Skip to content

Instantly share code, notes, and snippets.

@chrisgfortes
Created June 10, 2018 15:20
Show Gist options
  • Save chrisgfortes/477a601be52c386ccc195c2812c595ed to your computer and use it in GitHub Desktop.
Save chrisgfortes/477a601be52c386ccc195c2812c595ed to your computer and use it in GitHub Desktop.
Using custom command in the bash with autocompletion (MacOS - Bash)
#!/usr/bin/env bash
source ~/.bash_functions;
alias project='project $1'
_project_complete(){
COMPREPLY=($(compgen -d "$HOME"/Documents/Projects/"$2"))
COMPREPLY=("${COMPREPLY[@]##*/}")
}
project(){
cd $HOME/Documents/Projects/$1
}
complete -F _project_complete project
#!/usr/bin/env bash
source ~/.aliases;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment