Last active
December 15, 2015 05:19
-
-
Save eighteyes/5208517 to your computer and use it in GitHub Desktop.
Bash scripts to leverage the power of git to open working files. Grep supports line numbers!
This file contains 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
# Open log files x number of times back : glo 1 | |
function __glo(){ | |
subl `git log --name-only -n $1 --format=format: | xargs`; | |
} | |
alias glo='__glo' | |
# Open and grep log files x number of times back : glgo 1 query | |
function __glgo(){ | |
subl `git log --name-only -n $1 --grep '$2' --format=format: | xargs`; | |
} | |
alias glgo='__glgo' | |
# Open staged files | |
function __gso(){ | |
subl `git status -s | cut -c 4- | xargs`; | |
} | |
alias gso='__gso' | |
# Open staged grepped files | |
function __gsgo(){ | |
subl `git diff -G '$1' --name-only`; | |
} | |
alias gsgo='__gsgo' | |
# Open grepped files to line : ggo foo | |
function __ggo(){ | |
subl `git grep -n $1 | cut -f 1,2 -d :` | |
} | |
alias ggo='_ggo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment