bashrc


This post is in the category: Configurations

Posts here will mostly contain full configuration files for my own reference and will not likely not have much explanation. See posts in the Guides category for more explanational posts.


I have a few customizations to the bash prompt and how bash interfaces with a terminal window.

Custom Bash Prompts

Default user prompt. Short and simple.

PS1='[\u@\h \w]$ '

The root prompt is the same as the user prompt, except red as a warning.

PS1='[\[\e[01;31m\]\u@\h \w\[\e[0m\]]$ '

Yellow prompt that I use on “jumper” boxes. They are normally SSH servers that sit between two networks.

PS1='[\[\e[01;33m\]\u@\h \w\[\e[0m\]]$ '

Update Terminal Title

This is taken from the CentOS default config in /etc/bashrc. I noticed that my terminal titles were updating on CentOS boxes, but not on Ubuntu boxes. This is the config to add to make things consistent.

case $TERM in
    xterm*)
        PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
        ;;
    screen)
        PROMPT_COMMAND='printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
        ;;
    *)
        ;;
esac
This entry was posted in Configurations on by .

About Andrew Wells

I have been developing on the LAMP stack since about 2006. I run Ubuntu XFCE on my desktop and have a history of managing Ubuntu and CentOS servers. I code web applications mostly in PHP but have experience with other languages as well. When I'm not working, I can be found working in my home lab or out snowboarding, hiking, camping, or biking depending on the season.

Leave a Reply

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