Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Putty Dynamic Title (with $PWD)

I would like putty terminal to display the current folder. Is this possible ?

For example, when i'm in $HOME, the putty window title would be $HOME.

Then, if I do cd $HOME/foodir, the title would change to $HOME/foodir.

Is that possible ?

Thanks

like image 878
Carmellose Avatar asked Sep 27 '13 12:09

Carmellose


2 Answers

Setting PS1 did not work for me (putty 0.62).

I'm using bash, and here's what works :

PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
like image 167
laurent Avatar answered Nov 17 '22 22:11

laurent


Putty window is like a terminal on Linux, so it´s behavior is like a window in x mode on linux for example, so...

U can use the environment variable PS1 to define the title, like in this post: http://www.networkinghowtos.com/howto/how-to-set-the-putty-window-title-via-script/

In my case I defined the PS1 variable in /home/user/.bash_profile:

PS1="\[\e]2;\u@\H\w\a\[\e[32;1m\]>\[\e[0m\]"

But that´s my configuration, U can create your own.

...

like image 34
Celso Marigo Jr Avatar answered Nov 17 '22 22:11

Celso Marigo Jr