Created
June 2, 2014 20:26
-
-
Save dontjee/bcf6ff591f952a9fef3f to your computer and use it in GitHub Desktop.
My current .bashrc
This file contains 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
alias clear=cls | |
alias ll='ls -l --color' | |
alias ls='ls -G --color' | |
alias la='ls -a -G --color' | |
alias l='ls -al -G --color' | |
alias lt='ls -alrt -G --color' | |
alias c='clear' | |
alias open='cygstart' | |
alias cdg='cd ~/projectsgit' | |
export LS_COLORS='no=00:fi=00:di=00;36:ln=00;35:ex=00;92' | |
export TERM=xterm-256color | |
function start_visualstudio | |
{ | |
if [[ $1 != "" ]]; then | |
cygstart $1 | |
echo "starting visual studio with "$1 | |
return | |
fi | |
cygstart *.sln > /dev/null 2>&1 | |
if [[ $? != 0 ]]; then | |
cygstart src/*.sln > /dev/null 2>&1 | |
fi | |
if [[ $? != 0 ]]; then | |
echo "No project file found" | |
return | |
fi | |
} | |
alias vs=start_visualstudio | |
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_BLUE="\[\033[0;36m\]" | |
MAGENTA="\[\033[0;35m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" | |
function parse_git_branch { | |
git rev-parse --git-dir &> /dev/null | |
behind=$(git log --oneline HEAD..origin 2> /dev/null | wc -l) | |
ahead=$(git log --oneline origin..HEAD 2> /dev/null | wc -l) | |
git_status="$(git status 2> /dev/null)" | |
branch_pattern="^# On branch ([^${IFS}]*)" | |
remote_pattern="# Your branch is (.*) of" | |
diverge_pattern="# Your branch and (.*) have diverged" | |
if [[ ! ${git_status}} =~ "working directory clean" ]]; then | |
if [[ ${git_status}} =~ "Changes not staged for commit" ]]; then | |
state="${RED}\xE2\x99\xA6" | |
elif [[ ${git_status}} =~ "Changes to be committed" ]]; then | |
state="${YELLOW}\xE2\x99\xA6" | |
fi | |
else | |
state="${GREEN}\xE2\x99\xA6" | |
fi | |
# add an else if or two here if you want to get more specific | |
if [[ ${git_status} =~ ${remote_pattern} ]]; then | |
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then | |
remote="${YELLOW}^" | |
else | |
remote="${YELLOW}v" | |
fi | |
fi | |
if [[ ${git_status} =~ ${diverge_pattern} ]]; then | |
remote="${YELLOW}^v" | |
fi | |
if [[ ${git_status} =~ ${branch_pattern} ]]; then | |
branch=${BASH_REMATCH[1]} | |
ahead_color=${LIGHT_GRAY} | |
behind_color=${LIGHT_GRAY} | |
if [[ ${ahead} > 0 ]]; then | |
ahead_color=${MAGENTA} | |
fi | |
if [[ ${behind} > 0 ]]; then | |
behind_color=${RED} | |
fi | |
echo -e " (${branch} ${behind_color}${behind}${LIGHT_GRAY}|${ahead_color}${ahead}${GREEN})${remote}${state}" | |
fi | |
} | |
function prompt_func() { | |
previous_return_value=$?; | |
# prompt="${TITLEBAR}$BLUE[$RED\w$GREEN$(__git_ps1)$YELLOW$(git_dirty_flag)$BLUE]$COLOR_NONE " | |
prompt="${TITLEBAR}${LIGHT_GRAY}[${YELLOW}\w${GREEN}$(parse_git_branch)${LIGHT_GRAY}]${COLOR_NONE} " | |
if test $previous_return_value -eq 0 | |
then | |
PS1="${prompt}: " | |
fi | |
} | |
PROMPT_COMMAND=prompt_func |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment