Home » Questions » Computers [ Ask a new question ]

Window Title in Bash

Window Title in Bash

How can I set the window title in Bash? I do know that in Windows Batch it is TITLE.

Asked by: Guest | Views: 55
Total answers/comments: 3
Guest [Entry]

"Here is a nice function to do it:

# Allow the user to set the title.
function title {
PROMPT_COMMAND=""echo -ne \""\033]0;$1 (on $HOSTNAME)\007\""""
}

Put that in your ~/.bashrc, then type ""title whatever"" to set the title. If you want to get rid of the hostname, remove ""(on $HOSTNAME)"".

Edit: make sure to . ~/.bashrc (aka source ~/.bashrc) before trying, of course.

Source link."
Guest [Entry]

"If you are using ""mintty"" (the default terminal of Cygwin since end 2011), add the following in .bashrc :

function title {
export WINDOWTITLE=$1
}
export PS1='\[\e]0;$WINDOWTITLE:\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]~\w\[\e[0m\]\n\$'

and reopen your terminal and type ""title ThisIsMyTitle"""
Guest [Entry]

"We need more information: The answer will depend on what terminal you're using, not what shell. Is this in an xterm? An rxvt? A cygwin window on windows? Etc.

(danben's answer works for xterms, and probably for rxvt terminals)"