Macos – why is screen not showing the current running process name? (Mac OSX Terminal bash)

bashgnu-screenmacosterminal

I am running screen inside Mac OSX Terminal app (bash).

Here is the screenrc (got it from here):

$ cat ~/.screenrc 
termcapinfo xterm* ti@:te@
startup_message off
defutf8 on
shelltitle "$ |what?" # make screen assign window titles automatically
hardstatus alwayslastline
hardstatus string '%{= kw} [ %{= kb}%H%{= kw} ][%= %{= kw}%?%-Lw?%{= kW}%n*%f %t%?%?%{= kw}%?%+Lw%?%?%= ][ %{r}%l%{w} ]%{w}[%{r} %m/%d/%y/ %C %A %{w}]%{w}'
$

As can be seen I do have the line to show the current process name as the title in screen:

shelltitle "$ |what?" # make screen assign window titles automatically

But inside screen I just see "what?" (the default) instead of the process-name. Which suggests that "$" is not working.

What am I missing? And how does the "$ |something-else" work?

Best Answer

What is your bash prompt set to (i.e. the PS1 variable)?

Try the following in your .bashrc or .profile:

export PS1='\[\033k\033\\\]\u@\h:\w\$ '

and in your .screenrc:

shelltitle "$ |bash:"

This is what I have and it works. Basically, screen needs a magic string to know how your prompt ends so it can pick up the command that's running. You can vary it, but see the explanation on this page for more information on how it works:

Related Question