Created
October 21, 2015 10:24
-
-
Save adfinlay/830e237016eb973b598f to your computer and use it in GitHub Desktop.
Have vim inspect command history
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
vim () { | |
last_command=$(history | tail -n 2 | head -n 1) | |
if [[ $last_command =~ 'git grep' ]] && [[ "$*" =~ :[0-9]+:$ ]]; then | |
line_number=$(echo $* | awk -F: '{print $(NF-1)}') | |
/usr/bin/vim +${line_number} ${*%:${line_number}:} | |
else | |
/usr/bin/vim $* | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment