Skip to content

Instantly share code, notes, and snippets.

@masawada
Last active October 9, 2020 08:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masawada/6725094b8312c923bdaf49b9cf259141 to your computer and use it in GitHub Desktop.
Save masawada/6725094b8312c923bdaf49b9cf259141 to your computer and use it in GitHub Desktop.
save as /usr/local/bin/git-af
#!/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