Let me see if I have deciphered your screen configuration correctly:
- You use something like
logfile "%t-screen.log"
(probably in a .screenrc
file) to configure the name of the log file that will be started later.
- You use the
title <hostname>
(C-a A) screen command to set the title of a new window, or
you do screen -t <hostname> ssh0 <hostname>
to start a new screen session.
- You use the C-a H (C-a :log) screen command to toggle logging to the configured file.
If so, then is nearly equivalent (requires tmux 1.3+ to support #W in the pipe-pane
shell command; pipe-pane
is available in tmux 1.0+):
There is no notification that the log has been toggled, but you could add one if you wanted:
bind-key H pipe-pane -o "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Toggled logging to $HOME/#W-tmux.log'
Note: The above line is shown as if it were in a configuration file (either .tmux.conf
or one you source
). tmux needs to see both the backslash and the semicolon; if you want to configure this from the a shell (e.g. tmux bind-key …
), then you will have to escape or quote both characters appropriately so that they are delivered to tmux intact. There does not seem to be a convenient way to show different messages for toggling on/off when using only a single binding (you might be able to rig something up with if-shell
, but it would probably be ugly). If two bindings are acceptable, then try this:
bind-key H pipe-pane "exec cat >>$HOME/'#W-tmux.log'" \; display-message 'Started logging to $HOME/#W-tmux.log'
bind-key h pipe-pane \; display-message 'Ended logging to $HOME/#W-tmux.log'
Your shell configuration is setting the terminal title to the command that's currently running. It's a fairly common configuration. Since it's done by the shell, it isn't done if the shell is running on another machine with a different shell configuration. The escape sequence to set the Screen window title is ␛kTITLE␛\
where ␛
is the escape character (byte value 27).
In bash, look for code that emits this escape sequence. The escape character is probably represented as \e
or \033
. The code could be in the prompt (PS1
) or in the command that's executed before displaying a new prompt after running a command (PROMPT_COMMAND
). Check their values (taking care not to emit the escape sequences to the terminal in case they contain a literal escape character):
printf 'PS1=%s\nPROMPT_COMMAND=%s\n' "$PS1" "$PROMPT_COMMAND" | cat -v
It's also possible but less common to emit this escape sequence before running a command, via the DEBUG
trap:
trap -p DEBUG
These variables (or the trap) would have to be set in the bash configuration, either yours or system-wide: normally ~/.bashrc
, and /etc/bash.bashrc
on some systems, but also possibly ~/.bash_profile
, ~/.profile
, /etc/profile
or ~/.bash_login
, or a file included by one of these. You can narrow it down by running a new shell with fewer settings:
env -i bash # no environment variables or per-user settings
env -i HOME="$HOME" bash # no environment variables, normal interactive shell
env -i HOME="$HOME" bash -l # no environment variables, login shell
HOME=/none bash # skips your per-user settings
A comparison on which of those exhibits the problem will tell you whether the settings come from your settngs or system-wide ones, and whether they're from .bashrc
(read by interactive shells) or from a login-time file (.profile
, etc.).
Best Answer
As documented in the man page,
screen
looks for a null title-escape-sequence.bash
sends this sequence via the PROMPT_COMMAND environment variable (for example, mine defaults toprintf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
.To disable this feature for a particular window, I just run
unset PROMPT_COMMAND
from that window. Of course, one could just add this to their~/.bashrc
or to a specific environment file to make it more persistent.