The ★ Bash Prompt

I know you already love the command-line, the power of the whole world at your finger tips brings a smile to your face. Now make your time on the command-line extra special using a unicode bash prompt

Most modern terminal clients support UTF-8 characters, which means they can display the wide range of unicode characters, depending on fonts installed on your system. I do see quite a bit of difference in design and availability of characters between Linux and Mac clients.

Here’s what my current bash prompt looks like, relatively simple but still a touch of fancy:


limbo: ~ 

Here’s how I set my bash prompt, I source this colors file and set using color names:


source ~/dotfiles/extras/colors
FANCY="342226270"   # my fancy unicode prompt
export PS1="[$Cyan]h: [$Red]W [$Yellow]$FANCY [$Color_Off] "

Where the FANCY variable is the unicode character that I want. I’ve seen various different ways to get unicode to show in the terminal, including the simpliest copy-and-paste. I’ve found converting the character to octal to be the most portable especially for use within a prompt.

To get the octal number, copy and paste the character you want and echo into hexdump like so:


echo ▸ | hexdump -b

Which outputs the following, use the three bold parts:


0000000 342 226 270 012                                                
0000004

So in simpliest form it can be used, like so:


export PS1="\342\226\270"

Other Parameters within Prompt

You can put just about anything within the prompt, I used to include the time and more but found simple works well for me. Here are a few common ones you can include:


D{format} : date formatted using strftime
h         : short hostname 
H         : full hostname
t         : current time in 24-hour HH:MM:SS format
T         : current time in 12-hour HH:MM:SS format
u         : username of the current user
w         : current working directory (long)
W         : basename of current working directory (short)

Additionally, you can include the output of any command within your prompt, be selective because this will run everytime the prompt shows. See Bash Prompt HOWTO for more info.

Unicode Character Table

Here is a table of unicode characters I think would work well in a command-line prompt, there are 10,000 or so unicode characters. You can browse them all if you didn’t find something you like below.

2010
2011
2022
2023
2039
2039
203b
203b
2043
204e
2051
2052
2053
2055
2056
2058
2059
205a
205c
205d
205e
2192
21a3
21a6
21aa
21b1
21b3
21c9
21d2
21db
21dd
21e2
21e8
21fe
2217
221e
2234
2235
226b
227b
2299
229a
229b
229c
229d
229e
229f
22a0
22a1
22a2
22a6
22b3
22b9
22d9
2316
233e
235f
23e9
254c
254d
25b6
25b7
25b8
25b9
25ba
25bb
25c6
25c7
25c8
25c9
25ca
25cb
25cc
25cd
25ce
25cf
25ec
25ed
25ee
25ef
2600
2601
2602
2603
2604
2605
2606
2609
260a
260b
2614
2615
2618
261e
2620
2622
2623
2624
2625
2626
2629
262a
262b
262c
262d
262e
262f
2638
2639
263a
263b
263c
263d
263e
263f
2640
2641
2642
2654
2655
2656
2657
2658
2659
265a
265b
265c
265d
265e
265f
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
266a
266b
266c
266d
266e
266f
2670
2671
2690
2691
2692
2693
2694
2695
2696
2698
2699
269a
269b
269c
26bd
26be
26c4
26c5
270b
270c
270d
270e
270f
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
271a
271b
271c
271d
271e
271f
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
272a
272b
272c
272d
272e
272f
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
273a
273b
273c
273d
273e
273f
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
274a
274b
2763
2764
2799
279a
279b
279c
279d
279e
279f
27a0
27a1
27a2
27a3
27a4
27a5
27a6
27a7
27a8
27a9
27aa
27ab
27ac
27ad
27ae
27af
27b8
27b9
27ba
27bb
27bc
27bd
27be
2b50
2e2a
2e2b

One thought on “The ★ Bash Prompt

  1. Nice post, but can I ask what font face you’re using? The few I tried didn’t seem to have these unicode characters. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>