Method: Howzit::Util.os_paste

Defined in:
lib/howzit/util.rb

.os_pasteObject

Platform-agnostic paste-from-clipboard



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/howzit/util.rb', line 228

def os_paste
  os = RbConfig::CONFIG['target_os']
  out = '{bg}Pasting from clipboard'.c
  case os
  when /darwin.*/i
    Howzit.console.debug("#{out} (macOS){x}".c)
    `pbpaste`
  when /mingw|mswin/i
    Howzit.console.debug("#{out} (Windows){x}".c)
    `cat /dev/clipboard`
  else
    if 'xsel'.available?
      Howzit.console.debug("#{out} (Linux, xsel){x}".c)
      `xsel --clipboard --output`
    elsif 'xclip'.available?
      Howzit.console.debug("#{out} (Linux, xclip){x}".c)
      `xclip -selection clipboard -o`
    else
      Howzit.console.debug(out)
      Howzit.console.warn('Unable to determine executable for clipboard.')
    end
  end
end