避免将zsh命令添加到历史记录中

避免将zsh命令添加到历史记录中,zsh,zsh-zle,Zsh,Zsh Zle,我使用下面的绑定允许我按Control-Z来恢复我以前后台开发的程序。我设置了historptignorespace,并在fg前面放了一个空格,这样该命令就不会在我的历史记录中保留 但是,当我按下向上箭头时,它仍然出现。有没有办法把这个也去掉?我想按向上箭头忽略曾经输入过fg的事实 # Allow Ctrl-z to toggle between suspend and resume function Resume {

我使用下面的绑定允许我按Control-Z来恢复我以前后台开发的程序。我设置了
historptignorespace
,并在
fg
前面放了一个空格,这样该命令就不会在我的历史记录中保留

但是,当我按下向上箭头时,它仍然出现。有没有办法把这个也去掉?我想按向上箭头忽略曾经输入过
fg
的事实

# Allow Ctrl-z to toggle between suspend and resume                             
function Resume {                                                               
  zle push-input                                                                   
  BUFFER=" fg"                                                                     
  zle accept-line                                                                  
}                                                                                  
zle -N Resume                                                                                                                                                  
bindkey "^Z" Resume

以下几点对我有用。它实际上只是直接运行
fg
。其余部分是返回提示符所必需的

# Allow Ctrl-z to toggle between suspend and resume
function Resume {
  fg
  zle push-input
  BUFFER=""
  zle accept-line
}
zle -N Resume
bindkey "^Z" Resume

唉,我认为这是不可能的。“up history”实际上只是重放您键入的内容。@ChrisKitching我认为您基本上是对的,尽管运行
fg
并直接接受空行解决了我的问题:)