My Current [WSL] [Windows Terminal] Bash Shell Prompt


This blog post describes how I define the text prompt me to enter a command in the Bash shell using Windows Subsystem for Linux with Windows Terminal. This prompt is similar to the default in that it indicates the date and time that the previous command completed, username@hostname, and the current working directory path, but adds linefeeds to separate output from command invocations.

Other than removing chroot, which is irrelevant to me, and minor formatting changes such as as adding linefeeds, the components of my current Bash shell prompt are basically the defaults.

  • \n – linefeed to visually separate command output
  • [\D{%F %T}] – date and time
  • : – literal colon
  • \[\033[01;32m\]\u@\h\[\033[00m\] – gren user@host
  • : – literal colon
  • \[\033[01;34m\]\w\[\033[00m\] – blue working directory path
  • \n – literal linefeed
  • $ – literal dollar sign
  • (space) – literal space after dollar sign

For simplification, I removed the following from the default prompt because I do not use chroot.

${debian_chroot:+($debian_chroot)}

To use a variant of this prompt, you could append the following line to your ~/.bashrc file to override the default prompt definition logic without changing it.

PS1='\n[\D{%F %T}]:\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\n$ '

Alternatively, you could add this line to a custom initialization file as described in the following blog post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: