Reputation: 21
I had an alias in my bash profile like this:
alias test='cd /Usr/work/dir/test'
every time I would try to use bash completion for git in a terminal it would:
As soon as I removed that alias bash completion for git works fine. Why's that?
git version 2.26.2
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) Copyright (C) 2007 Free Software Foundation, Inc.
Upvotes: 0
Views: 50
Reputation: 532238
test
is a built-in command, and creating an alias named test
shadows it, which could lead to unforeseen issues. Pick a different name.
alias goto_test='cd /Usr/work/dir/test'
However, this is probably the least desirable solution. First, consider using a function instead:
goto_test () {
cd /Usr/work/dir/test
}
Second, you can add /Usr/work/dir
to your CDPATH
variable, so that you can quickly switch to any subdirectory without having to use the entire path.
$ CDPATH=/Usr/work/dir
$ cd test
/Usr/Work/dir
$ pwd
/Usr/Work/dir/test
This saves you from having to define multiple aliases or functions if there are several directories you might commonly switch to.
Upvotes: 3