How do I choose what shows up in PuTTY title bar from Linux?
The terminal title is set by using special escape sequences in the console output. By default, the bash prompt includes these escape sequences and sets the title to the current working directory.
So you will have to edit your PS1 variable (most of the time it's set in ~/.bashrc
), otherwise bash will overwrite your title every time the prompt is displayed.
You can then set the title by putting the following in a script that gets executed when you log in, e.g. ~/.profile
:
echo -e "\033]0;<your string>\007"
Most terminal programs - including konsole, putty and xterm - emulate the old VT100 terminal. This terminal allows you to set certain things, including bold, colors, setting the terminal title, and so on, using special character sequences called escape sequences.
The bash shell has a variable called PROMPT_COMMAND which, if set, is evaluated before every prompt you print out (I believe zsh has something similar, in fact I think bash took the code from them). You can output escape sequences in PROMPT_COMMAND and it will set your title bar.
This is what I have in mine (Linux/bash):
USER=$(/usr/bin/id -un)
HOSTNAME=$(uname -n)
HOSTNAME=${HOSTNAME%%.*}
PROMPT_COMMAND='echo -ne "\e]0;$USER@${HOSTNAME}: $(pwd -P)\a"'
You can put this in your ~/.bashrc
There are a lot of customizations you can do with your terminal. I like bold in my prompt, to make it easier to see the end of my prompt. This makes it bold yellow, good against my default black background:
PS1="\[\e[33;1m\]\h:\$\[\e[0m\] "
Look around for Linux Prompt Customization, you'll find more HowTos than you'll know what to do with. Pick the one that you find easiest to read.
I have searched many forums and I haven't found the answer for the question:
How to get all command output to Putty title?
Needed it for other programs to know when some jobs on a server is done and is it done right or wrong. Plink stdout and stdin wasn't working. I used many tweaks with wait delays and for some commands that worked, for others not. XSEL and XCLIP couldn't be installed on that server.
So here is the solution:
- Get command output in a file.
- Echo that file to title.
On Putty client and SUSE server it looks like this:
ls /home | grep domagaja > logutoit.txt
echo -e "\033]0\\;$(cat logutoit.txt)\\007\\c"
Hopefully someone will be able to use this. It won't work for all server types and putty client settings, of course, but the idea should work well.