Skip to content

Commit 448a3a1

Browse files
committed
Add news and docs for the new history searcher
1 parent aed28c3 commit 448a3a1

File tree

2 files changed

+89
-64
lines changed

2 files changed

+89
-64
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Standard library changes
9999
* The Julia REPL now support bracketed paste on Windows which should significantly speed up pasting large code blocks into the REPL ([#59825])
100100
* The REPL now provides syntax highlighting for input as you type. See the REPL docs for more info about customization.
101101
* The REPL now supports automatic insertion of closing brackets, parentheses, and quotes. See the REPL docs for more info about customization.
102+
* History searching has been rewritten to use a new interactive modal dialogue, using a fzf-like style.
102103
* The display of `AbstractChar`s in the main REPL mode now includes LaTeX input information like what is shown in help mode ([#58181]).
103104
* Display of repeated frames and cycles in stack traces has been improved by bracketing them in the trace and treating them consistently ([#55841]).
104105

stdlib/REPL/docs/src/index.md

Lines changed: 88 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -205,83 +205,92 @@ at the beginning of the line. The prompt for this mode is `pkg>`. It supports it
205205
entered by pressing `?` at the beginning of the line of the `pkg>` prompt. The Package manager mode is
206206
documented in the Pkg manual, available at [https://julialang.github.io/Pkg.jl/v1/](https://julialang.github.io/Pkg.jl/v1/).
207207

208-
### Search modes
208+
### History searching
209209

210210
In all of the above modes, the executed lines get saved to a history file, which can be searched.
211-
To initiate an incremental search through the previous history, type `^R` -- the control key
212-
together with the `r` key. The prompt will change to ```(reverse-i-search)`':```, and as you
213-
type the search query will appear in the quotes. The most recent result that matches the query
214-
will dynamically update to the right of the colon as more is typed. To find an older result using
215-
the same query, simply type `^R` again.
211+
To initiate an interactive search through the previous history, type `^R` -- the control key
212+
together with the `r` key.
216213

217-
Just as `^R` is a reverse search, `^S` is a forward search, with the prompt ```(i-search)`':```.
218-
The two may be used in conjunction with each other to move through the previous or next matching
219-
results, respectively.
214+
You will be presented with an interactive history viewer. As you type your search history will be filtered;
215+
pressing enter will insert the selected history entry into the REPL. Detailed help for the history
216+
searcher is available within the REPL with the special queries `?` and `??`.
220217

221218
All executed commands in the Julia REPL are logged into `~/.julia/logs/repl_history.jl` along with a timestamp of when it was executed
222-
and the current REPL mode you were in. Search mode queries this log file in order to find the commands which you previously ran.
223-
This can be disabled at startup by passing the `--history-file=no` flag to Julia.
219+
and the current REPL mode you were in. The history searcher reads this log file in order to find the commands which you previously ran.
220+
Multiple REPLs can write to this file at once, and every time you begin a search the newest history is fetched.
221+
Use of this file can be disabled at startup by passing the `--history-file=no` flag to Julia.
224222

225223
## Key bindings
226224

227225
The Julia REPL makes great use of key bindings. Several control-key bindings were already introduced
228-
above (`^D` to exit, `^R` and `^S` for searching), but there are many more. In addition to the
226+
above (`^D` to exit, `^R` for searching), but there are many more. In addition to the
229227
control-key, there are also meta-key bindings. These vary more by platform, but most terminals
230228
default to using alt- or option- held down with a key to send the meta-key (or can be configured
231229
to do so), or pressing Esc and then the key.
232230

233-
| Keybinding | Description |
234-
|:------------------- |:---------------------------------------------------------------------------------------------------------- |
235-
| **Program control** | |
236-
| `^D` | Exit (when buffer is empty) |
237-
| `^C` | Interrupt or cancel |
238-
| `^L` | Clear console screen |
239-
| Return/Enter, `^J` | New line, executing if it is complete |
240-
| meta-Return/Enter | Insert new line without executing it |
241-
| `?` or `;` | Enter help or shell mode (when at start of a line) |
242-
| `^R`, `^S` | Incremental history search, described above |
243-
| **Cursor movement** | |
244-
| Right arrow, `^F` | Move right one character |
245-
| Left arrow, `^B` | Move left one character |
246-
| ctrl-Right, `meta-F`| Move right one word |
247-
| ctrl-Left, `meta-B` | Move left one word |
248-
| Home, `^A` | Move to beginning of line |
249-
| End, `^E` | Move to end of line |
250-
| Up arrow, `^P` | Move up one line (or change to the previous history entry that matches the text before the cursor) |
251-
| Down arrow, `^N` | Move down one line (or change to the next history entry that matches the text before the cursor) |
252-
| Shift-Arrow Key | Move cursor according to the direction of the Arrow key, while activating the region ("shift selection") |
253-
| Page-up, `meta-P` | Change to the previous history entry |
254-
| Page-down, `meta-N` | Change to the next history entry |
255-
| `meta-<` | Change to the first history entry (of the current session if it is before the current position in history) |
256-
| `meta->` | Change to the last history entry |
257-
| `^-Space` | Set the "mark" in the editing region (and de-activate the region if it's active) |
258-
| `^-Space ^-Space` | Set the "mark" in the editing region and make the region "active", i.e. highlighted |
259-
| `^G` | De-activate the region (i.e. make it not highlighted) |
260-
| `^X^X` | Exchange the current position with the mark |
261-
| **Editing** | |
262-
| Backspace, `^H` | Delete the previous character, or the whole region when it's active |
263-
| Delete, `^D` | Forward delete one character (when buffer has text) |
264-
| meta-Backspace | Delete the previous word |
265-
| `meta-d` | Forward delete the next word |
266-
| `^W` | Delete previous text up to the nearest whitespace |
267-
| `meta-w` | Copy the current region in the kill ring |
268-
| `meta-W` | "Kill" the current region, placing the text in the kill ring |
269-
| `^U` | "Kill" to beginning of line, placing the text in the kill ring |
270-
| `^K` | "Kill" to end of line, placing the text in the kill ring |
271-
| `^Y` | "Yank" insert the text from the kill ring |
272-
| `meta-y` | Replace a previously yanked text with an older entry from the kill ring |
273-
| `^T` | Transpose the characters about the cursor |
274-
| `meta-Up arrow` | Transpose current line with line above |
275-
| `meta-Down arrow` | Transpose current line with line below |
276-
| `meta-u` | Change the next word to uppercase |
277-
| `meta-c` | Change the next word to titlecase |
278-
| `meta-l` | Change the next word to lowercase |
279-
| `^/`, `^_` | Undo previous editing action |
280-
| `^Q` | Write a number in REPL and press `^Q` to open editor at corresponding stackframe or method |
281-
| `meta-Left Arrow` | Indent the current line on the left |
282-
| `meta-Right Arrow` | Indent the current line on the right |
283-
| `meta-.` | Insert last word from previous history entry |
284-
| `meta-e` | Edit the current input in an editor |
231+
| Keybinding | Description |
232+
|:----------------------|:-----------------------------------------------------------------------------------------------------------|
233+
| **Program control** | |
234+
| `^D` | Exit (when buffer is empty) |
235+
| `^C` | Interrupt or cancel |
236+
| `^L` | Clear console screen |
237+
| Return/Enter, `^J` | New line, executing if it is complete |
238+
| meta-Return/Enter | Insert new line without executing it |
239+
| `?` or `;` | Enter help or shell mode (when at start of a line) |
240+
| `^R`, `^S` | Interactive history search, described above |
241+
| **Cursor movement** | |
242+
| Right arrow, `^F` | Move right one character |
243+
| Left arrow, `^B` | Move left one character |
244+
| ctrl-Right, `meta-F` | Move right one word |
245+
| ctrl-Left, `meta-B` | Move left one word |
246+
| Home, `^A` | Move to beginning of line |
247+
| End, `^E` | Move to end of line |
248+
| Up arrow, `^P` | Move up one line (or change to the previous history entry that matches the text before the cursor) |
249+
| Down arrow, `^N` | Move down one line (or change to the next history entry that matches the text before the cursor) |
250+
| Shift-Arrow Key | Move cursor according to the direction of the Arrow key, while activating the region ("shift selection") |
251+
| Page-up, `meta-P` | Change to the previous history entry |
252+
| Page-down, `meta-N` | Change to the next history entry |
253+
| `meta-<` | Change to the first history entry (of the current session if it is before the current position in history) |
254+
| `meta->` | Change to the last history entry |
255+
| `^-Space` | Set the "mark" in the editing region (and de-activate the region if it's active) |
256+
| `^-Space ^-Space` | Set the "mark" in the editing region and make the region "active", i.e. highlighted |
257+
| `^G` | De-activate the region (i.e. make it not highlighted) |
258+
| `^X^X` | Exchange the current position with the mark |
259+
| **Editing** | |
260+
| Backspace, `^H` | Delete the previous character, or the whole region when it's active |
261+
| Delete, `^D` | Forward delete one character (when buffer has text) |
262+
| meta-Backspace | Delete the previous word |
263+
| `meta-d` | Forward delete the next word |
264+
| `^W` | Delete previous text up to the nearest whitespace |
265+
| `meta-w` | Copy the current region in the kill ring |
266+
| `meta-W` | "Kill" the current region, placing the text in the kill ring |
267+
| `^U` | "Kill" to beginning of line, placing the text in the kill ring |
268+
| `^K` | "Kill" to end of line, placing the text in the kill ring |
269+
| `^Y` | "Yank" insert the text from the kill ring |
270+
| `meta-y` | Replace a previously yanked text with an older entry from the kill ring |
271+
| `^T` | Transpose the characters about the cursor |
272+
| `meta-Up arrow` | Transpose current line with line above |
273+
| `meta-Down arrow` | Transpose current line with line below |
274+
| `meta-u` | Change the next word to uppercase |
275+
| `meta-c` | Change the next word to titlecase |
276+
| `meta-l` | Change the next word to lowercase |
277+
| `^/`, `^_` | Undo previous editing action |
278+
| `^Q` | Write a number in REPL and press `^Q` to open editor at corresponding stackframe or method |
279+
| `meta-Left Arrow` | Indent the current line on the left |
280+
| `meta-Right Arrow` | Indent the current line on the right |
281+
| `meta-.` | Insert last word from previous history entry |
282+
| `meta-e` | Edit the current input in an editor |
283+
| **History search** | |
284+
| Up arrow, `^P`, `^K` | Move the focus one entry up |
285+
| Down arrow, `^P`, `^N`| Move the focus one entry down |
286+
| Page up, `^B` | Move the focus one page up |
287+
| Page down, `^F` | Move the focus one page down |
288+
| `meta-<` | Focus on the first (oldest) history entry |
289+
| `meta->` | Focus on the last (most recent) history entry |
290+
| Tab | Toggle selection of the currently focused entry |
291+
| Enter | Accept the currently focused/selected entries |
292+
| `^S` | Save the focused/selected entries to the clipboard or a file |
293+
| `^C`, `^D`, `^G` | Abort the history search |
285294

286295
### Customizing keybindings
287296

@@ -732,6 +741,21 @@ inherit = "julia_rainbow_curly_2"
732741

733742
For a complete list of customizable faces, see the [JuliaSyntaxHighlighting package documentation](https://julialang.github.io/JuliaSyntaxHighlighting.jl/dev/).
734743

744+
## Customising the history searcher
745+
746+
The history searcher uses the following default faces, that can be customised:
747+
748+
```toml
749+
[REPL.History.search]
750+
separator.fg = "blue"
751+
prefix.fg = "magenta"
752+
selected.fg = "blue"
753+
unselected.fg = "grey"
754+
hint = { fg = "magenta", slant = "italic", weight ="light" }
755+
results.inherit = "shadow"
756+
match = { weight = "bold", underline = true }
757+
```
758+
735759
## Customizing Colors
736760

737761
The colors used by Julia and the REPL can be customized, as well. To change the

0 commit comments

Comments
 (0)