Thursday, April 25, 2024
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 7082  / 1 Year ago, sun, january 1, 2023, 3:24:00

I want the name of command running , e.g unzip to be visible through the title bar of gnome-terminal , but it seems to be impossible , if the application running doesn't set a title explicitly , even though I choose 'Replace initial title' option in the profile dialog.


More From » gnome-terminal

 Answers
4

This is a more complete solution actually taking care of bash-completion spamming garbage.



To be clear: I did nothing on my own here but research. All credit goes to Marius Gedminas.



This works perfectly for me with Gnome-Terminal/Terminator (put it in your .bashrc or somewhere that's getting sourced)



# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "033]0;${USER}@${HOSTNAME}: ${PWD}007"'

# Show the currently running command in the terminal title:
# http://www.davidpashley.com/articles/xterm-titles-with-bash.html
show_command_in_title_bar()
{
case "$BASH_COMMAND" in
*033]0*)
# The command is trying to set the title bar as well;
# this is most likely the execution of $PROMPT_COMMAND.
# In any case nested escapes confuse the terminal, so don't
# output them.
;;
*)
echo -ne "033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}007"
;;
esac
}
trap show_command_in_title_bar DEBUG
;;
*)
;;
esac


Also this is a cross-post because I just found out about it and wanted to share and I think it's useful here as well.


[#38990] Monday, January 2, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tisglitter

Total Points: 307
Total Questions: 103
Total Answers: 119

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
tisglitter questions
Sun, Jan 9, 22, 16:18, 2 Years ago
Wed, Jun 1, 22, 18:03, 2 Years ago
Fri, Dec 10, 21, 14:31, 2 Years ago
;