File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,29 @@ export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}
99
1010# resize history to 100x the default (500)
1111export HISTSIZE=${HISTSIZE:- 50000}
12+
13+ top-history () {
14+ about ' print the name and count of the most commonly run tools'
15+
16+ if [[ -n $HISTTIMEFORMAT ]]; then
17+ # To parse history we need a predictable format, which HISTTIMEFORMAT
18+ # gets in the way of. So we unset it and set a trap to guarantee the
19+ # user's environment returns to normal even if the pipeline below fails.
20+ trap " export HISTTIMEFORMAT='$HISTTIMEFORMAT '" RETURN
21+ unset HISTTIMEFORMAT
22+ fi
23+
24+ history \
25+ | awk ' {
26+ a[$2]++
27+ }END{
28+ for(i in a)
29+ printf("%s\t%s\n", a[i], i)
30+ }' \
31+ | sort --reverse --numeric-sort \
32+ | head \
33+ | column \
34+ --table \
35+ --table-columns ' Command Count,Command Name' \
36+ --output-separator ' | '
37+ }
You can’t perform that action at this time.
0 commit comments