Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Created March 18, 2013 14:42
Show Gist options
  • Save apcomplete/5187630 to your computer and use it in GitHub Desktop.
Save apcomplete/5187630 to your computer and use it in GitHub Desktop.
bash script for being too lazy to cd into sites directory (with autocompletion)
_sites () {
local client project
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ $prev == "sites" ]
then
COMPREPLY=( $(compgen -W "$(ls /Users/alex/Sites/)" -- $cur) );
else
COMPREPLY=( $(compgen -W "$(ls "/Users/alex/Sites/$prev")" -- $cur));
fi
}
complete -F _sites sites;
sites () {
cd "/Users/alex/Sites/$1/$2"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment