Sitelet https://github.com/pforret/bashew/pull/24
Skip to content

Add Tool:pick - interactive pick-from-list helper - #24

Merged
pforret merged 3 commits into
masterfrom
claude/internal-tool-picker-qyyev1
Sep 19, 2026
Merged

pforret merged 3 commits into
masterfrom
claude/internal-tool-picker-qyyev1

Conversation

@pforret

@pforret pforret commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Options are read as lines from stdin, the chosen one is written to
stdout. Uses fzf if available, otherwise gum, otherwise bash's builtin
'select' (reading from /dev/tty since stdin holds the options).
Returns 1 with empty output when there are no options or the user cancels.

Includes docs and bash_unit tests (fzf and gum branches are faked).

Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01VMDQ5o753Kzsa7NHRy8mxN

pforret and others added 3 commits September 19, 2026 12:03
Options are read as lines from stdin, the chosen one is written to
stdout. Uses fzf if available, otherwise gum, otherwise bash's builtin
'select' (reading from /dev/tty since stdin holds the options).
Returns 1 with empty output when there are no options or the user cancels.

Includes docs and bash_unit tests (fzf and gum branches are faked).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDQ5o753Kzsa7NHRy8mxN
With a non-empty 2nd parameter, an extra "other: ..." option is appended
to the list. Choosing it prompts the user (on the terminal) to type their
own answer, which is trimmed and returned instead of a list entry.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDQ5o753Kzsa7NHRy8mxN
- 2nd parameter is now the label of the free-text option ("1" keeps "other: ...")
- 3rd parameter: default, returned when no choice can be made: with -f/--FORCE,
  without a terminal (cron, CI) or on timeout; defaults to the first option
- 4th parameter: timeout in seconds (0 = wait forever); fzf/gum are stopped by
  a watchdog (Tool:_pick_timeout), the bash menu uses read -t
- the 'select' fallback is replaced by a bash-only numbered menu with timeout support
- new Os:has_tty helper: true when there is a terminal to interact with

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VMDQ5o753Kzsa7NHRy8mxN
@pforret
pforret merged commit ab77878 into master Sep 19, 2026
3 checks passed
@what-the-diff

what-the-diff Bot commented Sep 19, 2026

Copy link
Copy Markdown

PR Summary

  • Enhanced User Interactivity with Tool:pick Function

    • This PR introduces an updated picking function that enhances user interaction. It provides a selection option from an input list using various tools. This function includes additional features like a free-text answer, a default selection, and an adjustable timeout.
  • New Function 'Os:has_tty' to Verify Terminal Availability

    • A new function has been added to confirm if a terminal is available for interaction, ensuring smoother operation and preventing errors related to terminal unavailability.
  • Updated Documentation For New Functions

    • Documentation for the new functions Tool:pick and Os:has_tty has been updated, providing examples and usage guidelines. It simplifies user interaction and understanding of the functions.
  • Core Logic Implementation in script.sh

    • The core logic for the interactive Tool:pick function and its timeout handling is implemented in this PR. This advancement ensures seamless functionality and better user experience.
  • Extensive Unit Tests in test_functions.sh

    • For ensuring the validity and proper operation of the Tool:pick function, various test conditions are applied. These include empty input, non-interactive use, successful selections, cancellation cases, and timeout handling scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant