def available_editor(preferred = nil)
      [preferred, ENV['EDITOR'], 'mate -w', 'vim', 'vi', 'emacs', 'nano', 'pico']
        .compact
        .find { |name| system("hash #{name.split.first} 2>&-") }
    end
#
Find an editor available in path. Optionally supply the _preferred_
editor. Returns the name as a string, nil if none is available.