Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Shell Title in WSL/Ubuntu without destroying PS1 #122

Closed
Dakkaron opened this issue Aug 25, 2020 · 0 comments · Fixed by #123
Closed

Set Shell Title in WSL/Ubuntu without destroying PS1 #122

Dakkaron opened this issue Aug 25, 2020 · 0 comments · Fixed by #123

Comments

@Dakkaron
Copy link
Contributor

Currently the documentation recommends setting the shell title this way:

PS1=$
PROMPT_COMMAND=
echo -ne "\033]0;New Title\a"

This sucks, because it sets PS1 to $. It would be much better to do this:

export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
echo -ne '\033]0;New Title\a'

This way, the command prompt stays the way it is, but setting the title still works.

Even better, add this to the end of ~/.bashrc:

settitle () {
  export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
  echo -ne '\033]0;'"$1"'\a'
}

What this does is it adds the command settitle that can be used at any time to change the window title like so:

settitle 'New Title'

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant