My prompt string is printed using this statement,
printf '\033]0;%s@%s:%s\007' user host /home/user
Why does it need an escape character (\033
) and a bell character (007
)?
When i ran the same command manually, it prints nothing.
When i removed the escape characters and gave the command as,
printf '%s@%s:%s' user host /home/user
it prints,
user@home:/home/user
which is easier to understand.
So, how does the escape characters, \033
and 007
get converted to a shell prompt string?
Best Answer
Only
\033
is an escape and it initiates the escape sequence up until and include the;
.\033]0;
. This initiates a string that sets the title in the titlebar of the terminal and that string is terminated by the\007
special character.See
man console_codes
:That you don't see any changes is probably because your prompt sets the title to the default title string on returning to the prompt. Try: