Is it possible to…
-
Step up local ZSH shell history (actions only happened in that prompt)
-
Step up global ZSH history (shared history is on) – default what happens when you press UP arrow when shared history is on
… separately.
For example one might bind CTRL+up for global history, normal up for local history. At the same time it makes sense to use the global history for a backwards history search (i.e. CTRL+R).
This might speed up some shell operations, as some operations are specific to that shell window and you want to go back in them.
Best Answer
Copy & Paste this to your
.zshrc
:Cursors are using local history:
If you need also key bindings (CTRL + cursors) to step through the global history add also this to your
.zshrc
:To make this work the option SHARE_HISTORY (see 16.2.4 History) needs to be enabled. Run
setopt
and check if "sharehistory" is listed. If not addsetopt sharehistory
to your.zshrc
. Then one can use set-local-history as we did above. The documenation says:Note that by default global history is used (and all functions end with "zle set-local-history 0", i.e. local history is disabled). So pressing CTRL + R will search the global history by default (which makes sense in most cases).
This is quite similar to the solution by @mpy, but ready for copy & paste. It overwrites the cursor keys up and down. I used this mail list entry.
See also: