I want the current command to be shown in the title of screen (or tmux).
I tried following settings but it doesn't work.
How can I make it work?
.screenrc
shelltitle "$ |fish"
shell /usr/local/bin/fish
.config/fish/config.fish
set -x PS1 '\033k\033\\[\u@\h \W]\$ '
For fish version 2.1.0 you only have to edit ~/.config/fish/functions/fish_title.fish
function fish_title
hostname
end
For version 1.23.1 this doesn't seem to work. If the directories do not exist, first create them:
mkdir -p ~/.config/fish/functions/
What worked for me in .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
I think you're looking for fish_title
. See documentation here.
You could do something like this:
function fish_title
echo $_ ' '
pwd
end
funcsave fish_title
(Note you just run this at a prompt - don't put it in a config file).
Thanks for your answers. Finally, this made it work!
.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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With