Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Update: A bash script to do the same thing (better?)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Update: A bash script to do the same thing (better?)
Authored by: tpavlic on Jul 11, '07 03:17:29PM
This is a better version.
filename="$1"
lineNum="$2"

[ "${filename:0:1}" == "/" ] || filename="${PWD}/$filename"  

exec osascript 
 -e "set CR to ASCII character of 13" 
 -e "set ESC to ASCII character of 27" 
 -e "tell application "Vim" to activate" 
 -e "tell application "System Events"" 
   -e "tell process "Vim"" 
   -e "keystroke ESC & ":set hidden" & CR " 
   -e "keystroke ":if bufexists('$filename')" & CR " 
   -e "keystroke ":exe \":buffer \" . bufnr('$filename')"  & CR " 
   -e "keystroke ":else " & CR " 
   -e "keystroke ":    edit ${filename// /\ }" & CR " 
   -e "keystroke ":endif" & CR " 
   -e "keystroke ":$lineNum" & CR " 
   -e "keystroke "zO" " 
   -e "end tell" 
 -e "end tell"
This will fix problems when you have multiple files open with the same base name.

[ Reply to This | # ]
Update (be sure to add /bin/sh): A bash script to do the same thing (better?)
Authored by: tpavlic on Jul 11, '07 03:18:51PM
Of course, be sure to add the #!/bin/bash at the top of the script.

[ Reply to This | # ]