Mercurial > hg > zsh-env
annotate completion/_ssh-add @ 188:757255b99cff default tip
Der Pfad von nano hat sich geƤndert
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Tue, 14 Mar 2023 07:19:52 +0100 |
parents | a081e7a3977d |
children |
rev | line source |
---|---|
99
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
1 #compdef ssh-add |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
2 |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 _ssh-add() { |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
4 local -a keys |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
5 for key in $HOME/.ssh/*; do |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
6 # only accept files that do not end in .pub |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
7 if [[ ${key#*.pub} == "$key" ]]; then |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
8 # exclude files that are not ssh keys |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
9 if [[ ${key#*/config} == "$key" && ${key#*/known_hosts} == "$key" ]]; then |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
10 keys+=($key) |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
11 fi |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
12 fi |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
13 done |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
14 compadd "$@" $keys |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
15 } |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
16 |
a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
17 _ssh-add "$@" |