Method: TTY::Pager::SystemPager.find_executable

Defined in:
lib/tty/pager/system.rb

.find_executable(*commands) ⇒ String?

Find first available termainal pager program executable

Examples:

Basic usage

find_executable # => "less"

Usage with commands

find_executable("less", "cat")  # => "less"

Parameters:

  • commands (Array[String])

Returns:

  • (String, nil)

    the found executable or nil when not found



92
93
94
95
96
97
# File 'lib/tty/pager/system.rb', line 92

def self.find_executable(*commands)
  execs = commands.empty? ? executables : commands
  execs
    .compact.map(&:strip).reject(&:empty?).uniq
    .find { |cmd| command_exist?(cmd.split.first) }
end