Interactive prompt reader and read builtin companion for the fish shell.
With Fisher
fisher install re3turn/fish-get jorgebucaran/getopts.fish
-
-por--prompt=MSG: Set the prompt message. -
-ror--rule=REGEX: Use the Regular ExpressionREGEXto validate the input. This creates an infinite read loop until the input matchesREGEX. -
-eor--error=MSG: Set the error message.MSGis aprintfbuiltin format string. Use the first positional %s to display the read input. -
-sor--silent[=NUMBER]: Hide the user input as it is being typed. Use this option to handle passwords or other sensitive data. Optionally, indicate aNUMBERto read up to a certain number of characters instead of a new line by default. -
-dor--default=STRING: Use default value if none selected. -
-qor--quiet: Suppress standard output. -
--no-case: Ignore case during validation. -
--no-cursor: Hide cursor. -
-hor--help: Show usage help.
get will print any user input to standard output by default.
getUse --prompt=MSG to display a prompt.
get --prompt "What's your name?\n-> "Use --rule=REGEX to validate the user input.
get --prompt="Enter a number:" --rule="[0-9]"Use --error=MSG to display an error message when --rule=REGEX fails. The error message can be printf builtin format string and the user input can be displayed using %s.
get --prompt="Enter a number:" --rule="[0-9]" --error="'%s' is not a valid number."Use --silent to hide the user input and read a password into a variable.
get --prompt="Enter your password:" --silentUsing --silent in combination with --rule and --error will hide the input from the error message using a star character *.
get --prompt="Enter your password:" --rule="[0-9]" --error="Invalid password '%s'" --silentUse --no-cursor to hide the cursor and --silent=NUMBER to read up to NUMBER of characters too.
Use
--quietto suppress writing the read input to standard output.
get --prompt="Press any key to continue..." --no-cursor --silent=1Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.