Editing a command line

Moving and deleting

Shale's line editor uses the keys Emacs, Bash and most terminal programs share. C-a goes to the start of the line, C-e to the end, and M-b and M-f move a word at a time. The arrow keys, Home, End and Delete work too. For the complete list, read Keys.

Enter runs the line, unless a parenthesis or a quote is still open. Then Enter starts a new line, so a long Sigil form can span several. To start a new line yourself, press C-j.

Cutting and pasting

To cut from the cursor to the end of the line, press C-k; from the start of the line to the cursor, C-u; and the word before the cursor, C-w. Then C-y pastes what you cut most recently.

Shale remembers the last 16 pieces of text you cut. Right after C-y, press M-y to swap what you pasted for the piece before it, and again to go further back. Cuts made one after another join into a single piece, so pressing C-w three times and then C-y puts all three words back.

Text you paste from your terminal goes in as text, without its control characters. Shale doesn't run a pasted line until you press Enter, even when the paste ends with a new line.

History

Shale keeps the lines you run in one history that all your sessions share. C-p or the up arrow shows the line before, and C-n or the down arrow comes back. On a line with several rows, the arrows move between rows first.

To find an older line, press C-r and type part of it. The prompt changes to (reverse-i-search), followed by what you typed and the newest line that contains it. Press C-r again for an older match, Enter to run the match, or C-g to go back to the line you were editing.

A line that starts with a space stays out of history, which is useful for a command with a password or token in it.

Suggestions

As you type, Shale looks for a line in your history that starts with what you've typed, and shows the rest of it in gray after the cursor. It prefers lines you ran in the current directory, so the same few letters can suggest different commands in different projects.

shale
ada :: build-box · ~/project = main · 14:05
$ grep plumber README.md

The suggestion is only a hint, and Enter runs only what you typed. To take it, press C-e or the right arrow. M-f takes the next word of it instead. On a command that spans several lines, C-e only moves to the end of the line.

Completion

Press Tab to complete the word at the cursor. The first word of a command completes to a builtin, a command from your configuration or a program on your PATH. Every other word completes to a file name.

When there's one match, Shale fills it in. A directory gets a slash after it; anything else at the end of the line gets a space. When there are several matches, Shale fills in the part they share; press Tab again to go through them one at a time. Names with spaces or quotes are quoted for you. Hidden files appear only when the word you're completing starts with a dot.

Abbreviations

An abbreviation is a short word that turns into a longer command when you type it as a command name, such as at the start of a line or after &&, and press Space or Enter. Unlike an alias, you see the full command before it runs, and history records the full command. You define abbreviations in your configuration; to learn how, read Configuration.