Skip to content

Instantly share code, notes, and snippets.

@halvener
Last active August 29, 2015 14:21
Show Gist options
  • Save halvener/bded5ff75d7008bb78f0 to your computer and use it in GitHub Desktop.
Save halvener/bded5ff75d7008bb78f0 to your computer and use it in GitHub Desktop.
RHEL 7 .bashrc file
# .bashrc
# Colors
black_text='\e[0;30m' # Black - Regular
red_text='\e[0;31m' # Red
green_text='\e[0;32m' # Green
yellow_text='\e[0;33m' # Yellow
blue_text='\e[0;34m' # Blue
purple_text='\e[0;35m' # Purple
cyan_text='\e[0;36m' # Cyan
white_text='\e[0;37m' # White
# Bold Colors
black_bold='\e[1;30m' # Black - Bold
red_bold='\e[1;31m' # Red
green_bold='\e[1;32m' # Green
yellow_bold='\e[1;33m' # Yellow
blue_bold='\e[1;34m' # Blue
purple_bold='\e[1;35m' # Purple
cyan_bold='\e[1;36m' # Cyan
white_bold='\e[1;37m' # White
faded='\e[2m'
# Reset
reset='\e[0m' # Text Reset
# If we are inside a git repository, print git:<branchname>
git_prompt() {
if [ "$(/usr/bin/git rev-parse --is-inside-work-tree 2> /dev/null)" == "true" ]; then
local branchname=$(git rev-parse --abbrev-ref HEAD)
echo " \[$faded\](git:$branchname)\[$reset\]"
fi
}
# If we are inside a mercurial repository, print hg:<branchname>
hg_prompt() {
if $(hg --cwd $(pwd) root > /dev/null 2>&1); then
local branchname=$(hg branch)
echo " \[$faded\](hg:$branchname)\[$reset\]"
fi
}
# Customize the prompt. The format should be:
# user@host path (git:branch) (hg:branch)
# Should the user be root, color the prompt red
custom_prompt() {
local user_color=""
if [[ "$EUID" -eq 0 ]]; then
user_color="$red_text"
prompt="#"
else
user_color="$green_text"
prompt="\$"
fi
PS1="[\[$user_color\]\u\[$reset\]@\[$yellow_text\]\h\[$reset\] \[$cyan_text\]\W\[$reset\]]$(git_prompt)$(hg_prompt)${prompt} "
}
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
# User specific aliases and functions
export PROMPT_COMMAND="custom_prompt; $PROMPT_COMMAND"
HISTCONTROL=ignoredups:ignorespace
alias mpg123="mpg123 -C"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment