annotate completion/_ssh-add @ 170:95e349996727

Add a script for setting up the shell environment on a naked home. Use a global .hgrc that has a hook for local includes per machine.
author Dirk Olmes <dirk.olmes@codedo.de>
date Sat, 04 Apr 2020 03:53:18 +0200
parents a081e7a3977d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 "$@"