Tôi có một tập lệnh (không phải do chính tôi viết), hiển thị chi nhánh git branch/svn trong dấu nhắc lệnh của tôi. Có ai biết tại sao điều này sẽ không hoạt động trên mac? Nó hoạt động hoàn hảo trong linux.Biến số PS1 env không hoạt động trên mac
Từ https://github.com/xumingming/dotfiles/blob/master/.ps1:
# Display ps1 with colorful pwd and git status
# Acording to Jimmyxu .bashrc
# Modified by Ranmocy
# --
if type -P tput &>/dev/null && tput setaf 1 &>/dev/null; then
color_prompt=yes
else
color_prompt=
fi
__repo() {
branch=$(type __git_ps1 &>/dev/null && __git_ps1 | sed -e "s/^ (//" -e "s/)$//")
if [ "$branch" != "" ]; then
vcs=git
else
branch=$(type -P hg &>/dev/null && hg branch 2>/dev/null)
if [ "$branch" != "" ]; then
vcs=hg
elif [ -e .bzr ]; then
vcs=bzr
elif [ -e .svn ]; then
vcs=svn
else
vcs=
fi
fi
if [ "$vcs" != "" ]; then
if [ "$branch" != "" ]; then
repo=$vcs:$branch
else
repo=$vcs
fi
echo -n "($repo)"
fi
return 0
}
if [ "$color_prompt" = yes ]; then
# PS1='\[\e[01;32m\]\[email protected]\h\[\e[00m\]:\[\e[01;34m\]\w\[\e[33;40m\]$(__repo)\[\e[00m\]\$ '
PS1='\[\e[01;32m\]\u\[\e[00m\]:\[\e[01;34m\]\W\[\e[33m\]$(__repo)\[\e[00m\]\$ '
else
PS1='\[email protected]\h:\w$(__repo)\$ '
fi
unset color_prompt
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;\W\a\]$PS1"
;;
*)
;;
esac
@Alain, tôi sẽ đi ra ngoài một chi và đề nghị đó là "Làm thế nào để làm cho nó hoạt động trên máy Mac?" – blahdiblah
@blahdiblah Hmm, trình chỉnh sửa gợi ý rằng "Tại sao nó không hoạt động trên máy Mac?" – Alain
@Alain Damn! Tôi đa đên rât gân! – blahdiblah