Created
June 22, 2014 10:24
-
-
Save kalineh/5de19a4098503ef23961 to your computer and use it in GitHub Desktop.
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
# Mostly generated from this: | |
# http://randomartifacts.blogspot.com.au/2012/10/a-proper-cygwin-environment.html | |
# Return immediately if we are not interactive | |
[ -z "$PS1" ] && return | |
# get current git branch name | |
function git_branch { | |
export gitbranch=[$(git rev-parse --abbrev-ref HEAD 2>/dev/null)] | |
if [ "$?" -ne 0 ] | |
then gitbranch= | |
fi | |
if [[ "${gitbranch}" == "[]" ]] | |
then gitbranch= | |
fi | |
} | |
# set usercolor based on whether we are running with Admin privs | |
function user_color { | |
id | grep "Admin" > /dev/null | |
RETVAL=$? | |
if [[ $RETVAL == 0 ]]; then | |
usercolor="[0;35m"; | |
else | |
usercolor="[0;32m"; | |
fi | |
} | |
# set TTYNAME | |
function ttyname() { export TTYNAME=$@; } | |
# Set prompt and window title | |
inputcolor='[0;37m' | |
cwdcolor='[0;34m' | |
gitcolor='[1;31m' | |
user_color | |
# Setup for window title | |
export TTYNAME=$$ | |
function settitle() { | |
p=$(pwd); | |
let l=${#p}-25 | |
if [ "$l" -gt "0" ]; then | |
p=..${p:${l}} | |
fi | |
t="$TTYNAME $p" | |
echo -ne "\e]2;$t\a\e]1;$t\a"; | |
} | |
PROMPT_COMMAND='settitle; git_branch; history -a;' | |
export PS1='\[\e${usercolor}\][\u]\[\e${gitcolor}\]${gitbranch}\[\e${cwdcolor}\][$PWD]\[\e${inputcolor}\] $ ' | |
# Bash history settings | |
export HISTFILESIZE=1000000 | |
export HISTSIZE=100000 | |
export HISTCONTROL=ignorespace | |
export HISTIGNORE='ls:history:ll' | |
export HISTTIMEFORMAT='%F %T ' | |
# Append to bash_history instead of overwriting | |
shopt -s histappend | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment