How can I get a $PS1
containing box-drawing characters?
I am running bash, if it makes a difference.
How can I get a $PS1
containing box-drawing characters?
I am running bash, if it makes a difference.
If you've got an editor with UTF-8 support, you can input the Unicode box-drawing characters and geometric shapes directly. Something like:
PS1='┌─[blah][blah]
└─▪ '
Write this to a file using your editor, then source the file into your bash session with source ./myfile
. When you're ready to keep it, add it to your .bashrc file.
The other, older way to do it is to use VT100 escape codes to switch to the terminal's line-drawing character set. In this case, your PS1 line looks like this:
PS1='\[\e(0\]lq\[\e(B\][blah][blah]
\[\e[0\]mq~\[\e(B\] '
The \[
and \]
tell bash that these portions of the prompt are non-printing, which helps it know where the cursor is when doing command-line editing. The \e(0
switches to the line-drawing character set, and the \e(B
switches back. While in line-drawing mode:
You can build a complete list by running things like printf '\e(0 qwertyuiop \e(B \n'
at the bash prompt.
Here's a very nice sampling of different PS1:
The one you want is this:
You will have to change it a bit, but the elements are there. I suggest you take a look here for more info: