共同历史和非共同历史

共同历史和非共同历史

使用zsh(in tmux),我想使用 访问会话历史记录,以及使用(或类似)Up访问共享历史记录。Shift+Up

有谁知道如何实现这一点?

答案1

假设您的终端输出Up^[[A

up-line-or-history() {
  zle .set-local-history -n ${#WIDGET:#*global*}  # 0 iff $WIDGET == *global*
  zle .up-line-or-history
}
zle -N up-line-or-history-local up-line-or-history
zle -N up-line-or-history-global up-line-or-history

# Up arrow
bindkey '^[[A' up-line-or-history-local

# Alt + up arrow
bindkey '^[^[[A' up-line-or-history-global

要检查按 时终端实际输出的内容Up,可以按CtrlV,然后按Up

有关上述代码如何工作的更多信息,请参阅http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html

相关内容