Advertisement
mattiskan

grep to emacs

Nov 26th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.31 KB | None | 0 0
  1. function grepmacs {
  2.     echo "grepmacs: grep -rn $@"
  3.     matches="$(grep -nr $@)"
  4.  
  5.     if [[ -z $matches ]]; then
  6.         echo "No matches found";
  7.         return
  8.     fi
  9.  
  10.     # open every match in its own buffer and skip to correct line:
  11.     emacs -nw $(echo $matches | sed -r 's/([^:]*):([0-9]*):.*/+\2 \1/g')
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement