Server.command_prompt
Open a command prompt via $ tmux command-prompt.
Source and package
-
Description#
Always uses
-b(background) to avoid blocking the command queue. Usesend-keys -K -c <client>to type into the prompt and submit.Requires tmux 3.3+ for
-bflag support.Examples#
Interactive prompts require tmux 3.4+; the wrapper itself works on 3.3+ but the
send-keys -K -c <client>round-trip used here is unreliable on 3.3a:>>> from libtmux.common import has_gte_version>>> if has_gte_version("3.4"):... with control_mode() as ctl:... server.command_prompt(... "set -g @cp_test '%1'",... target_client=ctl.client_name,... )... for key in ['h', 'i', 'Enter']:... _ = server.cmd('send-keys', '-K', '-c', ctl.client_name, key)... result = server.cmd('show-options', '-gv', '@cp_test').stdout[0]... else:... result = 'hi'>>> result'hi'- Parameters
-
-
template(str) # – Tmux command template. Use%1,%2for prompt values. -
prompt(str | None) # – Custom prompt text (-pflag). Commas separate multiple prompts. -
inputs(str | None) # – Pre-fill prompt input (-Iflag). Commas separate multiple. -
target_client(str | None) # – Target client (-tflag). -
one_key(bool | None) # – Accept only one key press (-1flag). -
key_only(bool | None) # – Only accept key presses, not text (-kflag). -
on_input_change(bool | None) # – Run template on each keystroke (-iflag). -
numeric(bool | None) # – Accept only numeric input (-Nflag). -
prompt_type(t.Literal ["command", "search", "target", "window-target"] | None) # – Prompt type (-Tflag). -
expand_format(bool | None) # – Pass the template throughargs_make_commands_prepare(-Fflag) so format strings expand. Requires tmux 3.3+. -
literal(bool | None) # – Disable splitting prompt on commas — treat it as a single prompt (-lflag). Requires tmux 3.6+. -
bspace_exit(bool | None) # – Close the prompt when the user empties it with backspace (-eflag,PROMPT_BSPACE_EXIT). Requires tmux 3.7+ (upstream master). -
no_freeze(bool | None) # – Do not freeze panes while the prompt is open (-Cflag,PROMPT_NOFREEZE), matchingdisplay-message -C. Requires tmux 3.7+; warns and is ignored on older tmux.
-
tmux command#
The tmux commands behind command_prompt.
tmux C API#
The C declarations in tmux that implement these commands.
In other ports#
Ask a client for input and run a command with it
| Language | Equivalent |
|---|---|
| Haskell | No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing. |
| TypeScript | no equivalent on Server |
| Rust | server |
| Go | tmux |
| Java | no equivalent on Server |
| C# | Lib |
| C++ | no equivalent on Server |
| Swift | no equivalent on Server |
| OCaml | No direct public OCaml equivalent is recorded for this operation. |
| Perl | No dedicated equivalent in the selected Perl surface. Explicit Server::cmd remains available for native tmux commands. |
No equivalent is recorded in Ruby, Lua, PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.