Mercurial > hg > zsh-env
diff completion/_ssh-add @ 99:a081e7a3977d
Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add.
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 18 Oct 2016 04:25:48 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/completion/_ssh-add Tue Oct 18 04:25:48 2016 +0200 @@ -0,0 +1,17 @@ +#compdef ssh-add + +_ssh-add() { + local -a keys + for key in $HOME/.ssh/*; do + # only accept files that do not end in .pub + if [[ ${key#*.pub} == "$key" ]]; then + # exclude files that are not ssh keys + if [[ ${key#*/config} == "$key" && ${key#*/known_hosts} == "$key" ]]; then + keys+=($key) + fi + fi + done + compadd "$@" $keys +} + +_ssh-add "$@" \ No newline at end of file