input for platform
Get input from the user via the terminal.
Signature
> input {flags} (prompt)
Flags
-
--bytes-until-any, -u {string}: Read bytes (not text) until any of the given stop bytes is seen. -
--numchar, -n {int}: Number of characters to read; suppresses output. -
--default, -d {string}: Default value if no input is provided. -
--reedline: Use the reedline library, defaults to false. -
--history-file {path}: Path to a file to read and write command history. This is a text file and will be created if it doesn't exist. Will be used as the selection list. Implies--reedline. -
--max-history {int}: The maximum number of entries to keep in the history, defaults to $env.config.history.max_size. Implies--reedline. -
--suppress-output, -s: Don't print keystroke values.
Parameters
-
prompt: Prompt to show the user.
Input/output types:
| input | output |
|---|---|
| nothing | any |
| list<string> | any |
Examples
Get input from the user, and assign to a variable.
> let user_input = (input)
Get two characters from the user, and assign to a variable.
> let user_input = (input --numchar 2)
Get input from the user with default value, and assign to a variable.
> let user_input = (input --default 10)
Get multiple lines of input from the user (newlines can be entered using Alt + Enter or Ctrl + Enter), and assign to a variable.
> let multiline_input = (input --reedline)
Get input from the user with history, and assign to a variable.
> let user_input = ([past,command,entries] | input --reedline)
Get input from the user with history backed by a file, and assign to a variable.
> let user_input = (input --reedline --history-file ./history.txt)
Subcommands:
| name | description | type |
|---|---|---|
input list |
Display an interactive list for user selection. | built-in |
input listen |
Listen for user interface events. | built-in |
Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/input.html