Created
April 22, 2014 07:40
-
-
Save wesolowski/11168876 to your computer and use it in GitHub Desktop.
My bashrc file
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
| # Configure colors, if available. | |
| if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
| c_reset='\[\e[0m\]' | |
| c_user='\[\e[1;33m\]' | |
| c_path='\[\e[0;33m\]' | |
| c_git_cleancleann='\[\e[0;36m\]' | |
| c_git_dirty='\[\e[0;35m\]' | |
| else | |
| c_reset= | |
| c_user= | |
| c_git_cleancleann_path= | |
| c_git_clean= | |
| c_git_dirty= | |
| fi | |
| # Function to assemble the Git parsingart of our prompt. | |
| git_prompt () | |
| { | |
| if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
| return 0 | |
| fi | |
| git_branch=$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p') | |
| if git diff --quiet 2>/dev/null >&2; then | |
| git_color="$c_git_clean" | |
| else | |
| git_color="$c_git_dirty" | |
| fi | |
| echo "[$git_color$git_branch${c_reset}]" | |
| } | |
| # Thy holy prompt. | |
| PROMPT_COMMAND='PS1="${c_user}\u${c_reset}@${c_user}\h${c_reset}:${c_path}\w${c_reset} $(git_prompt)\$ "' | |
| alias gs='git status' | |
| # alias gl='git pull' | |
| alias gd='git diff | mate' | |
| alias ga='git add' | |
| alias gf='git fetch' | |
| alias gfp='git fetch -vp' | |
| alias gc='git commit' | |
| alias gca='git commit -v -a' | |
| alias gb='git branch' | |
| alias gr='git reset' | |
| alias gba='git branch -a' | |
| alias gob='git checkout -b' | |
| alias got='git checkout -t' | |
| alias gotb='git checkout --track -b' | |
| alias glog='git log' | |
| alias c='clear' | |
| # Author.: Ole J | |
| # Date...: 23.03.2008 | |
| # License: Whatever | |
| # Wraps a completion function | |
| # make-completion-wrapper <actual completion function> <name of new func.> | |
| # <command name> <list supplied arguments> | |
| # eg. | |
| # alias agi='apt-get install' | |
| # make-completion-wrapper _apt_get _apt_get_install apt-get install | |
| # defines a function called _apt_get_install (that's $2) that will complete | |
| # the 'agi' alias. (complete -F _apt_get_install agi) | |
| # | |
| function make-completion-wrapper () { | |
| local function_name="$2" | |
| local arg_count=$(($#-3)) | |
| local comp_function_name="$1" | |
| shift 2 | |
| local function=" | |
| function $function_name { | |
| ((COMP_CWORD+=$arg_count)) | |
| COMP_WORDS=( "$@" \${COMP_WORDS[@]:1} ) | |
| "$comp_function_name" | |
| return 0 | |
| }" | |
| eval "$function" | |
| } | |
| # and now the commands that are specific to this SO question | |
| alias go='git checkout' | |
| # we create a _git_checkout_mine function that will do the completion for "go" | |
| # using the completion function "_git" | |
| make-completion-wrapper _git _git_checkout_mine git checkout | |
| # we tell bash to actually use _git_checkout_mine to complete "go" | |
| complete -o bashdefault -o default -o nospace -F _git_checkout_mine go | |
| alias gp='git push' | |
| # we create a _git_checkout_mine function that will do the completion for "go" | |
| # using the completion function "_git" | |
| make-completion-wrapper _git _git_push_mine git push | |
| # we tell bash to actually use _git_checkout_mine to complete "go" | |
| complete -o bashdefault -o default -o nospace -F _git_push_mine gp | |
| alias gl='git pull' | |
| # we create a _git_checkout_mine function that will do the completion for "go" | |
| # using the completion function "_git" | |
| make-completion-wrapper _git _git_pull_mine git pull | |
| # we tell bash to actually use _git_checkout_mine to complete "go" | |
| complete -o bashdefault -o default -o nospace -F _git_pull_mine gl | |
| alias gm='git merge' | |
| # we create a _git_checkout_mine function that will do the completion for "go" | |
| # using the completion function "_git" | |
| make-completion-wrapper _git _git_checkout_mine git merge | |
| # we tell bash to actually use _git_checkout_mine to complete "go" | |
| complete -o bashdefault -o default -o nospace -F _git_checkout_mine gm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment