Skip to content

Instantly share code, notes, and snippets.

@xmcgyver
Created September 1, 2010 09:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xmcgyver/560451 to your computer and use it in GitHub Desktop.
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)
#!/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