Last active
July 14, 2016 03:39
-
-
Save xeron/ff7c135e66381b6686860a7089e5b843 to your computer and use it in GitHub Desktop.
bashrc for git
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
| # ~/.bashrc: executed by bash(1) for non-login shells. | |
| ## Exports | |
| # Common | |
| HISTFILESIZE=1000000000 | |
| HISTSIZE=10000000 | |
| # HISTCONTROL=ignoreboth:erasedups | |
| HISTCONTROL=ignorespace:erasedups | |
| ## Colors | |
| export CLICOLOR=1 | |
| export GREP_OPTIONS='--color=auto' | |
| export LSCOLORS=gxfxcxdxbxegedabagacad | |
| # export LSCOLORS=exfxcxdxbxegedabagacad # Default | |
| # export LSCOLORS=GxFxCxDxBxegedabagaced # From Google | |
| # export LSCOLORS=ExGxBxDxCxEgEdxbxgxcxd # From http://www.norbauer.com/rails-consulting/notes/ls-colors-and-terminal-app.html | |
| # export LSCOLORS=exfxcxdxbxexexabagacad # From http://softwaregravy.wordpress.com/2010/10/16/ls-colors-for-mac/ | |
| ## GIT | |
| COLOR_YELLOW="\[\e[33;10m\]" | |
| COLOR_RED="\[\e[31;10m\]" | |
| COLOR_GREEN="\[\e[32;10m\]" | |
| COLOR_BLUE="\[\e[34;10m\]" | |
| COLOR_CYAN="\[\e[36;10m\]" | |
| COLOR_NONE="\[\e[0m\]" | |
| COLOR_NONEP="\[\e[38;0m\]" | |
| # Repo status | |
| function parse_git_dirty { | |
| [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working tree clean" ]] && echo "*" | |
| } | |
| # Branch | |
| function parse_git_branch { | |
| git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
| } | |
| # Python env | |
| function parse_py_env { | |
| if [ -n "$VIRTUAL_ENV" ]; then | |
| py_env=`echo $VIRTUAL_ENV | sed -e "s/.*\///"` | |
| echo "($py_env)" | |
| fi | |
| } | |
| # Screen | |
| function parse_screen { | |
| if [ "$TERM" == "screen" ]; then | |
| echo "($STY)" | |
| fi | |
| } | |
| prompt_func() { | |
| # If last command fail | |
| if test $? -eq 0 | |
| then | |
| PS1="${COLOR_GREEN}" | |
| else | |
| PS1="${COLOR_RED}" | |
| fi | |
| PS1="$(parse_py_env)$PS1" | |
| prompt="${COLOR_CYAN}\w${COLOR_GREEN}$(parse_git_branch)${COLOR_NONEP}" | |
| PS1="$PS1\u@\h:${prompt}${COLOR_NONE}\$ " | |
| } | |
| # Tell the terminal about the working directory at each prompt. | |
| if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then | |
| PROMPT_COMMAND="prompt_func; printf '\033k\033\134'; update_terminal_cwd" | |
| else | |
| PROMPT_COMMAND="prompt_func; printf '\033k\033\134'" | |
| fi |
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
| # ~/.profile: executed by the command interpreter for login shells. | |
| # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login | |
| # exists. | |
| # if running bash | |
| if [ -n "$BASH_VERSION" ] ; then | |
| # include .bashrc if it exists | |
| if [ -f "$HOME/.bashrc" ] ; then | |
| . "$HOME/.bashrc" | |
| fi | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment