【发布时间】:2014-07-22 10:41:20
【问题描述】:
我希望当前命令显示在屏幕(或 tmux)的标题中。
我尝试了以下设置,但它不起作用。
我怎样才能让它工作?
.screenrc
shelltitle "$ |fish"
shell /usr/local/bin/fish
.config/fish/config.fish
set -x PS1 '\033k\033\\[\u@\h \W]\$ '
【问题讨论】:
标签: gnu-screen fish
我希望当前命令显示在屏幕(或 tmux)的标题中。
我尝试了以下设置,但它不起作用。
我怎样才能让它工作?
.screenrc
shelltitle "$ |fish"
shell /usr/local/bin/fish
.config/fish/config.fish
set -x PS1 '\033k\033\\[\u@\h \W]\$ '
【问题讨论】:
标签: gnu-screen fish
对于 fish 2.1.0 版,您只需编辑 ~/.config/fish/functions/fish_title.fish
function fish_title
hostname
end
对于 1.23.1 版本,这似乎不起作用。如果目录不存在,请先创建它们:
mkdir -p ~/.config/fish/functions/
【讨论】:
.config/fish/functions/fish_title.fish 对我有用:
function fish_title
# this one sets the X terminal window title
# argv[1] has the full command line
echo (hostname): (pwd): $argv[1]
switch "$TERM"
case 'screen*'
# prepend hostname to screen(1) title only if on ssh
if set -q SSH_CLIENT
set maybehost (hostname):
else
set maybehost ""
end
# inside the function fish_title(), we need to
# force stdout to reach the terminal
#
# (status current-command) gives only the command name
echo -ne "\\ek"$maybehost(status current-command)"\\e\\" > /dev/tty
end
end
【讨论】:
>/dev/tty 对GNU 屏幕 非常重要。我发现此时其他答案都失败了。
我认为您正在寻找fish_title。见documentation here。
你可以这样做:
function fish_title
echo $_ ' '
pwd
end
funcsave fish_title
(注意你只是在提示符下运行它——不要把它放在配置文件中)。
【讨论】:
感谢您的回答。 终于成功了!
.screenrc
shelltitle "$ |fish"
shell /usr/local/bin/fish
.config/fish/config.fish
function fish_prompt
echo -ne '\033k'
echo -ne $argv
echo -ne '\033\\'
echo -ne '$ '
end
【讨论】: