Reputation: 543
From a different post I already know what to put in my .bashrc
to set the current executing command as the terminal title:
trap 'echo -ne "\033]2;$(history 1 | sed "s/^[ ]*[0-9]*[ ]*//g")\007"' DEBUG
I would like to adjust this in a way that if there's no command currently running, the title would be a modified version of the last command, for example the whole command in square brackets (like so: [find . -maxdepth 1 -type f]
).
How to achieve this?
Upvotes: 6
Views: 6832
Reputation: 1168
Easy and quick way to do this on the fly:
Install the program xtitle onto your PC by running this command from your terminal window: sudo apt-get install xtitle
.
Type xtitle YOUR_DESIRED_TITLE and hit ENTER/RETURN, e.g. xtitle Tomcat
will set the title to Tomcat. Repeat that command each time you want a new title.
Upvotes: 2
Reputation: 7698
You can (ab)use PS1 by putting the same escape sequence in so that every time the prompt is printed, the title gets updated.
export PS1="\033]2;[\$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//g')]\007$PS1"
The final PS1 just keeps your old prompt for the actual command line.
I don't actually use this, but it should work.
Upvotes: 4