Created
April 21, 2017 07:59
-
-
Save Shashwat986/b0f86033f0d098fef539e77646553a62 to your computer and use it in GitHub Desktop.
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
| source ~/git-completion.bash | |
| # useful git commands | |
| # list branches | |
| alias gl="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'" | |
| alias gb="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - (%(color:green)%(committerdate:relative)%(color:reset))'" | |
| # go to git home directory | |
| alias h="cd `git rev-parse --show-toplevel`" | |
| # list all branches and their comparision with master. | |
| # note: this uses git checkout, so there should be no uncommited changes in the current branch | |
| function gas(){ | |
| count=${1:-10} | |
| curr_branch=`git rev-parse --abbrev-ref HEAD` | |
| for bn in `git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short)' | tail -n $count`; do | |
| git checkout -q $bn | |
| git rev-list --left-right --count head...origin/master | awk -v bn="$bn" ' | |
| function yellow(s) { | |
| printf "\033[1;33m" s "\033[0m " | |
| } | |
| function blue(s) { | |
| printf "\033[34m" s "\033[0m " | |
| } | |
| { | |
| if ($1 != 0) { | |
| print yellow(bn), ":", blue("Ahead"), blue($1), blue("Behind"), blue($2) | |
| } else { | |
| print bn, ":", "Ahead", $1, "Behind", $2 | |
| } | |
| }'; | |
| done | |
| git checkout -q $curr_branch | |
| } | |
| # gets branch status with respect to master and release | |
| function gs(){ | |
| echo "With regards origin/master" | |
| echo -e "Ahead\tBehind" | |
| git rev-list --left-right --count head...origin/master | |
| if [[ $(gb|grep release) ]]; then | |
| echo | |
| echo "With regards origin/release" | |
| echo -e "Ahead\tBehind" | |
| git rev-list --left-right --count head...origin/release | |
| fi | |
| } | |
| # git fetch before getting status | |
| function gsu(){ | |
| git fetch -q | |
| gs | |
| } | |
| export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
| export NODE_PATH=/usr/local/lib/node_modules | |
| source /usr/local/etc/bash_completion.d/git-prompt.sh | |
| GIT_PS1_SHOWDIRTYSTATE=true | |
| export PS1='[\[\e[0;31m\]\u\[\e[0m\]@mbp \[\e[0;32m\]\w\[\e[1;33m\]$(__git_ps1)\[\e[0m\]]\$ ' | |
| #export PS1='[\u@mbp \w$(__git_ps1)]\$ ' | |
| export CLICOLOR=1 | |
| export LSCOLORS=GxFxCxDxBxegedabagaced | |
| alias ls='ls -GFh' | |
| export FZF_DEFAULT_OPTS="--no-mouse" | |
| [ -f ~/.fzf.bash ] && source ~/.fzf.bash | |
| # avoid duplicates | |
| export HISTCONTROL=ignoredups:erasedups | |
| # append history entries | |
| export HISTSIZE=500000 | |
| export HISTFILESIZE=500000 | |
| shopt -s histappend | |
| # After each command, save and reload history | |
| export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" | |
| # Aliases | |
| alias less='less -R' | |
| # making grep easier | |
| function gc() { grep -rnI "$@" * ;} | |
| function gcA() { grep -rnI -A 5 "$@" * ;} | |
| function gcB() { grep -rnI -B 5 "$@" * ;} | |
| function gcC() { grep -rnI -C 5 "$@" * ;} | |
| function gcf() { grep -rnIl "$@" * ;} | |
| # Adding function to check internet status at all points in time | |
| # Run `$ pingt 1&>/dev/null &` to keep this script running in the background | |
| function pingt() { | |
| while true | |
| do | |
| ping -q -c 5 -W 2 8.8.8.8 | |
| if [ $? -eq 0 ]; then | |
| echo "All Good" | |
| sleep 5 | |
| else | |
| echo "Not Connected..." | |
| say -v Karen "Not connected to the internet" | |
| ping -q -a -o 8.8.8.8 && say -v Karen "Connection Established" | |
| fi | |
| done | |
| } | |
| export python=3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment