# HG changeset patch # User Dirk Olmes # Date 1476757548 -7200 # Node ID a081e7a3977d7bc1caaa876d146d352b73dbd091 # Parent ab0d075236e067a58005871028eb17f0237c30db Add support for custom completions to zshrc. Add a completion function to match all ssh keys in ~/.ssh when using ssh-add. diff -r ab0d075236e0 -r a081e7a3977d completion/_ssh-add --- /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 diff -r ab0d075236e0 -r a081e7a3977d zshrc --- a/zshrc Sun Sep 18 09:56:03 2016 +0200 +++ b/zshrc Tue Oct 18 04:25:48 2016 +0200 @@ -22,6 +22,7 @@ fi # enable zsh's fancy autocomplete +fpath=(~/.zsh-env/completion $fpath) autoload -U compinit compinit