1

Here's what I would do to set the title interactively via shell:

echo -ne "\033]30;$PWD\007"

How can I make the above happen automatically each time I change my working directory?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Rajul Shah
  • 31
  • 4

2 Answers2

2

Set konsole's window title to be some string as defined below:

export PROMPT_COMMAND='echo -ne "\033]0;$(basename ${PWD})\007"'

or

export PROMPT_COMMAND='echo -ne "\033]30;$PWD\007"'

The title of konsole should change immediately when you run either command.

Found the answer here:

http://www.thegeekstuff.com/2008/09/bash-shell-take-control-of-ps1-ps2-ps3-ps4-and-prompt_command/

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Rajul Shah
  • 31
  • 4
0

If you add this to your shell prompt $PS1, it will be executed after every command (including changing directories). You need to escape the dollar sign in $PWD or it will only be executed when you are setting the prompt, instead of every time the prompt is displayed. You can do this by executing the following line:

PS1="\033]30;\$PWD\007$PS1"

Which should just add it to the beginning of your shell prompt. I would also recommend adding it to your .bashrc or profile script so it is done automatically on startup.

Kevin Brown-Silva
  • 40,873
  • 40
  • 203
  • 237
  • Appreciate the response, but that doesn't stick. It does it once, but not when I cd to different directory. – Rajul Shah Nov 18 '14 at 23:06
  • Hi Kevin, The solution you provided has a bad side-effect: the shell command line wraps prematurely and things get messed up after that. Took me some time to figure out this change was the reason. – Rajul Shah Dec 03 '14 at 18:35