Class: Snip::Util::Editor
- Inherits:
-
Object
- Object
- Snip::Util::Editor
- Defined in:
- lib/snip/util/editor.rb
Class Method Summary collapse
Class Method Details
.open(file_path) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/snip/util/editor.rb', line 5 def self.open(file_path) unless ENV.has_key?('EDITOR') puts "No editor configured. The $EDITOR shell variable is empty." puts "Example: Add 'echo EDITOR=vim' to your .bashrc or .zshrc if you would like to use VIM as your editor." return end # open configured editor and redirect outputs `#{ENV['EDITOR']} "#{file_path}" 3>&1 1>&2 2>&3` unless $?.success? puts "Error occured: " + $?.to_s end $? end |