Short tip: Enterprise Linux 7 and annoying prompts in GNU Screen titles

If you want to combine multiple terminal sessions on one window, multiplexers such as tmux or GNU Screen are useful tools. I have been using screen for 10 years with the following configuration:

 1$ cat ~/.screenrc
 2# F7+F8 for tab switching
 3bindkey -k k7 prev
 4bindkey -k k8 next
 5
 6# disable welcome
 7startup_message off
 8
 9# screen line with tabs, date and time
10hardstatus alwayslastline
11hardstatus string "%-w%{= BW}%50>%n %t%{-}%+w%< %87=%d.%m.%Y %0c"
12
13# start some screens
14screen -t bash 0
15screen -t bash 1
16
17# various settings
18deflogin off
19silencewait 15
20autodetach on

It's just a simple setup with a tiny bar at the bottom for tabs and the current date. I'm using tabs with customized titles a lot to keep an overview:

GNU screen tab

Unfortunately, the current terminal prompt is chosen as title under EL7:

GNU screen tab with prompt

To fix this, create the file /etc/sysconfig/bash-prompt-screen with the following content:

1# cat /etc/sysconfig/bash-prompt-screen
2printf "33]0;%s@%s:%s33\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"
3# chmod +x /etc/sysconfig/bash-prompt-screen

Now, tabs can be renamed again. 🙂

Translations: