繁体   English   中英

#show在终端中使用.bashrc的分支

[英]#show branch in terminal with .bashrc

我正在使用以下.bashrc文件。 制表符补全工作正常。 然而。 #show分支的第二段代码不是很好。 当我第一次设置并获取它时,它运行良好。 我位于终端位置的终端窗口看起来像这样[~]$ ,当它在分支中时类似[direcorty (master)]$但是,当我打开终端的新选项卡窗口时,它回到类似Anders-imac:~ anderskitson$如何在状态行中保留Show分支。

#Git tab completion
source ~/git-completion.bash
# Show branch in status line
PS1='[\W$(__git_ps1 " (%s)")]\$ '
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'

之所以不能保留,可能是因为您的终端使用的是.bash_profile而不是.bashrc

我将创建一个指向您的.bashrc文件的链接,以便所有新的终端窗口都将使用单个.bashrc文件中的代码:

mv ~/.bash_profile ~/.bash_profile.bak
ln -s ~/.bashrc ~/.bash_profile

mv = move,如果您想保留一些重要内容,它将备份您当前的.bash_profile。 ln -s =创建从.bashrc到.bash_profile的符号链接。

也许您的外壳是登录外壳? 如果是,则不必读取.bashrc 尝试在.bash_profile进行类似的更改,或者仅从.bash_profile .bashrc

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM