Change history alias into a function
This commit changes the history alias into a function which puts
the passed arguments before `-l 1`. It also provides a temporary
workaround to the lack of a `history -c` command in zsh.
For more information see issues 739 and 789.
Diff
1diff --git a/lib/history.zsh b/lib/history.zsh
2index 5de71c2d3e0fdd0296cc8d46da9fbd1724fd7a00..8a861fdbcd74a6233df5efd67a00d34dc7651265 100644
3--- a/lib/history.zsh
4+++ b/lib/history.zsh
5@@ -6,12 +6,24 @@ fi
6 HISTSIZE=10000
7 SAVEHIST=10000
8 9-# Show history
10+## History wrapper
11+function omz_history {
12+ # Delete the history file if `-c' argument provided.
13+ # This won't affect the `history' command output until the next login.
14+ if [[ "${@[(i)-c]}" -le $# ]]; then
15+ echo -n >| "$HISTFILE"
16+ echo >&2 History file deleted. Reload the session to see its effects.
17+ else
18+ fc $@ -l 1
19+ fi
20+}
21+
22+# Timestamp format
23 case $HIST_STAMPS in
24- "mm/dd/yyyy") alias history='fc -fl 1' ;;
25- "dd.mm.yyyy") alias history='fc -El 1' ;;
26- "yyyy-mm-dd") alias history='fc -il 1' ;;
27- *) alias history='fc -l 1' ;;
28+ "mm/dd/yyyy") alias history='omz_history -f' ;;
29+ "dd.mm.yyyy") alias history='omz_history -E' ;;
30+ "yyyy-mm-dd") alias history='omz_history -i' ;;
31+ *) alias history='omz_history' ;;
32 esac
3334 setopt append_history