CyberShadow / per-directory-history

Per directory history for zsh, as well as global history, and the ability to toggle between them with ^G.
zlib License
0 stars 1 forks source link

Switch back to global history doesn't work #1

Open tmpm697 opened 4 years ago

tmpm697 commented 4 years ago

Test: get default per-directory-history.zsh from this repo and load it,

open terminal and type something, press alt-l to switch back and forth between global and local history, I don't see global history there.

global history I mean, commands in history file in that I put under ~/.cache/zsh/zsh_history @CyberShadow

I find that the jimhester/per-directory-history works.

CyberShadow commented 4 years ago

What other history options do you have set?

tmpm697 commented 4 years ago

setopt:

autocd
autopushd
nobeep
extendedglob
extendedhistory
nohistbeep
histignorealldups
histignoredups
histnofunctions
histnostore
histsavenodups
histverify
ignoreeof
incappendhistory
interactive
interactivecomments
login
monitor
nonotify
nullglob
promptsubst
pushdignoredups
pushdminus
pushdsilent
pushdtohome
rmstarsilent
sharehistory
shinstdin
zle

@CyberShadow

CyberShadow commented 4 years ago

And what about HISTFILE etc.?

Better yet, can you provide steps to reproduce starting with e.g. env -i TERM=$TERM zsh -f?

tmpm697 commented 4 years ago
env -i TERM=$TERM zsh -f
export HISTFILE=~/.cache/zsh/zsh_history
export HISTSIZE=50000000
export SAVEHIST=50000000
export LESSHISTFILE=-

There's no old command in zsh_history loaded when global is enabled.

CyberShadow commented 4 years ago

Works for me:

$ mkdir -p .cache/zsh
$ echo test > .cache/zsh/zsh_history
$ env -i HOME=$PWD TERM=$TERM zsh -f
localhost% export HISTFILE=~/.cache/zsh/zsh_history
export HISTSIZE=50000000                      
export SAVEHIST=50000000
export LESSHISTFILE=-
source /home/vladimir/.config/oh-my-zsh/plugins/per-directory-history/per-directory-history.plugin.zsh

Pressing Alt+L:

using global history

Now pressing the up arrow key correctly recalls test from the global history file.

tmpm697 commented 4 years ago

Yes, it works as I simulate your steps, but somehow my current zsh configs won't work, zsh doesn't pull commands in zsh_history when enable global.

Is there any clues that would stop it working?

CyberShadow commented 4 years ago

You could try to narrow it down by either bisecting (whittling down) your config to a minimal one, or by trying to debug the plugin code directly to see what it / ZSH is doing.

If it helps, here's my settings:

$ setopt | grep hist   
extendedhistory
histexpiredupsfirst
histfindnodups
histignoredups
histignorespace
histverify
incappendhistory
sharehistory

$ set | grep HIST   
HISTCHARS='!^#'
HISTCMD=820
HISTFILE=/home/vladimir/.zsh_history_dirs/home/vladimir/zsh-per-directory-history
HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS=i
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
HISTSIZE=1000000
PER_DIRECTORY_HISTORY_BASE=/home/vladimir/.zsh_history_dirs
PER_DIRECTORY_HISTORY_FILE=zsh-per-directory-history
PER_DIRECTORY_HISTORY_TOGGLE='\el'
SAVEHIST=1000000
_per_directory_history_last_cmd='set | grep HIST'