You are not logged in.
For various reasons, I have recently been running multiple bash shells to monitor what is going on with my system. Some shells use official packages like: nethogs, iptraf-ng, iftop …. etc, with preset command line options and pipes, while others are home grown utilities. For convenience, these are all set up with their own .desktop launchers.
In addition, I have been using the “Alltray” package to allow me to minimise the respective terminal windows to the system tray.
I would like to be able to give each terminal window a unique name, for example, instead of “Terminal”, the nethogs terminal would display “Nethogs” on the title bar. Obviously, using the xfce-terminal, I can set the title manually from the terminal menu, but I would prefer if this was all taken care of automatically from inside the various shells.
The closest I have come to a working solution is either:
PROMPT_COMMAND='echo -en "\033]0;New terminal title\a"'
#or
PROMPT_COMMAND='echo -en "\033]0;New terminal title\007"'
The problem is that this only works after a bash is completed and returns to the command prompt, ie, too late to be of any use.
So, is there a way to change the title of a terminal window, from inside a shell, without returning to the bash prompt?
Thanks for your input
Irvine
Last edited by IrvineHimself (2017-07-25 14:58:45)
Et voilà, elle arrive. La pièce, le sous, peut-être qu'il arrive avec vous!
Offline
I asked a similar question some time ago. https://bbs.archlinux.org/viewtopic.php?id=222054
Maybe this: http://www.davidpashley.com/articles/xt … with-bash/
if [ "$SHELL" = '/bin/bash' ]
then
case $TERM in
rxvt|*term)
set -o functrace
trap 'echo -ne "\e]0;"; echo -n $BASH_COMMAND; echo -ne "\007"' DEBUG
export PS1="\e]0;$TERM\007$PS1"
;;
esac
fi
Offline
Thanks, that actually worked
Not quite as pretty as changing the title manually using the terminal menu, but still quite usable. It’s a shame that neither your previous thread nor the original source material came up in a Google search, so I am going to give a little bit of detail and hope Google picks it up.
I am not certain I understand the full subtlety, but I made a few changes to make it more applicable to my use case. (Basically, since I know I am using bash, I ditched the error checking.)
For an official package, I created a shell in /usr/local/bin and pointed a .desktop launcher at it. For example:
#!/bin/bash
set -o functrace
trap 'echo -ne "\e]0;"; echo -n $BASH_COMMAND; echo -ne "\007"' DEBUG
export PS1="\e]0;$TERM\007$PS1"
sudo nethogs -v 3
And for a custom bash, I just added the work folder to the path and repeated the above:
#!/bin/bash
PATH=$PATH:$HOME/Git/MyWorkFolder
export PATH
set -o functrace
trap 'echo -ne "\e]0;"; echo -n $BASH_COMMAND; echo -ne "\007"' DEBUG
export PS1="\e]0;$TERM\007$PS1"
MyCustomBash
Anyway, thanks again. Your solution is quite usable, and, using “AllTray”, I can quickly toggle the visibility of the desired monitor.
Irvine
Last edited by IrvineHimself (2017-07-25 15:04:04)
Et voilà, elle arrive. La pièce, le sous, peut-être qu'il arrive avec vous!
Offline
Glad I was able to help
Offline