Mercurial > hg > zsh-env
annotate completion/_ssh-add @ 173:f8c9b13158b8
create a default zshrc for the host
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Sat, 04 Apr 2020 04:23:36 +0200 |
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 "$@" |