Created
September 24, 2013 10:47
-
-
Save matiasherranz/6683083 to your computer and use it in GitHub Desktop.
GIT prompt setup file (and some more Bash tune-ups)
Place this file under the home directory. Name it ".bashrc" in Linux or ".profile" in Mac OS.
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
# Python projects: | |
alias limpiarpycs='find . -iname "*.pyc" -delete' | |
# Para que SVN no muera por los acentos: | |
export LC_CTYPE=UTF-8 | |
# General stuff: | |
alias ls="ls -G" | |
export EDITOR=nano | |
export GIT_EDITOR=nano | |
# Para que bash tenga mucha memoria: | |
export HISTCONTROL=erasedups | |
export HISTSIZE=5000 | |
export HISTFILESIZE=5000 | |
shopt -s histappend | |
# Git and Django completions: | |
source ~/.django_bash_completion | |
source ~/.git_completion.sh | |
# Do the Harlem shake! | |
function parse_git_dirty { | |
status=`git status 2> /dev/null` | |
dirty=` echo -n "${status}" 2> /dev/null | grep -q "Changed but not updated" 2> /dev/null; echo "$?"` | |
untracked=`echo -n "${status}" 2> /dev/null | grep -q "Untracked files" 2> /dev/null; echo "$?"` | |
ahead=` echo -n "${status}" 2> /dev/null | grep -q "Your branch is ahead of" 2> /dev/null; echo "$?"` | |
newfile=` echo -n "${status}" 2> /dev/null | grep -q "new file:" 2> /dev/null; echo "$?"` | |
renamed=` echo -n "${status}" 2> /dev/null | grep -q "renamed:" 2> /dev/null; echo "$?"` | |
modified=`echo -n "${status}" 2> /dev/null | grep -q "modified:" 2> /dev/null; echo "$?"` | |
deleted=`echo -n "${status}" 2> /dev/null | grep -q "deleted:" 2> /dev/null; echo "$?"` | |
bits='' | |
if [ "${dirty}" == "0" ]; then | |
bits="${bits} asdf" | |
fi | |
if [ "${untracked}" == "0" ]; then | |
bits="${bits} ?" | |
fi | |
if [ "${newfile}" == "0" ]; then | |
bits="${bits} *" | |
fi | |
if [ "${ahead}" == "0" ]; then | |
bits="${bits} +" | |
fi | |
if [ "${renamed}" == "0" ]; then | |
bits="${bits} >" | |
fi | |
if [ "${modified}" == "0" ]; then | |
bits="${bits} m" | |
fi | |
if [ "${deleted}" == "0" ]; then | |
bits="${bits} d" | |
fi | |
echo "${bits}" | |
} | |
function parse_git_revision { | |
ref1=$(__git_ps1 | sed -e "s/ (\(.*\))/(git: \1$(parse_git_dirty))/") | |
if [ "x$ref1" != "x" ]; then | |
echo " ${ref1} " | |
fi | |
} | |
# Colors! | |
Black=$(tput setaf 0) | |
BlackBG=$(tput setab 0) | |
DarkGrey=$(tput bold ; tput setaf 0) | |
LightGrey=$(tput setaf 7) | |
White=$(tput bold ; tput setaf 7) | |
RedBG=$(tput setab 1) | |
LightRed=$(tput bold ; tput setaf 1) | |
GreenBG=$(tput setab 2) | |
LightGreen=$(tput bold ; tput setaf 2) | |
Brown=$(tput setaf 3) | |
BrownBG=$(tput setab 3) | |
Yellow=$(tput bold ; tput setaf 3) | |
Blue=$(tput setaf 4) | |
BrightBlue=$(tput bold ; tput setaf 4) | |
Purple=$(tput setaf 5) | |
PurpleBG=$(tput setab 5) | |
Pink=$(tput bold ; tput setaf 5) | |
Cyan=$(tput setaf 6) | |
CyanBG=$(tput setab 6) | |
BrightCyan=$(tput bold ; tput setaf 6) | |
# sin color | |
sc=$(tput sgr0) | |
# And now set up the awesome bash prompt: | |
PS1='\[$LightGreen\][\u@\h]:\[$LightGrey\]\W\[$BrightCyan\]`parse_git_revision`\[$Yellow\]\$ \[$sc\]' | |
#PS1='\h:\W \u\$' | |
## Para que los acentos se vean al hacer cosas como "ls" y que se permitan en paths(que anden bien, bah!) | |
# Locale: | |
set meta-flag on | |
set input-meta on | |
set output-meta on | |
set convert-meta off | |
export LANG="en_US.UTF-8" | |
export LC_COLLATE="en_US.UTF-8" | |
export LC_CTYPE="en_US.UTF-8" | |
export LC_MESSAGES="en_US.UTF-8" | |
export LC_MONETARY="en_US.UTF-8" | |
export LC_NUMERIC="en_US.UTF-8" | |
export LC_TIME="en_US.UTF-8" | |
export LC_ALL= | |
############################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment