This short bash snippet allows you to copy and paste any grep or compiler output of the form some/file.java:12:34
to emacsclient
to jump to the specified file, line and column in Emacs:
function emacsClient() { local IFS=":" set $1 if [ $# -eq 3 ] then emacsclient -n +"$2:$3" "$1" elif [ $# -eq 2 ] then emacsclient -n +"$2:1" "$1" else emacsclient -n "$1" fi } alias ec=emacsClient
Example call:
$ grep -nH custom init.el init.el:93: (setq custom-file (expand-file-name "custom.el" (or (file-name-directory user-init-file) default-directory))) init.el:94: (load custom-file) init.el:95: (global-set-key (kbd "") '(lambda () (interactive) (load custom-file))) $ ec init.el:95: $
Update: I forgot to make the IFS variable local to the function. This would break things like git-bash-prompt, if the IFS is suddenly set to something else.