Score:1

Redo keyboard shortcut in Ubuntu shell (Bash)?

ru flag

There is a question about the undo keyboard shortcut in Ubuntu: Ctrl+_ or Ctrl+/ can do this.

Is there a redo keyboard shortcut?

Score:3
vn flag

Is there a redo keyboard shortcut?

Not directly in Bash, as mentioned already in another answer.

However, when editing more complicated command-lines, you might want to open it in an editor that can provide redo functionality (and more). Bash uses Ctrl+X Ctrl+E keybinding (when using default keybindings) or EscV (for vi keybindings) to open the current command-line in your selected editor (by default, Nano, in Ubuntu).

You can then use the undo/redo commands from your editor.

After editing the command-line, exiting the editor will execute the command.

To change the default editor system-wide, use:

sudo update-alternatives --config editor

To override just for your user, set the EDITOR environment variable to the path of your preferred editor.


Site-note: Do use caution with this feature -- As mentioned in this comment, any editor exiting with a success (0 return code) will cause the command to be executed in its last saved state, which could be unexpectedly dangerous.

See this answer for a potential workaround (which I have not tested personally). Also note that some other shells (Zsh and Fish, at least) do not execute the command on exit, but simply paste it into the command line, then requiring an Enter to execute. This is, IMHO, much safer default behavior.

Score:1
cn flag

No, there isn't. You have to redo yourself what you undid.

user956609 avatar
ru flag
why i don’t under stand
vanadium avatar
cn flag
Because nobody implemented that. Perhaps it makes little sense to have a redo command for editing an interactive command. For more complex commands you can use an editor.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.