Skip to content

Instantly share code, notes, and snippets.

@kdrdmr
Created April 1, 2013 09:40
Show Gist options
  • Save kdrdmr/5284033 to your computer and use it in GitHub Desktop.
Save kdrdmr/5284033 to your computer and use it in GitHub Desktop.
Auto complete example in bash alias commands
repo(){
to=$1
repo_path=/home/works/www/${to}
if [ -d "${repo_path}" ]; then
cd ${repo_path}
else
echo "repo bulunamadi: ${repo_path}"
fi
}
_repo_cd() {
local cur opts
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$(cd /home/works/www ; ls -d */. | sed 's|/./||')
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
}
complete -F _repo_cd repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment