Tmux提示符不在正常bash提示符PS1之后\W
我在Mac电脑上做了一些更新,似乎破坏了一些设置。在我的.bash_配置文件中有以下设置 导出PS1=“\W$” 这在我的正常bash会话中工作,只显示当前目录,而不是 整条路。但是,当我切换到tmux时,它会再次显示整个路径。bash配置文件中对PS1的其他更改(如颜色或其他字符)工作正常,并反映在tmux中。我已经清空了我的.tmux.conf,看看这是否导致了冲突,但是这个行为没有改变 我确实在系统上创建了一个新用户,并尝试了相同的PS1,它在正常会话和tmux中都能完美工作 我很困惑,因为我知道我已经让它工作了,但我不知道在更新中会发生什么变化。除了.bash_profile和.tmux.conf之外,还有哪些文件可以在这里使用?有没有一种方法可以告诉tmux从何处获取其设置 其他信息: 此行为在iTerm2和Terminal中都是相同的 Tmux版本1.8Tmux提示符不在正常bash提示符PS1之后\W,bash,tmux,Bash,Tmux,我在Mac电脑上做了一些更新,似乎破坏了一些设置。在我的.bash_配置文件中有以下设置 导出PS1=“\W$” 这在我的正常bash会话中工作,只显示当前目录,而不是 整条路。但是,当我切换到tmux时,它会再次显示整个路径。bash配置文件中对PS1的其他更改(如颜色或其他字符)工作正常,并反映在tmux中。我已经清空了我的.tmux.conf,看看这是否导致了冲突,但是这个行为没有改变 我确实在系统上创建了一个新用户,并尝试了相同的PS1,它在正常会话和tmux中都能完美工作 我很困惑,因
Mac OSX 10.9.1将以下内容添加到
.tmux.conf
:
new -n WindowName bash --login
set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"
set-option -g default-command bash
set -g default-terminal "screen-256color"
# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"
您可以将
WindowName
替换为您希望命名的第一个窗口。当以这种方式调用bash
时,它会将源代码发送到您的.bash\u profile
,.bash\u rc
,.profile
,等等。这就是您更改$PS1的地方。我也遇到了同样的问题,经过一些研究后,我将以下命令添加到了我的~/.tmux.conf
:
new -n WindowName bash --login
set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"
set-option -g default-command bash
set -g default-terminal "screen-256color"
# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"
我将OSX 10.9.5与iTerm2 Build 2.0.0.20141103、bash 4.3.30(1)版本、tmux 1.9a一起使用。Bash和tmux来自macports。我也有类似的问题。如果总是在应用bash命令的情况下启动tmux,则会得到正确的结果,如下所示:
tmux new bash
为了简化这个过程,我在~/.bash_别名文件中创建了一个别名,我一直在使用它:
alias tn='tmux new bash'
但这只适用于第一个窗口。在创建新窗口时,您必须通过在终端中执行bash
来再次启动bash。这一个对我有效:
在tmux/终端中:
tmux set-option -g default-command bash
或者简单地放入~/.tmux.conf
:
new -n WindowName bash --login
set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"
set-option -g default-command bash
set -g default-terminal "screen-256color"
# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"
将tmux与byobu一起使用时,可以尝试使用byobu提示符
命令。它会询问您是否需要bash颜色提示。回答“是”后,提示将变为正常user@host.在~/.tmux.conf
中添加以下行:
new -n WindowName bash --login
set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"
set-option -g default-command bash
set -g default-terminal "screen-256color"
# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"
不要忘记保存~/.tmux.conf
并重新启动tmux
,以便更改生效。在~/.tmux.conf中添加以下内容
set -g default-terminal "tmux-256color"
通过infocmp
命令,可以更好地检测系统的terminfo
数据库知道哪些终端。我的~/.tmux.conf中有以下内容:
new -n WindowName bash --login
set-option -g default-command "reattach-to-user-namespace -l /opt/local/bin/bash --login"
set-option -g default-command bash
set -g default-terminal "screen-256color"
# Last match wins
if-shell "infocmp xterm-256color" "set-option -g default-terminal xterm-256color"
if-shell "infocmp screen-256color" "set-option -g default-terminal screen-256color"
if-shell "infocmp tmux" "set-option -g default-terminal tmux"
如果infocmp
shell命令成功,则执行以下set选项
tmux命令。我知道我来晚了。但这是对我有用的
我刚刚在术语中添加了-256color
打开/运行tmux
运行以下命令:echo$TERM
。我们将使用这个的输出。我看到了屏幕
。在下一步中使用您自己的
编辑tmux配置文件:vim~/.tmux.conf
并添加以下行:set-g default terminal screen-256color
退出tmux
再次打开/运行tmux
使用tmux-256color
对我不起作用。我正在使用Ubuntu 18.04、bash 4.4.20、tmux 2.6。tmux
可能正在创建非登录shell,在这种情况下,.bashrc
将被取而代之。我认为情况并非如此,因为我的.bash_配置文件中的其他别名正在传入tmux,我对PS1所做的任何其他更改都会在tmux中正确反映,但是\W变量似乎不想正常运行。一旦进入tmux,$PS1设置为什么?竖起大拇指的人。。被接受的答案对我也不起作用。是,在tmux2.7
下仍然有效。每次启动gnome终端时,我都会通过执行tmux-u new session\,自动生成几个窗格;分裂窗口-h\;分割窗口-v\;选择窗格-t0\;发送密钥“C-m”代码>。。。在花了几个小时仔细阅读了许多维基和帖子之后,这终于对我起了作用。干杯,简单,干净,有效。这应该是公认的答案。@Cbhihe谢谢你的建议。但是你为什么需要发送密钥呢?没有最后一部分,它对我有效。@SPRBRN:Woaah!这已经有一段时间了,但是如果我能回忆清楚的话,send keys''C-m
将只发送空键'
,带回车符返回到先前使用选择窗格-t 0选择的窗格。因此,它应该以一种视觉上可识别的方式将光标定位在所述窗格中。这是使用它的唯一原因。只需移动鼠标并单击一次。。。您可以执行上面的命令(您甚至可以对term emulator进行编程,使其在启动时自动执行),然后就可以进行设置了。只需开始直接在默认选中的窗格中键入,由光标标识即可。;-)这是正确的答案,但让我们指出,第一个命令只在您重新启动系统之前有效。因此,您应该使用第二个命令并将其放在~/.tmux
中。这对我来说是可行的,但我还必须运行brew install repattach to user namespace
@tmux lover的一款在macOS上用zsh