Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last command in same terminal

Tags:

zsh

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?

like image 994
mseebach Avatar asked Feb 29 '12 15:02

mseebach


People also ask

How do you repeat the last command in 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.

Where is the previous command in terminal?

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.

How do I go back to the last command?

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.

How do I use Sudo last command?

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.


1 Answers

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.

like image 61
lolesque Avatar answered Dec 15 '22 14:12

lolesque