Created
March 18, 2014 05:44
-
-
Save fred/9614174 to your computer and use it in GitHub Desktop.
show git branch in bash prompt, nicer bash prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add to home .bashrc | |
if [[ $- != *i* ]] ; then | |
# Shell is non-interactive. Be done now! | |
return | |
fi | |
safe_term=${TERM//[^[:alnum:]]/?} | |
match_lhs="" | |
[[ -f ~/.dir_colors ]] && match_lhs="${match_lhs}$(<~/.dir_colors)" | |
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)" | |
function parse_git_branch { | |
#git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
#Rather than running git-branch + sed for every shell prompt, you can use this: | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo \(${ref#refs/heads/}\) | |
} | |
function proml { | |
local BLUE="\[\033[0;34m\]" | |
local LIGHT_BLUE="\[\033[1;34m\]" | |
local RED="\[\033[31m\]" | |
local LIGHT_RED="\[\033[1;31m\]" | |
local GREEN="\[\033[32m\]" | |
local LIGHT_GREEN="\[\033[1;32m\]" | |
local YELLOW="\[\033[1;33m\]" | |
local WHITE="\[\033[1;37m\]" | |
local LIGHT_GRAY="\[\033[37m\]" | |
local CYAN="\[\033[36m\]" | |
local LIGHT_CYAN="\[\033[1;36m\]" | |
local NO_COLOUR="\[\033[0m\]" | |
local PURPLE="\[\033[0;35m\]" | |
local PINK="\[\033[1;35m\]" | |
PS1="${TITLEBAR}$BLUE[$RED\u@\h $CYAN\$(~/.rvm/bin/rvm-prompt) $GREEN\$(parse_git_branch)$BLUE] $YELLOW\w$RED \$$WHITE " | |
PS2='> ' | |
PS4='+ ' | |
} | |
proml | |
# which will used a history file based on the terminal name. | |
# export HISTFILE=$HOME/.bash_history.$(tty|sed 's|/dev/tty||') | |
export HISTFILE=$HOME/.bash_history | |
# make a long History | |
export HISTSIZE=100000 | |
export HISTCONTROL=ignoreboth | |
export HISTTIMEFORMAT='%F %T ' | |
shopt -s histappend | |
export SVN_EDITOR="vim" | |
export EDITOR="vim" | |
# make bash autocomplete with up arrow/down arrow | |
bind '"\e[A":history-search-backward' | |
bind '"\e[B":history-search-forward' | |
# Try to keep environment pollution down, EPA loves us. | |
unset use_color safe_term match_lhs | |
# for memcached and rails: | |
export EVENT_NOKQUEUE=1 | |
export RAKE_COLUMNS=100 | |
# set some options | |
shopt -s checkwinsize | |
shopt -s histappend | |
shopt -s extglob | |
shopt -s cdspell | |
shopt -s hostcomplete | |
shopt -s no_empty_cmd_completion | |
shopt -s cmdhist | |
# fuck that you have new mail shit | |
unset MAILCHECK | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment