Custom Bash Prompts

I am a terminal junkie. When I was a kid, the first thing that I ever learned to do on a computer was program BASIC on a command line. Then I learned DOS (mostly to play smutty games like Leisure Suit Larry). When I discovered Linux, the amount of raw unadulterated power that could be had from the command line blew me away. It made DOS seem primitive and ancient by comparison. One thing that I really grew to love was my customized command line.

I like Macs because they are a pretty face with a UNIX core. Unlike most flavors of Linux, it has the most plain default command prompts (no colored directory listings, inelegant prompt). However, every time I have to reinstall the OS or set up a new machine (or VM) I always forget to copy over “.bash_profile“. So I end up having to reset my command prompt again and again. So I finally decided to write it down for myself and anyone else who comes across this.

For anyone who wants a good tutorial on customizing BASH can go here. (Also be sure to check out the section on color schemes.)  Note: If you start playing around with colors, make sure you wrap all /e[ tags with /[ and /]. These tell the terminal that they are non-printing characters. If you don’t, it will start messing up word-wrapping.

For those who want to just get some quick colors and a simple prompt, open up “~/.bash_profile” and “~/.bashrc” and paste the following in:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
export PS1="\[\e[0;32m\]\u@\h:\[\e[m\e[1;34m\]\w\[\e[m\] \$>"

If you want to have more fun, add the following as well. But make sure you have fortune installed (open a terminal and type “fortune”. If a witty aphorism appears, it is installed.)

fortune -a

Your command line prompt should look like this:

flynn@Encom:~/desktop $>

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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 )

Google+ photo

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

Connecting to %s