diff options
author | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·51-0400 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2018-09-10T18·53-0400 |
commit | 17ee0e400bef47c371afcae76037f9ea6a44ad13 (patch) | |
tree | 0e5efee6f00e402890e91f3eceb4b29408a498b6 /configs/shared/emacs/.emacs.d/open-from-iterm.sh | |
parent | 8b2fadf4776b7ddb4a67b4bc8ff6463770e56028 (diff) |
Support Vim, Tmux, Emacs with Stow
After moving off of Meta, Dotfiles has a greater responsibility to manage configs. Vim, Tmux, and Emacs are now within Stow's purview.
Diffstat (limited to 'configs/shared/emacs/.emacs.d/open-from-iterm.sh')
-rwxr-xr-x | configs/shared/emacs/.emacs.d/open-from-iterm.sh | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/configs/shared/emacs/.emacs.d/open-from-iterm.sh b/configs/shared/emacs/.emacs.d/open-from-iterm.sh new file mode 100755 index 000000000000..fdb4257965cb --- /dev/null +++ b/configs/shared/emacs/.emacs.d/open-from-iterm.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# To set this up, open iTerm2 -> Preferences -> Profiles -> Advanced +# In the "Semantic History" section, choose "Always run command..." from the +# dropdown and set the input text to: +# `~/dotfiles/emacs.d/open-from-iterm.sh \1` + +# Alias applications since $PATH is unavailable +emacs=/usr/local/bin/emacsclient +grep=/usr/local/bin/ggrep +tmux=/usr/local/bin/tmux +realpath=/Users/wpcarro/.nix-profile/bin/realpath + +e() { + # Useful debugger when paired with `tail -f /tmp/debug.log` + echo "$@" >>/tmp/debug.log +} + +# Need to query Tmux since iTerm's \5 variable doesn't work as expected with +# Tmux. +pwd=$($tmux display -pF '#{pane_current_path}') +cd "$pwd" || exit +path=$($realpath "$1") + +# This is a bit of a hack, but we cannot rely on iTerm to regex our paths +file=$($grep -P -o '^[^:]+' <<<"$path") +number=$($grep -P -o '(?<=:)[0-9]+(?=:[0-9]+:$)' <<<"$path") + +# Debugging +e "file: $file" +e "number: $number" + +if ! [ -z "$number" ]; then + $emacs -n -e "(find-file \"$file\")" "(goto-line $number)" "(call-interactively #'evil-scroll-line-to-center)" +else + $emacs -n -e "(find-file \"$file\")" +fi |