run shell commands using popen
This commit is contained in:
parent
576438708e
commit
a7b9c3ec4c
|
@ -13,13 +13,6 @@ require 'set'
|
|||
module Fingers
|
||||
end
|
||||
|
||||
# Monkey patching string to add shellscape method, maybe remove.
|
||||
class String
|
||||
def shellescape
|
||||
gsub('"', '\\"')
|
||||
end
|
||||
end
|
||||
|
||||
require 'tmux'
|
||||
require 'tmux_format_printer'
|
||||
require 'huffman'
|
||||
|
|
|
@ -11,8 +11,10 @@ class Fingers::ActionRunner
|
|||
|
||||
return unless final_shell_command
|
||||
|
||||
redirect_to_log_file = ">>#{Fingers::Dirs::LOG_PATH} 2>&1"
|
||||
`tmux run-shell -b "#{final_shell_command} #{redirect_to_log_file}"`
|
||||
IO.popen(action_env, final_shell_command, "r+") do |io|
|
||||
io.puts match
|
||||
io.close_write
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -48,14 +50,14 @@ class Fingers::ActionRunner
|
|||
# return unless ENV['DISPLAY']
|
||||
return unless system_copy_command
|
||||
|
||||
%(printf "#{match.shellescape}" | #{system_copy_command})
|
||||
system_copy_command
|
||||
end
|
||||
|
||||
def open
|
||||
# return unless ENV['DISPLAY']
|
||||
return unless system_open_command
|
||||
|
||||
%(printf "#{match.shellescape}" | #{system_open_command})
|
||||
system_open_command
|
||||
end
|
||||
|
||||
def paste
|
||||
|
@ -63,7 +65,11 @@ class Fingers::ActionRunner
|
|||
end
|
||||
|
||||
def shell_action
|
||||
%(printf "#{match.shellescape}" | MODIFIER=#{modifier} HINT=#{hint} #{action})
|
||||
action
|
||||
end
|
||||
|
||||
def action_env
|
||||
{ 'MODIFIER' => modifier, 'HINT' => hint }
|
||||
end
|
||||
|
||||
def action
|
||||
|
|
Loading…
Reference in New Issue