Language Selection

English French German Italian Portuguese Spanish

8 Useful and Interesting Bash Prompts

Filed under
Software

Many people don’t think of their command prompt as a particularly useful thing, or even pay it much attention. To me, this is a bit of a shame, as a useful prompt can change the way you use the command line. Well I’ve scoured the Interwebs looking for the best, most useful, or sometimes most amusing bash prompts. Here, in no particular order, are the ones I’d be most likely to use on my computers.

1. Show Happy face upon successful execution

This prompt is probably the most amusing one on the list, but remains useful. The idea is that as long as your commands execute successfully, your prompt shows a happy face. Any time a command fails, it shows a sad face instead.

PS1="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\`[\u@\h:\w]\\$ "

2.Change color on bad command
Here’s one of my favorites. This prompt has it all. Like above, the prompt changes color if your last command failed to run successfully, but it also shortens long paths and contains the bash history number of each command for easy retrieval.

rest here




More in Tux Machines

That Peculiar Linux 3.18 Kernel Bug Might Be Closed Soon

For the past month there's been kernel developers investigating "a big unknown worry in a regression" that have left many key kernel developers -- including Linus Torvalds -- puzzled. It looks like that investigation is finally being close to being resolved. Read more

New Releases

Notifications Without User Interaction on Ubuntu Are Annoying

The Unity desktop environment has a simple and rather ineffective system notification mechanism and it looks like that's not going to change, not even with the arrival of Unity 8. Read more

Librem Linux Laptop Drops NVIDIA Graphics But Still Coming Up Short Of Goal

One of the oddest things I found about the crowd-funded Librem 15 laptop when writing about it last month was that it wanted to be open-source down to the component firmware/microcode yet they opted to ship with a NVIDIA GPU. In an updated earlier this month, at least they came to their senses and dropped the discrete NVIDIA GPU. While I have no problems recommending NVIDIA graphics for Linux gamers and those wanting the best performance, that's only when using the proprietary drivers, and certainly wouldn't recommend it for a fully open-source system -- NVIDIA on the desktop side doesn't do much for the open-source drivers, let alone down to the firmware/microcode level. Instead the Librem folks have opted to upgrade the design to using an Intel Core i7 4770HQ processor that features more powerful Intel Iris Pro 5200 Graphics, which isn't as powerful as a discrete NVIDIA GPU but at least is more open-source friendly. Read more