John Mercier

[A software developer interested in java, groovy, and nixos]


Digging deeper into bash can be rewarding. Today, and possibly this weekend, I am going to focus on getting bash looking good (in xterm).


In a previous post I wrote about changing the directory output using \W instead of \w. This helps shorten the prompt when working in deep directories. Today I found this wiki page which shows how to add the output of the previous command to the prompt for debugging.

Every program that completes needs to return a status code. 0 means everything is ok, non-0 means something went wrong. Adding this to PS1 is great for testing commands like grep -q before adding it to a script. I setup the output with the green check box for 0 and red x for non-0.

In gentoo, this causes problems. My prompt shows a red and green box instead of the check box and x. Since these are unicode characters and xterm can be built without unicode support, the first thing I checked is the use flags.

john-gentoo john # emerge -av xterm

 * IMPORTANT: 2 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] x11-terms/xterm-314::gentoo  USE="openpty truetype unicode -Xaw3d -toolbar" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

Would you like to merge these packages? [Yes/No]

This shows that xterm was built with the unicode use flag turned on so the problem is not xterm.

On this guide I found this:

It is wise to add unicode to the global USE flags in /etc/portage/make.conf

After following this guidance I did not see a change.

Further in the guide is states that xterm should be started with uxterm to support unicode. Even then I have the same problem. After these changes I am sure either my font does not support these characters or my fonts are not set correctly.


{% highlight bash %}


cd /usr/share/consolefonts for i in * do setfont echo "testing >> $i << font" setfont $i echo -e "\0342\0234\0227" echo -e "\0342\0234\0223" read clear done {% endhighlight %}

This tests each console font by printing out the PS1 characters and waiting for input. I could not find a console font that has a checkmark and x. I am changing the characters to something more useful.

I also want to shorten the computer name so PS1 is not so long. This can be changed in /etc/conf.d/hostname. I am changing it to g1.


rc-update add consolefont boot rc-service consolefont start I now have consolefont setup. The font can be changed in /etc/conf.d/consolefont to one of the fonts in /usr/share/consolefonts


I am following this guide and restarting. This has setup X with nice fonts but not xterm.


my .xinitrc file only loads .Xresources not .Xdefaults. It is directly copied from /etc/X11/xinitrc. I basically copied this and set the faceSize to 8 instead of 11.

2014 - 2018 | Mixed with Foundation v5.5.1 | Baked with JBake v2.6.1