Resolve tmux and realpath aliases
Falsely concluded that these aliases wouldn't work in sub-shells. After a second look, resolved the issues. This is preferable!
This commit is contained in:
		
							parent
							
								
									f84a9c6438
								
							
						
					
					
						commit
						71b20680a9
					
				
					 1 changed files with 12 additions and 13 deletions
				
			
		| 
						 | 
					@ -3,36 +3,35 @@
 | 
				
			||||||
# To set this up, open iTerm2 -> Preferences -> Profiles -> Advanced
 | 
					# To set this up, open iTerm2 -> Preferences -> Profiles -> Advanced
 | 
				
			||||||
# In the "Semantic History" section, choose "Always run command..." from the
 | 
					# In the "Semantic History" section, choose "Always run command..." from the
 | 
				
			||||||
# dropdown and set the input text to:
 | 
					# dropdown and set the input text to:
 | 
				
			||||||
# `~/dotfiles/emacs.d/open-from-iterm.sh \1 \2`
 | 
					# `~/dotfiles/emacs.d/open-from-iterm.sh \1`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# NOTE: need to get $PATH set in here
 | 
					# Alias applications since $PATH is unavailable
 | 
				
			||||||
# NOTE: these don't get forwarded into subshells
 | 
					 | 
				
			||||||
# # Alias applications since $PATH is unavailable
 | 
					 | 
				
			||||||
emacs=/usr/local/bin/emacsclient
 | 
					emacs=/usr/local/bin/emacsclient
 | 
				
			||||||
grep=/usr/local/bin/ggrep
 | 
					grep=/usr/local/bin/ggrep
 | 
				
			||||||
# tmux=/usr/local/bin/tmux
 | 
					tmux=/usr/local/bin/tmux
 | 
				
			||||||
# realpath=/Users/wpcarro/.nix-profile/bin/realpath
 | 
					realpath=/Users/wpcarro/.nix-profile/bin/realpath
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
e() {
 | 
					e() {
 | 
				
			||||||
  # Useful debugger when paired with `tail -f /tmp/debug.log`
 | 
					  # Useful debugger when paired with `tail -f /tmp/debug.log`
 | 
				
			||||||
  echo "$@" >>/tmp/debug.log
 | 
					  echo "$@" >>/tmp/debug.log
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Need to use tmux here since \5 doesn't work as expected with Tmux.
 | 
					# Need to query Tmux since iTerm's \5 variable doesn't work as expected with
 | 
				
			||||||
pwd=$(/usr/local/bin/tmux display -pF '#{pane_current_path}')
 | 
					# Tmux.
 | 
				
			||||||
 | 
					pwd=$($tmux display -pF '#{pane_current_path}')
 | 
				
			||||||
cd "$pwd" || exit
 | 
					cd "$pwd" || exit
 | 
				
			||||||
path=$(/Users/wpcarro/.nix-profile/bin/realpath "$1")
 | 
					path=$($realpath "$1")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# This is a bit of a hack, but we cannot rely on iTerm to regex our paths
 | 
					# This is a bit of a hack, but we cannot rely on iTerm to regex our paths
 | 
				
			||||||
file=$($grep -P -o '^[^:]+' <<<"$path")
 | 
					file=$($grep -P -o '^[^:]+' <<<"$path")
 | 
				
			||||||
number=$($grep -P -o '(?<=:)[0-9]+(?=:[0-9]+:$)' <<<"$path")
 | 
					number=$($grep -P -o '(?<=:)[0-9]+(?=:[0-9]+:$)' <<<"$path")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Debugging
 | 
				
			||||||
e "file:   $file"
 | 
					e "file:   $file"
 | 
				
			||||||
e "number: $number"
 | 
					e "number: $number"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$emacs -n -e "(find-file \"$file\")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if ! [ -z "$number" ]; then
 | 
					if ! [ -z "$number" ]; then
 | 
				
			||||||
  $emacs -n -e "(goto-line $number)"
 | 
					  $emacs -n -e "(find-file \"$file\")" "(goto-line $number)"
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
					  $emacs -n -e "(find-file \"$file\")"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue