Created
January 2, 2012 07:28
-
-
Save akheron/1549712 to your computer and use it in GitHub Desktop.
bash completion for sala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bash | |
_sala() { | |
local IFS=$'\n' dir=${SALADIR:-.} cur | |
if ! type _get_comp_words_by_ref >/dev/null 2>&1; then | |
cur=${COMP_WORDS[$COMP_CWORD]} | |
else | |
_get_comp_words_by_ref cur | |
fi | |
# Not initialized, bail out | |
[ ! -f "$dir/.salakey" ] && return | |
# Skip dotfiles, e.g. .salakey | |
local names=$(cd $dir && compgen -f -- "$cur" | grep -v '^\.') | |
COMPREPLY=($(for name in $names; do | |
[ -d "$dir/$name" ] \ | |
&& echo "${name}/" \ | |
|| echo "$name " # Add a space after filenames | |
done)) | |
} | |
complete -o nospace -F _sala sala |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment