【问题标题】:#show branch in terminal with .bashrc#show 带有 .bashrc 的终端分支
【发布时间】:2012-02-02 00:16:02
【问题描述】:

我正在使用以下 .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"'

【问题讨论】:

    标签: git bash terminal


    【解决方案1】:

    它没有停留的原因可能是因为您的终端使用的是.bash_profile,而不是您的.bashrc

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

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

    mv = 移动,这将备份你当前的 .bash_profile,以防你有重要的东西想要保留。 ln -s = 创建一个从 .bashrc 到 .bash_profile 的符号链接。

    【讨论】:

      【解决方案2】:

      也许你的 shell 是登录 shell?如果是,.bashrc 不一定会被阅读。尝试在您的 .bash_profile 中进行类似的更改,或者直接从您的 .bash_profile 获取 .bashrc

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-09
        • 2013-05-17
        • 2018-12-03
        • 2021-04-02
        • 2019-01-20
        • 2014-04-29
        • 2019-08-02
        • 1970-01-01
        相关资源
        最近更新 更多