Created
September 21, 2011 19:51
-
-
Save usergenic/1233105 to your computer and use it in GitHub Desktop.
iterm2 users, want cmd-click to open file in emacs?
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
#!/bin/bash | |
# This file is for iTerm2 users. | |
# | |
# Put this file in /usr/local/bin/iterm-cmd-click-emacsclient | |
# | |
# You'll need to do the following at command line... | |
# $ defaults write com.googlecode.iterm2 SemanticHistoryHandler /usr/local/bin/iterm-cmd-click-emacsclient | |
emacsclient -e "(find-file \"$1\")" "(goto-line $2)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@wpcarro I should update my notification settings for gist comments!
Create a script in
~/bin/iterm-emacsclient
:Make it executable:
chmod +x ~/bin/iterm-emacsclient
In iTerm2 Session preferences Advanced pane setup Semantic History as:
Enter:
What does it do?
emacsclient
accepts row number if prefixed with+
e.g.This'll open
filename
and move to line 20.-n
stopsemacsclient
waiting for the buffer to close.So when you click
filename
in iTerm, it'll callemacsclient -n filename
If the user clicks on
filename:123
, it'll callemacsclient -n +123 filename
.Note in the run command above, we call it with
+\2
and\1
.\2
is the row number, and\1
is the filename. When no row number is sent, the script has$1
as+
so weshift
it off, and$2
becomes$1
, so we don't sendemacsclient
a stray+
which will throw an error.That's detailed enough of a rundown, hopefully.