Created
September 1, 2010 09:18
-
-
Save xmcgyver/560451 to your computer and use it in GitHub Desktop.
vimp = vi + pimp (allows vi to open a file from a grep search at the specified line number from the search result)
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 | |
# vimp = vi + pimp (allows vi to open a file from a grep search at the specified line number from the search result) | |
# (example usage -> prompt$ vimp /etc/hosts:23) | |
# tested on OS X 10.6 only | |
x="$1" | |
y=`basename $1` | |
# if colon in param | |
if [[ $y == *:* ]] | |
then | |
echo -n -e "\033]0;${y%%:*}\007" | |
vi +${x#*:} "${x%%:*}" | |
else | |
echo -n -e "\033]0;$y\007" | |
vi "${x}" | |
fi | |
# reset terminal title back to "" | |
echo -n -e "\033]0;\007" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment