Skip to content

Instantly share code, notes, and snippets.

@juhasz
Last active August 29, 2015 14:06
Show Gist options
  • Save juhasz/b9c655c72f236ca6b562 to your computer and use it in GitHub Desktop.
Save juhasz/b9c655c72f236ca6b562 to your computer and use it in GitHub Desktop.
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
## git autocomplete and promt
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
## Add some directories to PATH
function setpath() {
export PATH=/usr/local/git/bin:~/.bin:$PATH
}
setpath
### Prompt Colors
# Modified version of @gf3’s Sexy Bash Prompt
# (https://github.com/gf3/dotfiles)
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
RED=$(tput sgr0 && tput setaf 1)
GREEN=$(tput sgr0 && tput setaf 2)
YELLOW=$(tput sgr0 && tput setaf 3)
BLUE=$(tput sgr0 && tput setaf 4)
MAGENTA=$(tput sgr0 && tput setaf 5)
CYAN=$(tput sgr0 && tput setaf 6)
GRAY=$(tput sgr0 && tput setaf 7)
WHITE=$(tput sgr0 && tput setaf 7 && tput bold)
LIGHTRED=$(tput sgr0 && tput setaf 1 && tput bold)
LIGHTGREEN=$(tput sgr0 && tput setaf 2 && tput bold)
LIGHTYELLOW=$(tput sgr0 && tput setaf 3 && tput bold)
LIGHTBLUE=$(tput sgr0 && tput setaf 4 && tput bold)
LIGHTMAGENTA=$(tput sgr0 && tput setaf 5 && tput bold)
LIGHTCYAN=$(tput sgr0 && tput setaf 6 && tput bold)
BLACK=$(tput setaf 190)
ORANGE=$(tput setaf 172)
PURPLE=$(tput setaf 141)
BOLD=$(tput bold)
RESET=$(tput sgr0)
export RED
export GREEN
export YELLOW
export BLUE
export MAGENTA
export CYAN
export GRAY
export WHITE
export LIGHTRED
export LIGHTGREEN
export LIGHTYELLOW
export LIGHTBLUE
export LIGHTMAGENTA
export LIGHTCYAN
export BLACK
export ORANGE
export PURPLE
export BOLD
export RESET
# Git branch details
function parse_git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "${RED}*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
function parse_git_commits_ahead() {
# How many local commits do you have ahead of origin?
num=$(git status 2> /dev/null | grep "Your branch is ahead of" | sed -E "s/Your branch is ahead of .* by ([0-9]+) commits?.*/\1/");
if [ -n "$num" ]; then
echo $(tput setaf 7)'+'$num$WHITE;
fi
}
# Change this symbol to something sweet.
# (http://en.wikipedia.org/wiki/Unicode_symbols)
symbol=""
export PS1="\[${WHITE}\]\$(date "+%H%M")\[$LIGHTGREEN\] and \[${BOLD}${WHITE}\]\u \[$LIGHTGREEN\]is in \[$LIGHTBLUE\]\w\[$LIGHTGREEN\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$YELLOW\]\$(parse_git_branch)\[$WHITE\]\$(parse_git_commits_ahead)\n$symbol\[$RESET\]"
export PS2="\[$ORANGE\]→ \[$RESET\]"
## ignore duplicate lines in bash history
export HISTCONTROL=ignoreboth
## rebind stop signal, to get Ctrl-S work on command pattern search.
stty stop ^X
## aliases
# ls
alias ls='ls -FhG'
alias ll='ls -la'
# log
alias wl='jrnl wlog'
# navigation
alias 'cd..'='cd ..'
alias d='cd ~/Downloads'
alias ':q'=exit
# grep
alias grep='grep --color=auto'
# vim (mvim)
alias vim='mvim -v'
alias vi='mvim --remote-tab-silent'
alias v='mvim -R --remote-tab-silent'
# boot2docker
alias b2dup='boot2docker up && $(boot2docker shellinit)'
# other
alias g='wget'
alias gg='wget --no-check-certificate'
alias o='open'
export EDITOR=vim
## Set up docker ENV
if boot2docker status | grep running > /dev/null; then
$(boot2docker shellinit)
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment