Skip to content

Commit

Permalink
Fix mvim Focus on exotic Terminal. Closes gh-4
Browse files Browse the repository at this point in the history
Mvim focus fix is now available for iTerm too
  • Loading branch information
nel committed Jan 30, 2011
1 parent bbc6dea commit a09af52
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/interactive_editor.rb
Expand Up @@ -25,7 +25,7 @@ def edit(file=nil)
end
mtime = File.stat(@file.path).mtime

args = Shellwords.shellwords(@editor) #parse @editor as arguments could be complexe
args = Shellwords.shellwords(@editor) #parse @editor as arguments could be complex
args << @file.path
Exec.system(*args)

Expand Down Expand Up @@ -68,7 +68,11 @@ module Editors
:emacs => nil,
:nano => nil,
:mate => 'mate -w',
:mvim => 'mvim -g -f -c "au VimLeave * !open -a Terminal"'
:mvim => 'mvim -g -f' + case ENV['TERM_PROGRAM']
when 'iTerm.app' then ' -c "au VimLeave * !open -a iTerm"' #on close refocus on iTerm
when 'Apple_Terminal' then ' -c "au VimLeave * !open -a Terminal"' #on close refocus on Terminal
else '' #don't do tricky things if we don't know the Term
end
}.each do |k,v|
define_method(k) do |*args|
InteractiveEditor.edit(v || k, *args)
Expand Down

0 comments on commit a09af52

Please sign in to comment.