#!/bin/sh
+# COMPREPLY: an array containing possible completions as a result of your function
+# COMP_WORDS: an array containing individual command arguments typed so far
+# COMP_CWORD: the index of the command argument containing the current cursor position
+# COMP_LINE: the current command line
+
+# if you want the current argument that you are trying to complete, you would index into the words array
+# using: ${COMP_WORDS[COMP_CWORD]}.
+
+
# to complete jump
_completemarks() {
local curw=${COMP_WORDS[COMP_CWORD]}
local wordlist=$(find $MARKPATH -type l -printf "%f\n")
- COMPREPLY=($(compgen -W '${wordlist[@]}' -- "$curw"))
+ COMPREPLY=($(compgen -W '${wordlist[@]}' -- $curw))
return 0
}
# complete jump & unmark commands with result of _completemarks
complete -F _completemarks jump unmark
+
+# to complete ssh-add with exisiting priv keys
+_complete_ssh_add () {
+ local curw=${COMP_WORDS[COMP_CWORD]}
+ local sshkeys=$(find $HOME/.ssh -type f -printf "%f\n" | grep 'id_' | grep -v '.pub$');
+ COMPREPLY=($(compgen -W '${sshkeys[@]}' -- $curw))
+ return 0
+}
+
+complete -F _complete_ssh_add ssh-add