|XPROMPT(1)||General Commands Manual||XPROMPT(1)|
xprompt — prompt a user for input
X toolkit options] [
-rlen ] [
xprompt is a utility for the X Window System that is used by interactive scripts to prompt a user for one or more text inputs. It returns the response(s) by printing them to stdout, one per line. Xprompt pops up a window containing a prompt area and a reply area. Any reply area can optionally contain a default reply. If more than one prompt argument is given, only one is visible at a time but the user can scroll through the list of prompts to provide a response to each. A reply that contains no text will be emitted as a newline.
When there is more than one prompt, the cursor-down key and the Return (Enter) key select the next prompt and the cursor-up key selects the previous prompt. The program exits normally by typing ^D or pressing any mouse button inside the reply area of the window. Most standard editing commands (e.g., Delete, Backspace, ^U, cursor movement) are available. These default key bindings may be changed.
If the user is being prompted for potentially sensitive information,
such as a password, an initial "echo mode" can be selected to hide
the reply text.
action cycles through all of the echo modes.
The current echo mode applies to all prompts.
Refer to the
Normal text selection is not supported,
however an entire reply can be selected
CUT_BUFFER0 for subsequent pasting),
regardless of the echo mode in effect.
Also, the most recent text selection
(e.g., in an
can be pasted into the reply at the current cursor position,
also regardless of the echo mode.
Xprompt can be aborted by typing ^C. In this case, no output is generated and the program terminates with an exit status of 1.
The default is to position the window in the middle of the screen and to grab keyboard input so that the cursor does not need to be moved to the text area. If no height or width geometry is provided for the popup window, xprompt calculates it based on the length of the prompt, the reply length, and the fonts being used. If a height (or width) is provided, it is interpreted in terms of the character height (or width) in the reply font.
The following command line flags are recognized:
The maximum reply length is
Once this limit is reached, additional reply characters are ignored.
The default is 80 characters.
for the box bounding the text area is
The default is 1.
If the echo mode is
on (the default),
reply text is echoed normally.
If the mode is
reply text is not echoed.
If the mode is
each reply character is displayed as the mask character
If the mode is
dmask (delayed mask),
each reply character is displayed normally until either a timer expires
or another character is typed (whichever occurs first),
and then it is changed into the delayed mask character
The duration of the delay is configurable by the
-dmd flag or
When echo mode is
delay at most
ms milliseconds before a normally
echoed reply character is changed to the delayed mask character.
Print debugging output to stdout.
Turn off debugging output. This is the default.
The cursor may be anywhere but input is directed to the reply's text area.
The cursor must be in the reply's text area for input to be accepted.
The font to be used for the prompt string.
The font to be used for the reply string.
After all prompts have been seen, the Return key causes the program to exit normally (i.e., it becomes a synonym for ^D).
No return-exit. The Return key will not terminate the program. This is the default.
A file containing text translations, one per line,
to override the defaults.
may also be used to specify translations.
Warp the cursor into the text area and return it to its original position before exiting.
Don't warp the cursor. This is the default.
Print a helpful usage blurb, then exit. This is the default if no command line options are given or in the event of incorrect usage.
Print version information, then exit.
Append the string
to the ordered list of prompts.
reply string is given,
use it as the default reply for this prompt.
Xprompt defines (and redefines) key bindings for user convenience and in aid of the variety of echo modes it supports. It is possible to rebind keys, or sequences of keys, by changing the translations resources for events. This should be done with care because standard Text Widget actions may not work correctly. Some actions have several equivalent bindings.
Edit actions always act on the currently selected reply and are effective regardless of the echo mode.
Xprompt recognizes the following functions, shown with their default bindings:
Ctrl<Key>A: xp-beginning-of-line() Ctrl<Key>E: xp-end-of-line() <Key>Left: xp-backward-char() <Key>Right: xp-forward-char()
Ctrl<Key>J: xp-next-prompt() Ctrl<Key>M: xp-next-prompt() <Key>Linefeed: xp-next-prompt() <Key>Down: xp-next-prompt() <Key>Up: xp-previous-prompt() <Key>Return: xp-next-prompt-or-finish()
Ctrl<Key>C: xp-abort() Ctrl<Key>D: xp-finish-prompt() Ctrl<Key>L: xp-redraw-display() Ctrl<Key>T: xp-toggle-echo-mode()
Ctrl<Key>H: xp-erase-char() Ctrl<Key>K: xp-kill-to-end-of-line() Ctrl<Key>W: xp-erase-word() Ctrl<Key>U: xp-erase-line() <Key>BackSpace: xp-erase-char() <Key>Delete: xp-delete-char()
<Btn1Up>: xp-select-reply() <Btn1Down>: xp-ignore() <Btn2Down>: xp-paste-selection()
<Btn3Up>: xp-ignore() <Btn3Down>: xp-ignore() <Btn1Motion>: xp-ignore() <Btn2Motion>: xp-ignore() <Btn3Motion>: xp-ignore()
The function of an action is usually evident from its name. A few actions merit additional explanation [with their default binding]:
Terminate immediately with an exit status of 1.
Cycle to the next echo mode, retaining the text in the current reply
and moving the input cursor to the end of the reply.
Insert the contents of
respecting the maximum reply length.
Copy the contents of the reply buffer to
(e.g., so that it can be pasted into some other window).
Erase the entire reply. [
Erase the reply from the current cursor position to the end,
and save the erased text in
Delete any whitespace characters immediately to the left of the cursor,
then any sequence of non-whitespace characters.
Delete the reply character immediately to the left of the cursor.
Delete the reply character under the cursor.
Print all replies and the terminate with an exit status
of 0. [
Display the next prompt.
The list of prompts is circular, so the first prompt is displayed after
If all prompts have been seen and
Display the previous prompt.
The last prompt is previous to the first.
Insert this character (without interpretation) at the reply's current
The standard X toolkit options and resources are accepted.
For example, the default font can be changed by the standard
flag or by the resource
In addition, the following resources are understood:
The maximum length of the reply.
enable debugging output.
The delay in ms for echo mode dmask.
The initial echo mode, as one of the
-echo flag parameters.
The border width for the box bounding the text area.
keyboard input should be focussed on the text area
regardless of where the cursor is.
The character to display when the echo mode is
The character to display when the echo mode is
The font to use for the reply string, overriding
The font to use for the prompt string, overriding
TRUE, the Return key allows
normal termination if all prompts have been seen.
Text widget translations.
The name of a file containing text widget translations.
Warp the cursor into the text area, if
The following demonstrates how xprompt can be used by a shell script to grab multi-reply output:
reply=`xprompt -p "Prompt1" -p "Prompt2" -p "Prompt3"` IFS=" " set $reply echo "First reply is: $1" echo "Second reply is: $2" echo "Third reply is: $3"
Originally released under an MIT license variant. Subsequent versions also use the BSD-2-Clause license. Refer to the distribution's LICENSE file and source code for details.
A reply is limited to a single line. The user is responsible for ensuring that a proper window size is chosen. The masking characters cannot be specified on the command line, only by resources. Although some care is taken to keep potentially sensitive reply text private, such as by disabling core dumps, xprompt does not offer a high degree of security. Text that has been echoed in one of the privacy modes can still be selected for pasting, at which point it is vulnerable to being seen or copied, even long after xprompt has terminated. Accidentally toggling the echo mode will instantly "unhide" text.
Originally written circa 1989 by:
Barry Brachman <email@example.com>
Dept. of Computer Science
University of British Columbia
with valuable suggestions by Rick Morrison and Bob Mende. Conversion to X11R5 by Casey Leedom.
Updated 30 years after its original release by
Barry Brachman <firstname.lastname@example.org>.
The latest release is available at https://www.dss.ca/dss/tech/src/xprompt.
|xprompt version 2.0.1||3-Oct-2019||XPROMPT(1)|
$Id: xprompt.1.xml 3092 2019-10-03 19:28:09Z brachman $