Open Dentrax opened 3 years ago
@sbstp
As a workaround, I thought of a few possible solutions to handle this:
By creating a temp history file for the current session, we can easily cover this. We should append every command we write to that temporary file. In the merging stage, we can listen for the zshexit
hook in order to append the whole $ZDOTDIR/.current_history
to $HOME/.zsh_history
. Rebasing by time is needed for the history file after merge operation?
Is it make sense to append each command we write to under $HOME/.zsh_history
? We can add a precmd
hook for this.
Like the kubectx. Why wouldn't we make shell spawning optional? I might simply do not want to work under a new shell.
Any thoughts? @sbstp Looking forward to this feature. 😍
This feels like something that should be implemented outside of kubie. The sub-shell is required to inject a bunch of stuff into .bashrc
when we launch the shell.
I'm not sure if real time history merging between multiple terminals is something that people actually want. But you should be able to setup your shell to merge history when it exists using plain old shell settings, like shown here.
I think the reason why that happens comes from using a sub-shell in the first place.
I recently looked at kubie how it is doing terminal window isolation etc.
Using a sub-shell definitely has advantages that I did not consider when starting to implement kubeswitch 1.5 years ago.
However, not launching a sub-shell also avoids problems such as this one. The shell history works across terminals +
seeing a history of selected contexts (via switch h
) works.
Anyways, kubie is a great tool and I guess has trade-offs and advantages like a lot of other software.
Actually I don't understand why this is so complicated. Even with a sub shell, you can just point HISTFILE
to its default value, and then it that case it will work as expected.
The decision of merging/sharing/appending history is controlled by the user https://unix.stackexchange.com/questions/1288/preserve-bash-history-in-multiple-terminal-windows.
Currently it would be great if kubie
will offer an option to use the default HISTFILE
instead of creating a copy of it, as this creates a bug where ideally merged history just disappears.
I currently bypassed this by:
cp ~/.zsh_history ~/.zsh_history_bypass_kubie
vim ~/.zshrc
HISTFILE=~/.zsh_history_bypass_kubie
HISTSIZE=500000
SAVEHIST=500000
setopt appendhistory
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
Kind ping here. 🤞 @sbstp
I'd like to see this feature in kubie. Anyone has a bandwidth to submit a PR for this?
cc @sbstp
Currently it would be great if kubie will offer an option to use the default
HISTFILE
instead of creating a copy of it, as this creates a bug where ideally merged history just disappears.
If you explicitly configure HISTFILE
, what exactly is the problem? I am not entirely sure if I understand. I'm trying to get this fixed, but I don't see a problem if you have export HISTFILE="$HOME/.zsh_history
. Yes, the history file will be copied, but zsh will write to the original file.
Sorry, cc @Shaked (2 years later 😅)
It would be a great feature if we are able to pass our command history to main shell in order to keep history maintained from sub-shells. Currently, we do not have access to any previous commands after we exit the sub-shell.