【问题标题】:$PWD in window title bar, both in Bash and Tmux在 Bash 和 Tmux 中,窗口标题栏中的 $PWD
【发布时间】:2014-02-06 15:38:28
【问题描述】:

我希望我的窗口标题栏显示我的 PWD。在我的.bashrc 中,我有这个似乎对 Bash 有用:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

但是,当我使用 Tmux 时,窗口会显示我启动 Tmux 的目录,而不是我在 Tmux 中导航到的当前目录。

下面,我在~ 中启动了Tmux,然后导航到~/Downloads。标题栏仍显示~。在它后面是一个窗口,我只使用 Bash 导航到 ~/Downloads;它显示了我想要的:

以下是我已经尝试过但不起作用的方法:

【问题讨论】:

    标签: bash tmux pwd


    【解决方案1】:

    我想当我在结合其他一些更改之前尝试过这个......现在它可以工作了:

    在~/.tmux.conf:

    set -g set-titles on
    set -g set-titles-string '#T'
    

    在~/.bashrc 中(顺便说一下,我在switch 语句中添加了|screen):

    if [ "$color_prompt" = yes ]; then
        PS1='> '
        #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    else
        PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    fi
    unset color_prompt force_color_prompt
    
    # If this is an xterm set the title to user@host:dir
    case "$TERM" in
    xterm*|rxvt*|screen)
        PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
        ;;
    *)
        ;;
    esac
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-21
      • 1970-01-01
      • 2019-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多