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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With