Skip to content

Instantly share code, notes, and snippets.

@artheus
Last active October 26, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artheus/85e149db1633b2c3f03e845772ab77fc to your computer and use it in GitHub Desktop.
Save artheus/85e149db1633b2c3f03e845772ab77fc to your computer and use it in GitHub Desktop.
My workspace bash function with completion
function wp() {
cd "$HOME/workspace/$1"
}
__wp_path_comp()
{
local cur_word="${COMP_WORDS[COMP_CWORD]}"
local wpcontent
wpcontent=`find $HOME/workspace/${cur_word}* -maxdepth 0 -type d -print 2> /dev/null | sed -e "s|$HOME/workspace/||" `
COMPREPLY=( $(compgen -W "$wpcontent" -S "/" -- $2) )
}
complete -o nospace -F __wp_path_comp wp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment