Permalink
Browse files

Send return key to Terminal before "Open in Vim"

  • Loading branch information...
jmettraux committed Apr 1, 2017
1 parent 2e4f006 commit 6fcad2dbd162f8a4ce273b6c260665bdda32fe58
Showing with 8 additions and 3 deletions.
  1. BIN out/images/20170331_automator.png
  2. +8 −3 posts/20170331.md
Binary file not shown.
View
@@ -30,7 +30,7 @@ Here are the two pieces of code, the Javascript one:
<pre><code class="javascript">
function run(input, parameters) {
var m = input.toString().match(/( [^\s\/:]*\/[^\s:]+)(:[0-9]+)?/);
var m = input.toString().match(/([^\s\/:"]*\/[^\s:"]+)(:[0-9]+)?/);
var m1 = m[1].trim();
var m2 = m[2] ? "+" + m[2].substring(1) + " " : "";
@@ -46,7 +46,8 @@ on run {input, parameters}
tell application "Terminal"
activate
delay 0.7
delay 0.3
tell application "System Events" to key code 36
do script ("" & input) in front window
end tell
@@ -62,5 +63,9 @@ For those of you using iTerm2, here is a post by [Luca Guidi](https://lucaguidi.
**Update 2017-04-01**
Made Javascript more robust.
Made Javascript [more robust](https://github.com/jmettraux/blog/commit/1054165ebbda8741670cc1638898849cb44e3d18).
**Update 2017-04-02**
Made Javascript more robust and made sure to send a preliminary return key stroke to the terminal before calling Vim.

0 comments on commit 6fcad2d

Please sign in to comment.