DEV Community

Philidor Green
Philidor Green

Posted on


Auto-alias Your Repos (with autocomplete)

Found this note about Auto-alias Your Repos, while this is very fast but I've another handy code to do the same. Check it out.

All my projects is under dev directory in the $HOME path, I've this code in my ~/.bash_profile:


goto() {
   cd "$HOME/dev/$1" 
_goto() {
  local word="${COMP_WORDS[COMP_CWORD]}"
  local comps=$(dir $HOME/dev)
  COMPREPLY=( $(compgen -W "${comps}" -- ${word}) )
complete -f -F _goto goto
Enter fullscreen mode Exit fullscreen mode

Now I can jump in any project folder under the dev with autocomple:

~ >  goto b<TAB>
bench_redis_fdb  bigboy           botmaster
bfm              bitpayer
Enter fullscreen mode Exit fullscreen mode

Use it!

Top comments (0)