我编辑了我的 $Home .bash_profile 以包含一些 git 别名命令。我对此很陌生,我不知道出了什么问题。
.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
我似乎无法理解我做错了什么。有什么想法吗?
[编辑] 只是想提一下,我添加的部分是从 PS1 开始的。例如 alias ll = "ls -lahG"
效果很好。上面的没有。
[EDIT2] 我尝试使用 gs(){ git status "$*"; } 相反,但这似乎并没有起到作用。
[EDIT3] 问题是我必须获取 ~/.profile。我最终做的是将它放在 ~/.bashrc 文件中,并根据 Sputnick 的建议获取该文件。
最佳答案
您应该使用 ~/.bashrc
而不 ~/.bash_profile
作为别名。
~/.bashrc
用于交互使用,参见 http://mywiki.wooledge.org/DotFiles & http://wiki.bash-hackers.org/scripting/bashbehaviour
最重要的是,您应该使用以下方式获取修改后的文件:
. ~/.bashrc
或
source ~/.bashrc
关于git - 将 git 别名添加到 .bash_profile 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12676864/