reddit / emacs

vterm history cycling for zsh

jensensanssarif · 2022-02-04 14:24
I've been using ansi-term for a while, and I recently tried switching to vterm. It looks and works pretty well, but I'm having a problem with how vterm cycles through your command history. In zsh, if you type something and press the up arrow key, you get the last command you used that starts with what you've already typed. This works fine in ansi-term, but in vterm, it just cycles to the last command that was used in that vterm session. I was wondering if anyone knew if there was any configuring that I need to do on either end to get this to behave the same way in vterm as it does in ansi-term. ---EDIT--- Editing to clarify that it's specifically the matching of the already typed command that's not working. I can cycle through the history without issue, but sometimes I'm sshing onto a machine, or doing a repetitive task, and prefer to have zsh search for the right command for me.
bravosierrasierra · 2022-02-04 18:03
check vterm-shell variable: may be you use bash in vterm?
jensensanssarif · 2022-02-04 19:00
It's set to zsh, I think it may have something to do with what vterm's send-up function does.
TokenMenses · 2022-02-04 19:09
I think this is more of a question of your shell environment variables. I set the following in my zshrc to get shared history across all zshes: ``` setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. setopt SHARE_HISTORY # Share history between all sessions. ```
jensensanssarif · 2022-02-04 19:27
Gave this a try, and it's still behaving the same way, this is useful to have though, thanks!
TokenMenses · 2022-02-04 19:48
Thought that would do it. Here's my full list of history-related settings from my zshrc. Hopefully you can find something by comparing with `set | grep HIST`. ``` #setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. setopt SHARE_HISTORY # Share history between all sessions. setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history. setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again. setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. setopt HIST_FIND_NO_DUPS # Do not display a previously found event. setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. #setopt HIST_VERIFY # Do not execute immediately upon history expansion. setopt APPEND_HISTORY # append to history file #setopt HIST_NO_STORE # Don't store history commands HISTSIZE=1000000 # how many lines of history to keep in memory SAVEHIST=1000000 # how many lines to keep in the history file ```