7

Is it possible to change the title that Bash on Ubuntu on Windows displays in its title bar? By default it's set to <username>@<computername>:<CWD>. I'd like to, say, add Bash on Ubuntu on Windows: as a prefix to it.

I've tried some solutions that added different lines to .bashrc (such as using xtitle), but the problem is that BoUoW changes its title every time it changes the CWD, so it just immediately overrides whatever you set in .bashrc.

Is there a way to permanently either add a prefix or fully change the tile?

Biswapriyo
  • 11,584

1 Answers1

4

If you are using WSL you can edit ~/.bashrc file in your distro. This also works for Windows Terminal at least in version 0.7.

You need to locate \[\e]0; as explained here: https://askubuntu.com/a/405769/808082.

The example from .bashrc for Ubuntu 18.4:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

This means the title is set to ${debian_chroot:+($debian_chroot)}\u@\h: \w\a\.

In your case you need to change it to:

PS1="\[\e]0;Bash on Ubuntu on Windows: ${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
pvasek
  • 156