rlwrap(1)
๐ NAME ๐
rlwrap(1) โ rlwrap is the readline wrapper. That's the whole vibe, bestie. โจ
โจ SYNOPSIS โจ
rlwrap [rlwrap-options] command ...
๐ธ DESCRIPTION ๐ธ
Okay so rlwrap runs the specified command, intercepting user input so you get readline's line editing, persistent history, and completion. It's giving "your terminal but upgraded" ๐
rlwrap tries (and almost succeeds) to be completely transparent โ you (or your shell) shouldn't notice any difference between command and rlwrap command, except the added readline functionality, of course. This should even hold true when you are re-directing, piping, and sending signals from and to command, and when command manipulates its terminal settings, working directory, or (with the -U option) command line. No cap, it's lowkey invisible like that ๐ซถ
There are many options to add (programmable) completion, handle multi-line input, colour, and re-write prompts. If you don't need them (and you probably don't), you can skip the rest of this manpage, although some of those options could make your command line quite a bit more comfortable... ๐
๐ OPTIONS ๐
-a[password_prompt],--always-readline[=password_prompt]โ Always remain in "readline mode" (see below), regardless ofcommand's terminal settings. Ifrlwrap"does nothing", this is the option to use, becausecommandis apparently already doing its own line editing. NB: with this option,rlwrapwill echo (and save) passwords, unless you givecommand's password prompt as an argument.
The argument is optional; if given, it has to directly follow a short option without an intervening space (-aPassword:) and a long option with an equals sign (--always-readline=Password:).
The -N (--no-children) option can be used to avoid wrappiOBng pagers and editors called from command; this should make them much more usable.
-A[!],--ansi-colour-aware[=!]โ Prompts that use colour, or use other CSI codes to e.g. set window titles or enable bracketed-paste, will confuserlwrap, especially at the end of long input lines. This option will usually (but by no means always) makerlwrapbetter behaved in such cases. ๐
Giving '!' as an argument will make rlwrap remove all color codes from the prompt.
The argument is optional; if given, it has to directly follow a short option without an intervening space (-A!) and a long option with an equals sign (--ansi-colour-aware=!).
-b,--break-charslist_of_characters โ Consider the specified characters word-breaking. This determines what is considered a "word", both when completing and when building a completion word list from files specified by-foptions following (not preceding!) it. Default list:(){}[],'+-=&^%$#@";|\Unless-cis specified,/and.(period) are added to this default list. Whitespace is always considered word-breaking, except if you prefix the list with"precisely:". For example:-b $'precisely:\t'will break on tabs, but not on spaces, or anything else. Due to a limitation inrlwrap, newlines are always word-breaking.-c,--complete-filenamesโ Complete filenames (filename completion is always case-sensitive, even with the-ioption). On Linux, OS X, FreeBSD and Solaris,rlwrapwill keep track ofcommand's working directory, so that relative filenames will be completed as one would expect. ๐ฆ-C,--command-namecommand_name|N โ Use command_name instead ofcommandto determine the names of history and completion files, and to evaluate$if command_nameconditionals in$INPUTRC. A numeric argument N > 0 means: use the Nth argument as the command_name (counting backwards from the end of the argument list).-D,--history-no-dupesn โ How aggressively to weed out duplicate entries from the input history. If n =0, all inputs are kept in the history list; if n =1(this is the default), consecutive duplicates are dropped from the list; while n =2will makerlwrapdrop all previous occurrences (in the current session) of the current input from the list.
Using -D 2 in combination with the operate-and-get-next key may shuffle history items around in an unpredictable way! ๐ญ
-e,--extra-char-after-completionchar โ By default,rlwrapappends a space after any inserted completion text. Use this option to change this to''(don't insert anything) or some other character.-E,--always-echoโ By default,rlwrapavoids displaying passwords by echoing'***'whenever the client clears the ECHO flag on its input. This option will makerlwrapignore this ECHO flag and always echo the user's input. (-aPassword:will still work as expected.)-f,--filefile โ Split file into words (using the default word-breaking characters, or those specified by a preceding--break-charsoption), and add them to the completion word list. This option can be given more than once, and adds to the default completion list in$RLWRAP_HOMEor/usr/share/rlwrap/completions.
Specifying -f . will make rlwrap use the current history file as a completion word list.
-g,--forget-matchingregexp โ Forget (i.e. never put into the history list) input lines that match the POSIX 1003.2 regular expression regexp. A common use case would be-g '^[[:blank:]]'(or simply-g '^ ') to not remember input lines that start with a space. The match is always case-insensitive. perl-style character classes like'\d'are not recognised, use'[[:digit:]]'. For more about regular expressions, seeregex (7).-h,--helpโ Print a short help message. Short and sweet, bestie ๐ซถ-H,--history-filenamefile โ Read command history from file (and write it back there if--histsize >= 0).-i,--case-insensitiveโ Ignore case when completing (filename completion remains case-sensitive). This option has to come before any-foptions.-I,--pass-sigint-as-sigtermโ Send a TERM signal tocommandwhen an INT is received (e.g. when you press CTRL-C).-l,--logfilefile โ When in readline mode, appendcommand's output (including echo'ed user input) to file (creating file when it doesn't exist).-m[newline_substitute],--multi-line[=newline_substitute]โ Enable multi-line input using a "newline substitute" character sequence (" \ ", [space-backslash-space] by default). Newline substitutes are translated to newlines before sending the input tocommand. With this option, you can call an external editor$RLWRAP_EDITORon the (expanded) current input with therlwrap_call_editorkey (CTRL-^ by default). The argument is optional; if given, it has to directly follow a short option without an intervening space (-m';;') and a long option with an equals sign (--multi-line=';;').-M,--multi-line-ext.ext โ Call multi-line-editor on temporary files with filename extension .ext (useful for e.g. automatic syntax colouring).-n,--no-warningsโ Don't print warnings.-N,--no-childrenโ Whenrlwrapis invoked with the--always-readlineoption, editors and pagers that are called by the client will be pretty unusable, as they will see your keypresses only if you press ENTER.rlwrap -Nwill avoid this problem by switching to direct mode if it thinkscommandis waiting for one of its children.-o,--one-shotโ Send an EOF tocommandafter accepting the first line of input.-O,--only-cookregexp โ Only ever "cook" prompts that match regexp, which can be preceded by'!', meaning that all matching candidate prompts will be cooked immediately ("confident mode").-p[colour],--prompt-colour[=colour]โ Use one of the colour namesblack,red,green,yellow,blue,cyan,purple(=magenta) orwhite, or an ANSI colour code like$'\033[1;33m'or'ESC[38;5;209m'. An uppercase colour name (YelloworYELLOW) results in a bold prompt. Prompts that already contain (colour) escape sequences or one of the readline "ignore markers" (ASCII0x01and0x02) are never coloured. This option implies--ansi-colour-aware. Google for'ANSI color'to learn more about colour codes. The argument is optional; if given, it has to directly follow a short option without an intervening space (-p'Red') and a long option with an equals sign (--prompt-colour='Red').-P,--pre-giventext โ Startrlwrapwith text in its edit buffer (this will automatically set the--always-readlineoption).-q,--quote-characterslist_of_characters โ Assume that the given characters act as quotes when matching parentheses. Take care to escape the list properly for your shell (example:-q "\"'", which happens to be the default, or-q "\""which will be better for lisp input).-r,--rememberโ Put all words seen on in- and output on the completion list.-R,--reniceโ Makerlwrapnicer thancommand(cfnice (1)). This may preventrlwrapfrom interruptingcommandto display a prompt whencommandis still "thinking" about what to output next.-s,--histsizeN โ Limit the history list to N entries, truncating the history file (default:300). A negative size-N(even-0) means the same asN, but treats the history file as read-only.-S,--substitute-promptprompt โ Substitute the specified prompt forcommand's own prompt. Mainly useful whencommanddoesn't have a prompt.-t,--set-terminal-namename โ Setcommand's TERM to name. Programs that confuserlwrapwith fancy screen control codes can sometimes be tamed by specifying-t dumb.-U,--mirror-argumentsโ (linux only) Keep track ofcommand's arguments as seen by theps (1)command, and mirror them inrlwrap's own arguments. This can be useful for commands that overwrite command-line password arguments that would be exposed byrlwrapwithout this option. The mirroring takes place only after the first user input, or already after a few milliseconds, if you use the--pollingoption (which is what you probably want if you want to hide the command line).-v,--versionโ Printrlwrapversion.-w,--wait-before-prompttimeout โ okay so here's the tea: to figure out whether command's last output is a prompt, rlwrap waits timeout milliseconds after receiving it. Only when no more output has arrived does it get cooked (coloured, filtered and/or replaced by a substitute prompt) and displayed as a prompt. Before that, the prompt shows up "uncooked". Most users won't even notice ๐, but heavy cookers can prepend the timeout with a minus sign, which makes rlwrap hold back the prompt until it's been cooked โ that's "patient mode" โจ. It prevents the prompt from flashing, but it'll also interfere with long output lines and make switches from direct to readline mode less reliable. Default timeout: 40 ms โฑ๏ธ-W,--pollingโ wake up every timeout millisecs, where timeout is the same as for the-w(--wait-before-prompt) option, 40 ms by default. Why? To sense the slave's interrupt character andISIGflag and adjust stdin's terminal settings accordingly, even before you press a key ๐. Try this option e.g. when CTRL+C acts differently on command with, and without, rlwrap. Iconic troubleshooting behavior honestly.-X,--skip_setcttyโ don't create a new session for command: command will inherit the controlling terminal of the process that invokes rlwrap. Lowkey useful for wrapping commands that spawn children that are expected to stay running (in particular: not receive aSIGHUP) when the command itself exits ๐ซถ-z,--filterfilter โ use filter to change rlwrap's behaviour. Filters are small python or perl scripts that rlwrap runs in order to re-write or suppress input, output, prompts, history items and even signals ๐. They can keep sensitive input out of the history, implement simple macros, programmable hotkeys for e.g. fuzzy history search, and programmable completion. rlwrap comes with a perl and a python module to make filter writing easy (cf.RlwrapFilter(3pm)for the perl module โ the python one is very similar, iykyk). A bunch of example filters are installed in the directory/usr/share/rlwrap/filters.
So like, run this:
rlwrap -z listing
and it lists all currently installed filters, while
rlwrap -z filter
displays information about filter ๐
If filter needs arguments, you should quote the whole filter command line, bestie:
rlwrap -z 'filter args' command ...
rlwrap -z 'pipeline filter1 ... : filter2 ... : ...' command ...
If this command line contains shell metacharacters, rlwrap passes it to the system shell for parsing. No cap.
Now, filters have to follow a special protocol, so shell commands like sed and grep cannot be used as rlwrap filters ๐ซ . They can, however, be converted into filters by the makefilter filter:
rlwrap -z 'makefilter egrep -i --color "error|$"' command
will color all occurrences of "error" (or "Error") in command's output, while
rlwrap -z 'makefilter --message-type history sed -e s"/whisky/lemonade/"' command
sanitises your drinking history ๐ธ๐. Both filters can be combined using the pipeline filter, of course. Slay.
โจ EXAMPLES โจ
Run nc (netcat) with command-line editing and history:
rlwrap nc
Wrap smbclient (which uses readline itself), keep passwords out of the history and don't interfere with pagers (like less) called by smbclient:
rlwrap -aPassword: -N smbclient //PEANUT/C
Wrap sensitive_app, hide password from ps (if sensitive_app does so) and keep all input that starts with a space out of history:
rlwrap -g '^ ' -U sensitive_app --password MySeCrEt
Wrap gauche (a Scheme interpreter) with a bold blue prompt, enable multi-line editing (using .scm as filename extension) and don't consider single quotes as quotes (so that the parentheses in e.g. (print 'q) match):
rlwrap -pBlue -m -M .scm -q'"' gosh
Wrap sqlite3, use the pipeto filter to be able to pipe the output of SQL commands through grep and/or less, complete (case-insensitively) on the SQL keywords in sql_words:
rlwrap -a -z pipeto -i -f sql_words sqlite3 contacts.db
In a shell script, use rlwrap in 'one-shot' mode as a replacement for read:
order=$(rlwrap -pYellow -S 'Your pizza? ' -H past_orders -P Margherita -o cat)
๐ฆ DIRECT MODE AND READLINE MODE ๐ฆ
Most simple console commands put your terminal either in "cooked" or in "raw" mode. In cooked mode the terminal will wait until you press the ENTER key before handing the entire line to the program; in raw mode every key you press is handed down immediately โก. In cooked mode you generally can use the backspace key, but not the arrow keys, to edit your input.
When you rlwrap command, rlwrap will run it in a separate session, under its own (controlling) "pseudo-terminal" (pty), and monitor this pty to see whether it is in raw, or in cooked mode. In the first case, rlwrap will copy all input and output directly between command and your terminal ("direct mode"). In the second case, rlwrap will use readline to edit your input ("readline mode"), and monitor command's output โ every last line that doesn't end with a newline is a potential prompt ๐. How it handles such a candidate prompt depends on its being in "patient" or "impatient" mode, see below ๐
Simple console commands use cooked mode whenever they want whole input lines, and raw mode when they want single keypresses. Those are the programs for which rlwrap is most useful ๐ซถ. More sophisticated commands have their own line editor and hence use raw mode all the time. With those commands, rlwrap will appear to "do nothing" ๐. Therefore, if rlwrap is in direct mode when the user presses ENTER for the first time it will give a warning that it needs --always-readline to do anything at all (warnings can be suppressed with the -n option).
๐ธ PATIENT, IMPATIENT AND CONFIDENT MODE ๐ธ
If command writes a lot of output, it tends to be written (and read) in "chunks". Not all chunks will end with a newline, and we need to distinguish their last lines ("candidate prompts") from real prompts โ especially if we want to re-write ("cook") prompts ๐. rlwrap solves this (almost) by waiting a little, to see if there is more to come. "A little" is 40 msec by default, but this can be changed with the -w option.
Normally rlwrap writes the candidate prompt as soon as it is received, replacing it with a "cooked" version after the wait time. This is called "impatient" mode. If you don't like the flashing effect (which can become annoying when you "cook" the prompt heavily) you can put rlwrap in "patient mode" by specifying a negative value with -w (e.g. -w -40). Rlwrap will then hold back the prompt and only print it after cooking โจ.
If prompts always match some regular expression you can specify "confident mode" with --only-cook='!<regexp>' (note the exclamation mark โผ๏ธ). Then all candidate prompts that match (and only those) will be cooked immediately. They will, however, not be "uncooked" if more output arrives, which can happen if they weren't prompts after all ๐ญ. Confident mode doesn't work with a negative value for the -w option.
๐ฅ COOKING PROMPTS ๐ฅ
If and when rlwrap decides that it has a prompt, it will perform a number of actions on it, depending on the given options: filtering (-z), substituting (-S) and colouring (-p), in this order ๐
. The resulting "cooked" prompt is then printed (after erasing the "raw" prompt, if necessary). Chef's kiss, literally.
โจ SPECIAL KEYS AND BINDABLE COMMANDS โจ
okay so these are the little keyboard shortcuts rlwrap gives you, and lowkey they're all rebindable if your window manager is being a hater ๐
- Ctrl + O โ accepts the current line but doesn't drop it into the history list. Its readline command name is
rlwrap-accept-line-and-forget. bestie this one is so good for throwaway commands ๐ - Ctrl + ^ โ pops open an external editor (see
RLWRAP_EDITORbelow) to edit whatever you're currently typing. โ ๏ธ heads up: this only works if the-moption is set. Its readline command name isrlwrap-call-editor. - (Not currently bound) โ any key (or key sequence, see below) can be bound to the readline command
rlwrap-direct-keypress. That key (or keys) then always gets sent straight through to command, even when rlwrap is not in direct mode. no cap ๐ซถ - (Not currently bound) โ any key or key combo can be bound to the readline command
rlwrap-direct-prefix. This is how you define multi-key direct keypresses: you define their first key(s) as a "direct prefix". - (Not currently bound) โ multiple keys can be bound to the readline command
rlwrap-hotkey. Each of those keys then causes the key itself, the current input line, and the current history to be filtered (cf.RlwrapFilter(3pm)) through the current filter โ which means it's a no-op when there's no filter โ and the filter can then re-write the input line, move the cursor, and update the history (differently for each key โจ). After all that, you can still edit the resulting input. iconic. - (Not currently bound) โ
rlwrap-hotkey-without-historyacts likerlwrap-hotkey, except the history (which can be quite large ๐ญ) is not passed to the filter. Way more efficient if your filter wouldn't do anything useful with the history anyway. - (Not currently bound) โ
operate-and-get-nextaccepts the current line for return to the calling application as if a newline had been entered, and fetches the next line relative to the current line from the history for editing. The default readline keybinding (CTRL + O) is overwritten by rlwrap, but you can re-bind it in~/.inputrc. ๐จ Don't use this in combination with-D 2(--history-no-dupes 2), see above.
These special keys were chosen for literally no other reason than that they aren't currently bound to any readline action. If you don't like them (or your window manager swallows them ๐), they โ and the other 4 commands โ can be re-bound more sensibly by putting lines like these in your ~/.inputrc:
"\M-\C-m": rlwrap-accept-line-and-forget # ESC-ENTER to accept but keep out of history
"\C-x": rlwrap-call-editor # CTRL-x e to edit (multi-line) input in editor of your choice
$if erl # (only) for the Erlang shell:
"\C-g": rlwrap-direct-keypress # pass CTRL-g directly to enter 'user switch' command
$endif
"\C-t": rlwrap-direct-prefix # make it possible to define direct keypresses that start with CTRL-t ...
"\C-tx": rlwrap-direct-keypress # ... in that case: pass CTRL-t + x directly.
"\C-y": rlwrap-hotkey-without-history # CTRL-y to filter input line (and e.g. insert X selection)
cf. the readline(3) manpage. ๐ (NB: take care to not use keys that are already caught by your window manager, or by the terminal driver, like CTRL + S โ rlwrap will never see those ๐)
๐ธ ENVIRONMENT ๐ธ
RLWRAP_HOMEโ the directory where the history and completion files live. ๐RLWRAP_EDITOR(or elseEDITOR, or elseVISUAL) โ the editor used for multi-line input (andrlwrap-edit-history). Example time:
export RLWRAP_EDITOR="vi +%L"
export RLWRAP_EDITOR="vim '+call cursor(%L,%C)'"
export RLWRAP_EDITOR="emacs +%L:%C %F"
The first example above is the default โจ โ %L and %C get replaced by line and column numbers corresponding to the cursor position in rlwrap's edit buffer, and %F gets replaced by the name of the (temporary) file. If %F isn't used, that name is put after the (expanded) $RLWAP_EDITOR.
RLWRAP_FILTERDIRโ if you specify a filter with a relative path (rlwrap -z filterorrlwrap -z dir/filter), rlwrap prepends$RLWRAP_FILTERDIRto this path (or/usr/share/rlwrap/filtersif this variable isn't set). ๐ฆ
โก SIGNALS โก
A bunch of signals get forwarded to command: HUP INT QUIT USR1 USR2 TERM and (by way of resizing command's terminal) WINCH. Some care is taken to handle TSTP (usually the result of a CTRL + Z from the terminal) sensibly โ for example, after suspending rlwrap in the middle of a line edit, continuing (by typing fg) will land you at the exact spot where you suspended it. ๐ซถ slay.
A filter can be used to modify/ignore signals, or to send output "out of band" to the rlwrapped command.
Filters (except those that filter signals) that take more than 1 second to respond can be interrupted by a CTRL + C from the terminal โ (although rlwrap will not survive this ๐ญ).
If command changes the keystrokes that send a particular signal from the keyboard (like emacs, which uses CTRL + G instead of CTRL + C), rlwrap will do the same โ but only after the next keystroke. Use the --polling option to make rlwrap more transparent in this respect. ๐
When command is killed by a signal, rlwrap will clean up, reset its signal handlers, and then exit by sending the same signal to itself. This guarantees that your shell will [sic] the same exit status as it would have seen without rlwrap. no cap, that's the whole point ๐ฅ
๐ REDIRECTION ๐
When standard input is not a terminal (or when run inside an emacs buffer), editing input doesn't make sense, so rlwrap will ignore all options and simply execute command in place of itself. ๐ซ
When stdout (or stderr) is not a terminal, rlwrap will re-open it to /dev/tty (the user's terminal) after it has started command, so that command's output is redirected as expected, but keyboard input and rlwrap error messages are still visible. ๐
The upshot of all this: rlwrap command behaves more or less like command when you're redirecting. ๐
๐ EXIT STATUS ๐
Non-zero after an rlwrap error, or else command's exit status. rlwrap will always leave the terminal in a tidy state, even after a crash. โจ (she cleans up after herself, we stan)
๐ FILES ๐
rlwrap expects its history and completion files in $RLWRAP_HOME, but uses .dotfiles in the user's home directory if this variable isn't set. โ ๏ธ This will quickly become messy if you use rlwrap for many different commands. (fr fr, your home dir will be a whole situation ๐)
$RLWRAP_HOME/command_history, ~/.command_history History for command โ remember that command may be overridden by the --command-name (or -C) option. ๐
$RLWRAP_HOME/command_completions, ~/.command_completions Per-user completion word list for command. rlwrap never writes into this list, but you can use -l logfile and then -f logfile to simulate the effect of a -r option that works across invocations. ๐ฆ
/usr/share/rlwrap/completions/command System-wide completion word list for command. This file is only consulted if the per-user completion word list is not found. ๐
$INPUTRC, ~/.inputrc Individual readline initialisation file (see readline (3) for its format). rlwrap sets its application name to command (this can be overridden by the -C option), which enables different behaviours for different commands. You could e.g. put the following lines in ~/.inputrc:
$if coqtop
set show-all-if-ambiguous On
$endif
โฆmaking rlwrap show all completions whenever it runs coqtop. ๐
๐ญ LIMITATIONS ๐ญ
Okay so real talk: although rlwrap is flexible, delivers the goods (readline functionality), and adheres to the Unix "many small tools" paradigm โ it is a kludge. rlwrap cannot know anything about command's internal state, which makes context-sensitive completion impossible. Using the GNU Readline library from within command is still by far the best solution. ๐ฏ
Moreover, "it takes two to tango": there's no way for rlwrap to synchronise its internal state with command, which results in a number of subtle race conditions โ where, for example, command may have changed the state of its terminal before rlwrap has read command output that was written before the state change. You'll notice these races especially on a busy machine and with heavy "cooking" and filtering, when suddenly (and unpredictably) prompts or command output are garbled or incorrectly coloured. ๐ not the vibes.
rlwrap can try, but often fails, to handle prompts that contain control characters (prompts, and the effect of -A and -t, can be analysed by the filter dissect_prompt). If -A (--ansi-colour-aware) doesn't help, a filter may be needed to clean up the prompt. Specifying --set-term-name with a simpler, or even dumb, terminal may also help. ๐ง
โญ VERSION โญ
This manpage documents rlwrap version 0.48.
๐ AUTHORS ๐
The GNU Readline library (written by Brian Fox and Chet Ramey) does all the hard work behind the scenes ๐
, the pty-handling code (written by Geoff C. Wing) was taken practically unchanged from rxvt, and completion word lists are managed by Damian Ivereigh's libredblack library. The rest was written by Hans Lub (hanslub42@gmail.com). ๐ซถ
๐ SEE ALSO ๐
readline(3), RlwrapFilter(3pm)
and that's the whole page bestie!! ๐ source/version: rlwrap(1), documentin' rlwrap version 0.48, dated November 7, 2025 โ go forth and have the cutest little readline-powered prompts, mwah ๐โจ๐ฆ
๐ฆ where this page comes from
- alpine 3.24: rlwrap-doc 0.48-r0 ยท GPL-2.0-or-later
- arch rolling: rlwrap 0.48-1 ยท GPL-2.0-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms