Skip to main content

Editing

The linenoise-based CLI editor is currently only available for macOS and Linux.

Goose's CLI uses a line-editing library based on linenoise, which has shortcuts that are based on Emacs mode of readline. Below is a list of available commands.

Moving

KeyAction
LeftMove back a character
RightMove forward a character
UpMove up a line. When on the first line, move to previous history entry
DownMove down a line. When on last line, move to next history entry
HomeMove to beginning of buffer
EndMove to end of buffer
Ctrl+LeftMove back a word
Ctrl+RightMove forward a word
Ctrl+AMove to beginning of buffer
Ctrl+BMove back a character
Ctrl+EMove to end of buffer
Ctrl+FMove forward a character
Alt+LeftMove back a word
Alt+RightMove forward a word

History

KeyAction
Ctrl+PMove to previous history entry
Ctrl+NMove to next history entry
Ctrl+RSearch the history
Ctrl+SSearch the history
Alt+<Move to first history entry
Alt+>Move to last history entry
Alt+NSearch the history
Alt+PSearch the history

Changing Text

KeyAction
BackspaceDelete previous character
DeleteDelete next character
Ctrl+DDelete next character. When buffer is empty, end editing
Ctrl+HDelete previous character
Ctrl+KDelete everything after the cursor
Ctrl+TSwap current and next character
Ctrl+UDelete all text
Ctrl+WDelete previous word
Alt+CConvert next word to titlecase
Alt+DDelete next word
Alt+LConvert next word to lowercase
Alt+RDelete all text
Alt+TSwap current and next word
Alt+UConvert next word to uppercase
Alt+BackspaceDelete previous word
Alt+\Delete spaces around cursor

Completing

KeyAction
TabAutocomplete. When autocompleting, cycle to next entry
Shift+TabWhen autocompleting, cycle to previous entry
Esc+EscWhen autocompleting, revert autocompletion

Miscellaneous

KeyAction
EnterExecute query. If query is not complete, insert a newline at the end of the buffer
Ctrl+JExecute query. If query is not complete, insert a newline at the end of the buffer
Ctrl+CCancel editing of current query
Ctrl+GCancel editing of current query
Ctrl+LClear screen
Ctrl+OCancel editing of current query
Ctrl+XInsert a newline after the cursor
Ctrl+ZSuspend CLI and return to shell, use fg to re-open

External Editor Mode

Use .edit or \e to open a query in an external text editor.

  • When entered alone, it opens the previous command for editing.
  • When used inside a multi-line command, it opens the current command in the editor.

The editor is taken from the first set environment variable among GOOSE_EDITOR, EDITOR or VISUAL (in that order). If none are set, vi is used.

This feature is only available in the linenoise-based CLI editor, which is currently supported on macOS and Linux.

Using Read-Line

If you prefer, you can use rlwrap to use read-line directly with the shell. Then, use Shift+Enter to insert a newline and Enter to execute the query:

rlwrap --substitute-prompt="D " goose -batch