By default, the title of a screen session is the name of the last command entered, which is fine for me, but in some cases I'd like to change it. I know the command Ctrl–A A, but it only changes the title until the next command, and I'd like it to stay there until I decide otherwise.
EDIT:
Here's the preexec
function I found in my .zshrc
if [[ "$TERM" == "screen" ]]; then
local CMD=${1[(wr)^(*=*|sudo|-*)]}
echo -n "\ek$CMD\e\\"
fi
Best Answer
Depends how things are set up, but by default, something like this should work.
Then run:
settitle NEWTITLE
.See screen title docs and GNU screen faq for more details.
Given Ctrl+A A is only changing it until the next command, it's probably being set by
$PS1
(all shells), or$PROMPT_COMMAND
/DEBUG trap
(bash only) orprecmd
/preexec
(zsh only).You should look for any place that
\e
or\033
appears withk
or\\
after it, basically like mysettitle
example above.UPDATE
You said you had a custom
preexec
.Why not change it to this:
Then you can set a custom title by running:
and unset the title by running
Don't forget to change
precmd
and$PS1
as well if necessary.ASIDE
You could even extend this to all terminals (e.g.
xterm
,gnome-terminal
, etc.) by not hard coding the\ek
and\e\\
.This is how I do it:
Then you can change your
preexec
to: