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

时间:2016-03-07 19:16:00

标签: zsh zsh-zle

我使用以下绑定允许我按Control-Z恢复我之前背景的程序。我设置histoptignorespace并在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

1 个答案:

答案 0 :(得分:1)

以下对我有用。它实际上只是直接运行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