Possible to follow behaviour defined in .inputrc?

In RStudio, the up arrow goes through the history of previous commands in order, and ctrl-up or (cmd-up) searches through the history with the string preceding the insertion point.

For the shell, this behaviour is configured via the .inputrc file, and me, like many others, have configured the up arrow to do a search. Since the command-line version of R follows this behaviour, this is quite deep in my muscle memory, and actually a bit of a challenge whenever I use RStudio.

Would it be possible to make RStudio read the .inputrc file and follow the behaviour configured there?

1 Like

In RStudio 1.1 (currently in preview) we've added lots more GNU readline-like behavior, including Ctrl+R incremental reverse history search and Ctrl+N/Ctrl+P to navigate the history, but we haven't yet tackled trying to respect per-user preferences in .inpurtrc.

It's not impossible to do so, though, so we'll consider it in a future release. Appreciate the suggestion!

2 Likes

I would also very much welcome this behaviour. I understand that tying that up to .intputrc might be problematic (especially on Windows) but I think the following default would be safe + nice:

  • Ctrl/Cmd+↑ does history search, with whatever is to the left of the cursor on the current line = opens a modal with the history and the possibility to click through the list (i.e. almost the current behaviour, except that I would restrict it to what is to the left of the cursor, which should be inconsequent in most cases but makes it easier to recover from mistakes).
  • does history recall = replaces the current command with a command from history, but here also I would restrict results to whatever matches what is currently to the left of the cursor. With nothing typed, you get the current behaviour. With something typed you iterate through history, limited to items matching the current text.

For this to work, when the current command line is replaced by a line from history, the cursor should stay in the same place. This does not prevent execution of the code because pressing Enter executes the whole line, no matter where the cursor is.

Example. My history is

foo <- 1
fib <- 2
bar <- 3

Now my prompt looks like this

> f|

where | is the cursor.

Now, Ctrl/Cmd+↑ gives me a modal with

foo <- 1
fib <- 2

and selecting the first (oldest) element of the history fills the command prompt with

> f|oo <- 1

Note the position of the cursor. This way, typing Ctrl/Cmd+↑ again gives me the same options again (because only "f" is to the left of the cursor), which allows me to select a different one in case I clicked wrong.

Typing replaces the command line with

> f|ib <- 2

and typing again gives

> f|oo <- 1

Of course typing gives back

> f|ib <- 2

As @ilari.scheinin, my muscle memory is so used to this behaviour of that I am having trouble adjusting!

I went ahead and wrote this up as a feature request https://github.com/rstudio/rstudio/issues/2771

Fingers crossed.