浏览代码

fix(history): fix `history -c` (#12362)

Fixes #12362
Marc Cornellà 1 年之前
父节点
当前提交
eafa78217d
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      lib/history.zsh

+ 4 - 4
lib/history.zsh

@@ -4,14 +4,14 @@ function omz_history {
   local clear list stamp
   local clear list stamp
   zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp
   zparseopts -E -D c=clear l=list f=stamp E=stamp i=stamp
 
 
-  if [[ $# -eq 0 ]]; then
-    # if no arguments provided, show full history starting from 1
-    builtin fc $stamp -l 1
-  elif [[ -n "$clear" ]]; then
+  if [[ -n "$clear" ]]; then
     # if -c provided, clobber the history file
     # if -c provided, clobber the history file
     echo -n >| "$HISTFILE"
     echo -n >| "$HISTFILE"
     fc -p "$HISTFILE"
     fc -p "$HISTFILE"
     echo >&2 History file deleted.
     echo >&2 History file deleted.
+  elif [[ $# -eq 0 ]]; then
+    # if no arguments provided, show full history starting from 1
+    builtin fc $stamp -l 1
   else
   else
     # otherwise, run `fc -l` with a custom format
     # otherwise, run `fc -l` with a custom format
     builtin fc $stamp -l "$@"
     builtin fc $stamp -l "$@"