Putty Dynamic Title (with $PWD)

2019-06-22 05:00发布

问题:

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

回答1:

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/~}"'


回答2:

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.

...