Putty Dynamic Title (with $PWD)

14,141

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

Solution 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.

...

Share:
14,141
Carmellose
Author by

Carmellose

Mostly using technologies such as C, C++, Python, R and SQL.

Updated on June 04, 2022

Comments

  • Carmellose
    Carmellose about 2 years

    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

  • Daniel Harding
    Daniel Harding over 9 years
    To make this work as intended, I had to add a backslash before the tilde in the PWD expansion.