4

Is this possible at all? (basically a pendant to cmd.exe's title command that Mikel's answer mentions, although I'd prefer changing the entire tab name instead of adding a window title)

2 Answers 2

4

In bash, the standard Xterm sequences documented at How to change the title of an xterm seem to work, e.g.

echo -e "\033]0;custom title\007"; cat

So try adding that to your PS1 in your .bashrc or whichever config file you use, e.g:

PS1="\033]0;\$PWD\007$PS1"

or use PROMPT_COMMAND instead if you are using bash.


In cmd.exe, you can use title <string> to set the title.

You would chain it together using a doskey alias like this:

doskey cd=title $1 ^&^& cd $1

Then set it to load for every new cmd using the instructions in Loading DOSKEY Automatically with CMD.


In both cases, to show only the window title, go to Settings->Appearance and tick the
Use console window title* box.

6
  • I'm afraid title is a built-in of cmd.exe, so bash claims bash: title: command not found :( but it works for cmd.exe, so +1 Jan 20, 2011 at 12:41
  • thanks for the update - wow, doskey's still around? Hm, I'd probably first of all doskey alias=doske Jan 20, 2011 at 12:51
  • Yes, my original answer was only for cmd. I have updated it with instructions for bash.
    – Mikel
    Jan 20, 2011 at 12:58
  • your current solution won't change the working directory, using PS1='\033]0;\u@\h:\w\007'$PS1 instead does the trick Jan 20, 2011 at 13:17
  • Sorry, yes, there was a missing backslash. It is fixed now.
    – Mikel
    Jan 20, 2011 at 13:18
1

Been a while, but the only post that mostly answered my problem
Building on the answer from Mikel and the comment from Tobias, adding

PS1='\[\033]2;\u:\w\007\]'$PS1

to ~/.bashrc allowed consoleZ (successor to console2) to show the shell title in the consoleZ tab, and not mess up line wrapping in the shell.

"Note the use of \[...\], which tells bash to ignore the non-printing control characters when calculating the width of the prompt. Otherwise line editing commands get confused while placing the cursor."
http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss4.3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .