Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding git alias to .bash_profile not working

I edited my $Home .bash_profile to include some git alias commands. I am rather new to this and I can't figure out what went wrong.

.bash_profile

alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'

alias got='git '
alias get='git '

PS1="\u$ "
alias ll="ls -lahG"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && \
. "$HOME/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

I can't seem to understand what I did wrong. Any ideas?

[EDIT] Just wanted to mention that the part that I added is from PS1 up. For example alias ll = "ls -lahG" works well. The ones above do not.

[EDIT2] I tried to user gs(){ git status "$*"; } instead but that didn't seem to do the trick.

[EDIT3] The problem was that I had to source ~/.profile. What I ended up doing is putting it in the ~/.bashrc file and source that file at Sputnick's recommendation.

like image 719
Marius Pop Avatar asked Oct 01 '12 16:10

Marius Pop


Video Answer


1 Answers

You should use ~/.bashrc and not ~/.bash_profile for aliases.

~/.bashrc is for interactive use, see http://mywiki.wooledge.org/DotFiles & http://wiki.bash-hackers.org/scripting/bashbehaviour

And most important thing, you should source the modified file with :

. ~/.bashrc

or

source ~/.bashrc
like image 113
Gilles Quenot Avatar answered Oct 18 '22 01:10

Gilles Quenot