Zsh 同一终端中的最后一个命令

Zsh 同一终端中的最后一个命令,zsh,Zsh,在Bash中,当我打开两个终端时,每个终端都保持自己的历史记录,因此向上箭头总是显示在该终端中输入的前一个命令 在zsh中,历史记录是共享的,因此向上箭头表示在任一终端中输入的最后一个命令。我很喜欢ctrl-R为我提供完整的共享历史记录,但有没有办法让arrow up从活动终端向我提供最后一个命令?我无法直接帮助您,但在我的终端中,命令历史记录是一对一的终端,所以这是您所期望的行为。下面我打印出我的.zshrc文件。请玩它。我用雅库克运行终端 # The following lines were

在Bash中,当我打开两个终端时,每个终端都保持自己的历史记录,因此向上箭头总是显示在该终端中输入的前一个命令


在zsh中,历史记录是共享的,因此向上箭头表示在任一终端中输入的最后一个命令。我很喜欢ctrl-R为我提供完整的共享历史记录,但有没有办法让arrow up从活动终端向我提供最后一个命令?

我无法直接帮助您,但在我的终端中,命令历史记录是一对一的终端,所以这是您所期望的行为。下面我打印出我的
.zshrc
文件。请玩它。我用雅库克运行终端

# The following lines were added by compinstall

bindkey -v

bindkey -M viins '^r' history-incremental-search-backward
bindkey -M vicmd '^r' history-incremental-search-backward


#http://grml.org/zsh/zsh-lovers.html
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache



zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*' expand prefix suffix
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-suffixes true
zstyle ':completion:*' original true
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:cd:*' ignore-parents parent pwd
zstyle :compinstall filename '/home/borys/.zshrc'
zstyle ':completion:*:(rm|kill|diff):*' ignore-line yes

autoload colors; colors
setopt autocd
setopt extendedglob


autoload -Uz compinit
compinit
# End of lines added by compinstall
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
# End of lines configured by zsh-newuser-install

# opens txt files in vi
alias -s txt=vi

#shortcuts for going up in directories hierarchy
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'

alias d="dirs -v"
setopt PUSHD_IGNORE_DUPS
setopt AUTO_PUSHD
DIRSTACKSIZE=14



alias findfn="find -type f -name "
alias duall="du -s ./* | sort -n| cut -f 2-|xargs -i du -sh {}"

#prompt theme 
COLOR_RESET="%{$reset_color%}"
PS1="$fg_bold[black][%n@%m:$fg[blue]%~]
$COLOR_RESET%%"
PS2=$PS1
  # PS1=[%n@%m:%2~]

# color stderr
exec 2>>(while read line; do
  print '\e[91m'${(q)line}'\e[0m' > /dev/tty; print -n $'\0'; done &)

#show vi mode in prompt
function zle-line-init zle-keymap-select {
#fg_light_red=$'%{\e[5;25m%}'

#    RPS1="$fg_light_red ${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
#    RPS2=$RPS1
#    PS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}
#[%n@%m:%2~]"
PS1="${${KEYMAP/vicmd/$COLOR_RESET}/(main|viins)/$fg_bold[black]}[%n@%m:$fg[blue]%~]
$COLOR_RESET%%"
    PS2=$PS1
    zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select

export SVN_EDITOR=vi

什么是设置选项

也许您可以设置
共享历史记录
选项

您可以使用
setopt no_share_history
unsetopt share_history
将其取消设置


有关更多选项,请查看
man zshoptions

我怀疑很多人可能会在这里登陆(像我一样),同时寻找共享zsh历史的方法,并且仍然会在同一窗口中显示第一个命令。非常好,正是我所寻找的,
setopt
不是很直观,我期待着类似于
setopt share\u history 0
@Excalibur的东西,你是对的。你找到解决办法了吗?@lumbric:我正在运行oh my zsh,这似乎和预期的一样有效。我在.zshrc中没有看到任何自定义设置。“现在似乎可以用了。@Excalibur嗯,这很奇怪,我也用了oh my zsh,但它不能在开箱即用。”。我现在找到了解决方案:有没有对这件事做出过裁决?我似乎还记得我在一个网站上玩过这个把戏。依我看,这应该是默认行为。两者兼有是一个不错的选择: