Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/irb/command/copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def copy_to_clipboard(text)
def clipboard_program
@clipboard_program ||= if IRB.conf[:COPY_COMMAND]
IRB.conf[:COPY_COMMAND]
elsif executable?("clip.exe")
"clip.exe"
elsif executable?("pbcopy")
"pbcopy"
elsif executable?("xclip")
Expand All @@ -62,11 +64,19 @@ def clipboard_program
end

def executable?(command)
system("which #{command} > /dev/null 2>&1")
if windows?
system("where #{command} > NUL 2>&1")
else
system("which #{command} > /dev/null 2>&1")
end
end

def clipboard_available?
!!clipboard_program
windows? || !!clipboard_program
end

def windows?
/mingw|mswin/.match?(RUBY_PLATFORM)
end
end
end
Expand Down