lib/howzit/prompt.rb in howzit-2.0.14 vs lib/howzit/prompt.rb in howzit-2.0.15

- old
+ new

@@ -76,18 +76,24 @@ ## ## @param matches [Array] The options list ## ## @return [Array] the selected results ## - def choose(matches) + def choose(matches, height: :auto) + height = if height == :auto + matches.count + 3 + else + TTY::Screen.rows + end if Util.command_exist?('fzf') settings = [ '-0', '-1', '-m', - "--height=#{matches.count + 3}", + "--height=#{height}", '--header="Use tab to mark multiple selections, enter to display/run"', - '--prompt="Select a section > "' + '--prompt="Select a section > "', + '--preview="howzit {}"' ] res = `echo #{Shellwords.escape(matches.join("\n"))} | fzf #{settings.join(' ')}`.strip if res.nil? || res.empty? Howzit.console.info 'Cancelled' Process.exit 0