Skip to content

Instantly share code, notes, and snippets.

@Aricg
Last active August 29, 2015 14:04
Show Gist options
  • Save Aricg/5a8e2e5e0b4e41a2cbb7 to your computer and use it in GitHub Desktop.
Save Aricg/5a8e2e5e0b4e41a2cbb7 to your computer and use it in GitHub Desktop.
prompt
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
#I like to know the load when I login.
echo "Load: $(uptime | awk -F ":" '{print $NF}')"
#Pretty, fast, git log
function lg {
command git log --graph --pretty=format:'%Cred%h%Creset - %ce %C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --date=relative "$@"
}
alias v='vim'
#alias sudo='sudo '
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias ls='ls -F'
alias grep='grep --color=auto'
alias g='grep --color=auto'
alias h='history'
alias gits='puppet parser validate $(git ls-files --others --exclude-standard) \
&& git status'
#
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
#History stuff
HISTFILESIZE=400000000
HISTSIZE=10000
export HISTSIZE PROMPT_COMMAND
shopt -s histappend
shopt -s checkwinsize
PROMPT_COMMAND="history -a"
# Sexy Solarized Bash Prompt, inspired by "Extravagant Zsh Prompt"
# Customized for the Solarized color scheme by Sean O'Neil
# Taken from github somewhere
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then TERM=gnome-256color; fi
if tput setaf 1 &> /dev/null; then
tput sgr0
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
BASE03=$(tput setaf 234)
BASE02=$(tput setaf 235)
BASE01=$(tput setaf 240)
BASE00=$(tput setaf 241)
BASE0=$(tput setaf 244)
BASE1=$(tput setaf 245)
BASE2=$(tput setaf 254)
BASE3=$(tput setaf 230)
YELLOW=$(tput setaf 136)
ORANGE=$(tput setaf 166)
RED=$(tput setaf 160)
MAGENTA=$(tput setaf 125)
VIOLET=$(tput setaf 61)
BLUE=$(tput setaf 33)
CYAN=$(tput setaf 37)
GREEN=$(tput setaf 64)
else
BASE03=$(tput setaf 8)
BASE02=$(tput setaf 0)
BASE01=$(tput setaf 10)
BASE00=$(tput setaf 11)
BASE0=$(tput setaf 12)
BASE1=$(tput setaf 14)
BASE2=$(tput setaf 7)
BASE3=$(tput setaf 15)
YELLOW=$(tput setaf 3)
ORANGE=$(tput setaf 9)
RED=$(tput setaf 1)
MAGENTA=$(tput setaf 5)
VIOLET=$(tput setaf 13)
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
GREEN=$(tput setaf 2)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
# Linux console colors
MAGENTA="\033[1;31m"
ORANGE="\033[1;33m"
GREEN="\033[1;32m"
PURPLE="\033[1;35m"
WHITE="\033[1;37m"
BOLD=""
RESET="\033[m"
fi
#functions for git features of PS1 below.
parse_git_dirty () {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
parse_git_branch () {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
#PS1 prints info when you are in a git repo. prints a red jolly rogers if the last command did not exit 0
PS1="\[ \$(if ! [ \$? = 0 ]; then printf '\e[033;31m \xE2\x98\xA0 '; fi)\]\[${BOLD}${CYAN}\]\u \[$BASE0\]at \[$CYAN\]\h\[$BLUE\]\w\[$BASE0\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$YELLOW\]\$(parse_git_branch)\[$BASE0\]\n\$ \[$RESET\]"
PS2="continue-> "
bash --version | head -n1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment