mbl-35 / wslctl

Provide a single command wslctl to create, backup and manage WSL (Windows Subsystem for Linux) instances on a windows host
0 stars 1 forks source link

Wsl hostname in bash prompt #16

Closed mbl-35 closed 2 years ago

mbl-35 commented 2 years ago

Instead of having the hosting machine hostname in the bash prompt, set the wsl instance name in prompt by default.

Add in a /etc/profile.d script :

# Wslname in PS1
PS1="\[\e]0;\u@$WSL_DISTRO_NAME: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@$WSL_DISTRO_NAME\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
mbl-35 commented 2 years ago

Better use the /etc/wsl.conf, and set the hostname parameter in the [network] section. Thus, PS1 env variable is unchanged, and this works even if zsh or other is used.