I wanted to have a git openlast
command which would look at the last commit, get a list of added or changed files, filter them to only the text files, and finally open them in an editor.
So far I've done the following:
git show --stat HEAD
read -p "Open in Vim tabs? (Y/n)" -n 1 -r
if [[ -z $REPLY || $REPLY =~ [Yy] ]]; then
vim -p $(git diff --diff-filter=AM --ignore-submodules --name-only HEAD^)
fi
The down fall is if I add or change a binary file in the previous commit then it will be opened by the editor (Vim in this case). Is there a way to take the list outputted by the git diff
command and remove binary files?