From c56e91916c06705d73b62e337d8fa8a625633054 Mon Sep 17 00:00:00 2001 From: JamshedVesuna Date: Sat, 5 Mar 2016 12:39:41 -0800 Subject: [PATCH] Added OS X and Google Chrome auto refresh with applescripts --- plugin/applescript/activate-vmp.scpt | Bin 0 -> 3014 bytes plugin/applescript/search-for-vmp.scpt | Bin 0 -> 1720 bytes plugin/vim-markdown-preview.vim | 20 ++++++++++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 plugin/applescript/activate-vmp.scpt create mode 100644 plugin/applescript/search-for-vmp.scpt diff --git a/plugin/applescript/activate-vmp.scpt b/plugin/applescript/activate-vmp.scpt new file mode 100644 index 0000000000000000000000000000000000000000..511402b6a44e9b02d94d46c4019959154c95856f GIT binary patch literal 3014 zcmb_eS#(rY7Txbv#`p4G62vADBBhOjfec^}k_I(~5a

NrECS*D8wYB&L$eszmwq z*Ixb6Kiz-51aVeW6me`+oN&e{gP;*aK@g{QKylc;?|Y^wTmgUjW!;lIoV)Kn=bm$J zEs71U>1=F|&Z?eOYnl%rroH!b1@vS8Io(Gd=zQ-!n`Ni%GZ+#WsqiSb|bdB49BIQ!ox^c@lPi zpjLtLINOs5Se2uK-#h$XteVmtt38|@vYLc)9(Q>h<7$x~3u&oyRlv`~Stq%F=kmKi zYbdrlAfB&I$huTy{(uRdL_j8rKcWm1JqfE%WTH5i-$wW?EDsY;B7WoY8|2o)>VW_z zs7>P6o-7PZpDIJk`Cm--P#&6Ihn1+XQ6a^1FvXL|xkl)9Xb(>KieGx_=r(gTSC8}f z1wZ$29_;2ot6r?8dJ=(y>M$4Q;{s2@nx*wQn9I)`ekKQXE^m!`xF952hdDgv@)!zg zkrR{2CT6CFcFn~+O!F}f)+S6Z#dOTZjp#uis?=ggqgNr6!dmoeWrq=Y|kW7*{$s{1P`ueEFqjE2gm;S{YbaQVTguFVetS0R^u)ssWrX_(Ftmm_0m z0KYaHe>hDN`5}Y{pYOYT|4apdC(JeFg_Pw4)EA@Po?Kvj{Qv#ZJ$=`}wh&V;8)R#% zJZ%*%jm3NVhf;&x(ZvgYbKs6uBgYrdkmkS7|5s^CD%F)tM4P(PslG&YY+&Fw%D*!d z#)jctT}7j6)CUwsN5{YZ&r8OJ5~`6UDz?~hZDW__OHF@x*Y3ZoZ(+P)qxMfMJN!4b zn^AZ~B@pe|hBTxGh8oZ%hU~dDOB-5!>Ujw=VTdLxLEe#0IY`_>M`pW!L zv?!-j=t5HY97U5dIjwP@M%Bvt0sR%Lh!tU}Msd}Her0+JgVKvC2^OkEH;PcrDST>1 z>C~LUrY0m)GX@ux<{B8US^UL_p8;QnqqqbSS7l8+l}^O_hZ4qV z@}9nuz<~~5k)C;HUA}x8XKf#KmLoplo8$1sGt_a1FG$Z+)Kb2U#Qt%JRUW8n9&Vd} ztGBH>_))S5xxL-xz`8?K&AZ!roA+p?{-vxHYyFX#M++)YwtgJ)E3Yqt+u63g@<4CR zv6+ijBGTQqz4x5vJ*(PQa;FhnI*WY;ke$Qlad||-_Hnt1uqG_@C9Lsi_R)--iSqGt z+{R}eK4<)+Ul9>*!)AxiqQLF_Yr1dA!f4c2u~ES zTNaq(|AUr@M6R#Q%Y{;C3G`y1)mK-DOMPXU5SQ^OKFKG1EDP};=VN@-;o}+n#|-|X zS@;g0(xSPi2%og}Iea2((bq9TZ}asI3jGRh;UnDajzJ3}By@U7gZrpszFNw`2i0ye)&i!CvX`)~v+{_aQGf7*DIZ K7o8Xx+4w*Cju{XD literal 0 HcmV?d00001 diff --git a/plugin/applescript/search-for-vmp.scpt b/plugin/applescript/search-for-vmp.scpt new file mode 100644 index 0000000000000000000000000000000000000000..a57ddedd62b9923711a0f8b396d081cebd190a55 GIT binary patch literal 1720 zcmb_cOK)3M5dQA9Q#aQ>cASJHq;YCWUwPP0s=~r4h$sz>NLovjNVH+&xK`}?aUXE0s!|JmrFoPjZRz_Fnm&f_+*^xODq_R2&v<4$cg{E8ojLEP zt0yLhk46XMg9Ca80eC|qFkr%CP=TWEDbfUvz$?$?nSvK)injJNV2h$K3bed944(-f zgSVnlQFuOf+#kS_r|>ISZeSZm5ik*8ph8elm=y-L;dO-2q$rG%W4Fr_k34~)&;-M# zi%T~AvVn#H76<5<{n=Fw2gez&3O#3S*FV3<-H?$wPRp$qy%@3SBO&e#GQ~UmiHHYMQi8 zw}b=+5D6jz<0o{7(T#mLg*-~kR6-gR6mSAI=1`_*mUhIn)?cROo;)!PEES zZERQA?xx<4x8%M@?vn&r2Ml?n>1gAQ$~}ds%jpn{e*-%dg*n9>LwFZ&VyB{T2pz%! zx$Bp^bwU+(y6F$#9l7I?JDU6*|B!#%FSqNlrrZPk_(O zp|HoLW}L0JS7EP`*Sp2 zYi1=!Hy4t$XKP91h;+J=or`7C)j|>@loi`9B{AdF63aNXB;lT!#4Ab+vfaWs#1XJD zgCg5MiV-$`g?5QnoI^6pPly8*;5$wu!|^F|Fl*4zB{T^a zOyU(-T3{rgSu^Ch7SG^ZE(kTj!<+9KdeJ9q1{KoR%Vu4b6-!pp5l?4N)oi}9@~6cj z@ELjh3cXx@S#esK7gZ2_@HNRF=$EUq%wdnql1201A6C4foNHBIvk4Ok-A=M-%Ay8$ zRZq*ZMiQg4AXogdP#+t=Tya#6WD^-|M32nNWw|65<$|1--x0B7{>3O+a+zAe&J-=V zq%F2<&o zmWu&+3%PATVf1XO9lhVJZ1x)8ulBF`BJiCI9fK#A`lZl4dUh&xOjfk`HB|^rhCH%{ QhIBPkVSffT=I4L>8{nvbGynhq literal 0 HcmV?d00001 diff --git a/plugin/vim-markdown-preview.vim b/plugin/vim-markdown-preview.vim index 1581a58..7066d3d 100644 --- a/plugin/vim-markdown-preview.vim +++ b/plugin/vim-markdown-preview.vim @@ -3,6 +3,8 @@ " git@github.com:JamshedVesuna/vim-markdown-preview.git "============================================================ +let b:vmp_script_path = resolve(expand(':p:h')) + if !exists("g:vim_markdown_preview_browser") let g:vim_markdown_preview_browser = 'Google Chrome' endif @@ -40,6 +42,8 @@ function! Vim_Markdown_Preview() endif if has('mac') let OSNAME = 'mac' + let b:search_script = b:vmp_script_path . '/applescript/search-for-vmp.scpt' + let b:activate_script = b:vmp_script_path . '/applescript/activate-vmp.scpt' endif let curr_file = expand('%:p') @@ -68,7 +72,12 @@ function! Vim_Markdown_Preview() endif if OSNAME == 'mac' - call system('open -g /tmp/vim-markdown-preview.html') + let b:vmp_preview_in_browser = system('osascript ' . b:search_script) + if b:vmp_preview_in_browser == 1 + call system('open -g /tmp/vim-markdown-preview.html') + else + call system('osascript ' . b:activate_script) + endif endif if g:vim_markdown_preview_temp_file == 1 @@ -92,6 +101,8 @@ function! Vim_Markdown_Preview_Local() endif if has('mac') let OSNAME = 'mac' + let b:search_script = b:vmp_script_path . '/applescript/search-for-vmp.scpt' + let b:activate_script = b:vmp_script_path . '/applescript/activate-vmp.scpt' endif let curr_file = expand('%:p') @@ -120,7 +131,12 @@ function! Vim_Markdown_Preview_Local() endif if OSNAME == 'mac' - call system('open -g vim-markdown-preview.html') + let b:vmp_preview_in_browser = system('osascript ' . b:search_script) + if b:vmp_preview_in_browser == 1 + call system('open -g /tmp/vim-markdown-preview.html') + else + call system('osascript ' . b:activate_script) + endif endif if g:vim_markdown_preview_temp_file == 1 -- 2.45.2