add top-history
parent
61f727fb96
commit
4044f4123c
|
|
@ -1,3 +1,4 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'search history using the prefix already entered'
|
about-plugin 'search history using the prefix already entered'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'search history using the substring already entered'
|
about-plugin 'search history using the substring already entered'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'improve history handling with sane defaults'
|
about-plugin 'improve history handling with sane defaults'
|
||||||
|
|
||||||
|
|
@ -9,3 +10,30 @@ export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}
|
||||||
|
|
||||||
# resize history to 100x the default (500)
|
# resize history to 100x the default (500)
|
||||||
export HISTSIZE=${HISTSIZE:-50000}
|
export HISTSIZE=${HISTSIZE:-50000}
|
||||||
|
|
||||||
|
top-history() {
|
||||||
|
about 'print the name and count of the most commonly run tools'
|
||||||
|
|
||||||
|
if [[ -n $HISTTIMEFORMAT ]]; then
|
||||||
|
# To parse history we need a predictable format, which HISTTIMEFORMAT
|
||||||
|
# gets in the way of. So we unset it and set a trap to guarantee the
|
||||||
|
# user's environment returns to normal even if the pipeline below fails.
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "export HISTTIMEFORMAT='$HISTTIMEFORMAT'" RETURN
|
||||||
|
unset HISTTIMEFORMAT
|
||||||
|
fi
|
||||||
|
|
||||||
|
history \
|
||||||
|
| awk '{
|
||||||
|
a[$2]++
|
||||||
|
}END{
|
||||||
|
for(i in a)
|
||||||
|
printf("%s\t%s\n", a[i], i)
|
||||||
|
}' \
|
||||||
|
| sort --reverse --numeric-sort \
|
||||||
|
| head \
|
||||||
|
| column \
|
||||||
|
--table \
|
||||||
|
--table-columns 'Command Count,Command Name' \
|
||||||
|
--output-separator ' | '
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue