Created
June 18, 2013 20:59
-
-
Save adbre/5809305 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
alias which='type -a' | |
alias ..='cd ..' | |
alias dev='cd /c/dev/' | |
alias path='echo -e ${PATH//:/\\n}' | |
alias ls='ls -hF --color' # add colors for filetype recognition | |
alias la='ls -Al' # show hidden files | |
alias lx='ls -lXB' # sort by extension | |
alias lk='ls -lSr' # sort by size, biggest last | |
alias lc='ls -ltcr' # sort by and show change time, most recent last | |
alias lu='ls -ltur' # sort by and show access time, most recent last | |
alias lt='ls -ltr' # sort by date, most recent last | |
alias lm='ls -al |more' # pipe through 'more' | |
alias lr='ls -lR' # recursive ls | |
# ls on msys does not support --group-directories-first | |
function ll() { | |
ls -l "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| egrep -v "^d|total "; | |
} | |
function mk() { | |
mkdir -p $@ && cd $@ | |
} | |
function explrr() { | |
# crude manipulation to convert a NIX path to WINDOWS... | |
local path=$(pwd) | |
path=${path//\//\\} | |
path=${path/\\c\\/c:\\} | |
explorer $path | |
return 0 | |
} | |
# include more directories in PATH | |
# try to find 7-Zip as msys does not include zip tools | |
export PATH="${PATH}:/c/Program Files/7-Zip/" | |
export PATH="${PATH}:/c/Program Files (x86)/7-Zip/" | |
export PATH="${PATH}:/c/Program Files/TortoiseGit/bin/" | |
export PATH="${PATH}:/c/Program Files (x86)/Notepad++/" | |
function __mygit_ps1() { | |
local LASTEXITCODE=$? | |
local RED="\033[0;31m" | |
local LIGHTRED="\033[01;31m" | |
local YELLOW="\033[0;33m" | |
local BRIGHTYELLOW="\033[01;33m" | |
local GREEN="\033[0;32m" | |
local LIGHTGREEN="\033[01;32m" | |
local DARKGRAY="\033[01;30m" | |
local BLUE="\033[00;36m" | |
local LIGHTBLUE="\033[01;36m" | |
local NOCOLOR="\033[m" | |
echo -ne "${DARKGRAY}`date +%H:%M:%S` " | |
if [ $LASTEXITCODE = 0 ]; then | |
echo -ne "${GREEN}OK " | |
else | |
echo -ne "${LIGHTRED}ERR " | |
fi | |
local STATUS=`git status 2>&1` | |
if [[ "$STATUS" == *'Not a git repository'* ]]; then | |
echo -ne "$" | |
else | |
if [[ "$STATUS" == *'working directory clean'* ]]; then | |
echo -ne "${LIGHTGREEN}" | |
elif [[ "$STATUS" == *'to be committed'* ]]; then | |
echo -ne "${BRIGHTYELLOW}" | |
elif [[ "$STATUS" == *'not staged for commit'* ]]; then | |
echo -ne "${LIGHTRED}" | |
else | |
echo -ne "${LIGHTBLUE}" | |
fi | |
echo -ne `__git_ps1` | |
echo -ne "${NOCOLOR}" | |
if [[ "$STATUS" == *'ahead'* ]]; then | |
echo -ne "${LIGHTGREEN} ahead" | |
elif [[ "$STATUS" == *'behind'* ]]; then | |
echo -ne "${LIGHTRED} behind" | |
elif [[ "$STATUS" == *'diverged'* ]]; then | |
echo -ne "${BRIGHTYELLOW} diverged" | |
else | |
echo -ne "${LIGHTBLUE} in sync" | |
fi | |
fi | |
# reset any colors | |
echo -e "${BLUE} "`pwd`"${NOCOLOR}" | |
echo -ne "$ " | |
} | |
# epic prompt with git status info | |
export PS1='$(__mygit_ps1)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment