Last active
October 9, 2020 08:38
-
-
Save masawada/6725094b8312c923bdaf49b9cf259141 to your computer and use it in GitHub Desktop.
save as /usr/local/bin/git-af
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
#!/bin/bash | |
BRANCH=$1 | |
FILE_PATH=$2 | |
[ -v $BRANCH ] && BRANCH=$(git branch -l | grep -Ev '^\*' | awk '{ print $1 }' | peco) | |
[ -v $BRANCH ] && echo 'branch not found' && exit; | |
[ -v $FILE_PATH ] && FILE_PATH=$(git ls-files | peco) | |
[ -v $FILE_PATH ] && echo 'file_path not found' && exit; | |
git show $BRANCH:$FILE_PATH | vim -c "doautocmd BufRead $(basename $FILE_PATH)" -R - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment