||FreeBSD General Commands Manual
xprompt - prompt a user for input
xprompt [ X toolkit options ] [-rlen number] [-ibw number] [-grab]
[-nograb] [-pfn fontname] [-rfn fontname] [-re] [-nre] [-tf filename] [-w
wordchars] [-warp] [-nowarp] -p prompt [-r reply] [-p prompt [-r reply]] ...
Xprompt pops up a window containing a prompt and an optional default
reply. If more than one prompt argument is given, the cursor-down key and the
return key select the next prompt and the cursor-up key selects the previous
prompt. The program exits normally by typing <ctrl> D or pressing any
mouse button inside the reply area of the window. The replies are printed to
stdout, one per line. Most standard editing characters (e.g., Delete,
Backspace, <ctrl> U, cursor movement) are available. These default key
bindings may be changed.
Xprompt can be aborted by typing <ctrl> C. In this
case, no output is generated and an exit code of 1 is returned by the
The default is to position the window in the middle of the screen
and to grab keyboard input so that the cursor need not be positioned inside
the text area. If no height or width geometry is provided, xprompt
will calculate 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:
- -rlen number
- Specifies the maximum length of the reply. The default is 80
- -ibw number
- Specifies the border width for the box bounding the text area. The default
- The cursor must be in the text portion of the window for input to be
- The cursor may be anywhere but input is directed to the text area.
- -r reply
- Insert reply into the text area as the default reply.
- -pfn fontname
- Specifies the font to be used for the prompt string.
- -rfn fontname
- Specifies 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 <ctrl> D).
- The return key will not terminate the program. This is the default.
- -tf filename
- Specifies a file containing text translations, one per line, to override
the defaults. Xprompt recognizes the following functions in
addition to those predefined:
The resource textTranslations may also be used to specify translations.
- The program terminates and returns an exit status of 1. The default
binding is Ctrl<Key>C.
- Erases the entire reply. The default binding is Ctrl<Key>U.
- By default, a word is considered to consist of one or more alphanumeric
characters. Non-word characters following the cursor are deleted, then
word characters are deleted up until the next non-word character or the
end of line. There is no default binding.
- All replies are printed and the program terminates with an exit status of
0. The default bindings are Ctrl<Key>D, <Btn1Down>,
<Btn2Down>, and <Btn3Down>.
- The next prompt is displayed. The list of prompts is circular, so the
first prompt is displayed after the last. The default bindings are
Ctrl<Key>J, Ctrl<Key>M, <Key>Down, and
- If all prompts have been seen and returnExit is TRUE, finish-prompt() will
be called otherwise next-prompt() will be called. The default binding is
- The previous prompt is displayed. The last prompt is considered to be
previous to the first. The default binding is <Key>Up.
- -w wordchars
- The string wordchars specifies the characters that make up a word
for the purpose of the erase-word() function. The string is in a format
similar to that used by the tar(1) command:
The default is "a-zA-Z0-9".
- A backslash followed by 1, 2, or 3 octal digits stands for the ASCII
character corresponding to the octal value. The value is limited to 8
- A backslash followed by a non-octal digit character stands for the
- Other ASCII characters stand for themselves.
- The range of characters between two characters, <c1> and <c2>,
is specified by a sequence of the form <c1>-<c2> when
<c1> comes before <c2> in the ASCII character set.
The standard X toolkit options and resources are accepted. For example, the
default font can be changed by the standard -fn fontname flag or by the
resource XPrompt*Font. In addition, the following resources are
- Warp the cursor into the text area and return it to its original position
- Don't warp the cursor. This is the default.
If xprompt is invoked from a Bourne shell script, the following hack can
be used to quickly grab multi-reply output:
- Rlen (class Integer)
- Specifies the maximum length of the reply.
- insideborderWidth (class BorderWidth)
- Specifies the border width for the box bounding the text area.
- Grab (class Boolean)
- Specifies whether keyboard input should be focussed on the text area
regardless of where the cursor is.
- replyFont (class Font)
- The font to use for the reply string, overriding XPrompt*Font.
- promptFont (class Font)
- The font to use for the prompt string, overriding XPrompt*Font.
- returnExit (class Boolean)
- Specifies whether the return key should allow normal termination if all
prompts have been seen.
- textTranslations (class String)
- Text widget translations.
- textTranslationFile (class String)
- The name of a file containing text widget translations.
- Warp (class Boolean)
- Warp the cursor into the text area.
- wordChars (class String)
- The set of character that make up a word for the purpose of the
On normal completion 0 is returned. If the program is aborted, 1 is returned.
reply=`xprompt -p "Prompt1" -p "Prompt2" -p
echo "First reply is: $1"
echo "Second reply is: $2"
echo "Third reply is: $3"
Dept. of Computer Science
University of British Columbia
Valuable suggestions by Rick Morrison and Bob Mende.
Conversion to X11R5 by Casey Leedom.
The reply is limited to a single line. The user is responsible for ensuring that
a proper window size is chosen.
Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.