changeset 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 ab0d075236e0
children deff86179ed8
files completion/_ssh-add zshrc
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
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
--- 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