There are multiple questions about this sprinkled around the network, but what I could find has one of two things in common:

  • They give the manual solution, which only prints the current running program (with no arguments)
  • The use zsh preexec feature (though I am not sure how that interacts with screen). I am looking for a Bash solution.

How do I get my screen title to show the entire command run, so if I run 3 long running Python scripts for example, I can see the script names in the title as well? For bonus points, if I can get this to keep displaying the last command run that would be even better.

My current setup:

  • export PROMPT_COMMAND='/bin/echo -ne "\033k\033\0134"'
  • PS1 ends with >
  • shelltitle ">|bash"

I tried:

  • Adding stuff between \033k and \033 - breaks with ${BASH_COMMAND}
  • Using trap debug to set an external additional title since for XTERM with no screen I know the solution. This breaks badly with the PS1.

and variations of the above. I want a solution to be through screen, so both the window title and the screen window list show the full command.

As a bonus, I would really like it if Screen interacts nicely with Vim, so changing buffers/opening new files/etc. would dynamically updated in the screen title.


using PROMPT_COMMAND='/bin/echo -ne "\033k\033\0134"' in .bashrc togerther with shelltitle '$ |bash' in .screenrc works fine for me. Using this specific PROMPT_COMMAND somehow breaks my PS1 so i also added the following to .bashrc:

case "$TERM" in
    screen*) PROMPT_COMMAND='/bin/echo -ne "\033k\033\0134"';;

Example image attached - running sleep in window 0, find in window 1, watch in window 2, ping in window 3 and bash in window 4. enter image description here

  • Thanks for the input. Have a look at the screen selection window- are there arguments displayed? The fact you only see find for example is my problem. Suppose I am finding two things on two different screens. I would like to be able to tell them apart when selecting. – kabanus Jan 25 at 6:41
  • As such, I would like to see find /path -name... etc. – kabanus Jan 25 at 6:42
  • Well i did miss that you also wanted to see all the arguments of the commands in your original post. You could try to create some wrappers for your scripts just to overcome limitation of window naming, but that's not ideal. I found a link that migth help. The picture in the link looks at least a bit promising in my opinion. – lager Jan 25 at 12:44
  • I failed to make tap debug work because I did not enclose it in an if, and it interacted badly with PROMPT_COMMAND. You hit the jackpot!! Thanks, you get the credit - I edited the proper answer in, please confirm it for the benefit of future visitors. – kabanus Jan 26 at 9:03
  • @Isaac while my edit did deviate from original intent, this is not an answer currently. The OP did provide the way to a solution and all you are doing is denying them some reputation. I think it would have been more beneficial if you allowed lager to choose to accept or decline. As it stands, I have to remove the accepted mark. – kabanus Jan 27 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.