Skip to content

How to command-prompt from a shell script? #2499

@mohkale

Description

@mohkale

Issue description

I'm currently trying to write a script to interactively pipe-panes. Part of this involves asking the user which direction they want the pipe to go (in, out, both), followed by the command name and confirming whether they'd like to kill an open pipe.

command-prompt by itself doesn't have a flag to output the result to stdout so I've been trying to do indirectly through display-message but It seems to me that the command-prompt command implicitly runs a subshell which captures the output preventing my script from recieving it.

For example I have a script ~/tmux-pipe-ctrl which I've bound to | (bind | $HOME/tmux-pipe-ctrl) containing this:

choice=$(tmux command-prompt -1 -p "Direction (i|o|b):" "display-message -p '%%'")

How do I access the command-prompt result from within my script?

If there's no way (as of yet) I'd like to propose a flag that dumps the prompts result to stdout.

Required information

Please provide the following information:

  • tmux version (tmux -V). tmux next-3.3
  • Platform (uname -sp). Linux unknown
  • $TERM inside and outside of tmux (echo $TERM). screen-256color
  • Logs from tmux (tmux kill-server; tmux -vv new).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions