When, in Bash, I have two terminals open, each maintain its own history, so hitting arrow-up always presents the previous command entered in that terminal.
In zsh the history is shared, so arrow-up presents the last command entered in either terminal. I rather like that ctrl-R gives me the full, shared history, but is there a way to make arrow-up give me the last command from the active terminal?
This is the most dependable shortcut in Linux to execute the last run command in the terminal. Just press the Ctrl and P keys together to fill the prompt with the last executed command and you are ready to go.
Open a terminal application on your Linux or Unix and type history to list all commands. To search for a command in the history, press ctrl+r multiple times. For instance, you can hit the ctrl+r and type string to search.
Press CTRL+P to switch to the last command, and then press CTRL+O to execute it. This will do the wonder. No configuration needed! You can use CTRL+O as many times as you want to keep re-executing the last commands.
If you want to quickly run the last command executed but as the root superuser, simply type the following: sudo !! Yes, that's “sudo” followed by a space and two exclamation points.
What says setopt
?
Maybe you have the option SHARE_HISTORY
set.
You can unset it with setopt no_share_history
or unsetopt share_history
.
For more options look in man zshoptions
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With