Putty Dynamic Title (with $PWD)

风格不统一 提交于 2019-12-14 00:58:09

问题


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.

...



来源:https://stackoverflow.com/questions/19050611/putty-dynamic-title-with-pwd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!