Merge pull request #1764 from cornfeedhobo/history-plugins
refactor all history modifications into discrete pluginspull/1794/head
commit
18781ed397
|
|
@ -24,6 +24,12 @@ hooks
|
||||||
.gitattributes
|
.gitattributes
|
||||||
lint_clean_files.sh
|
lint_clean_files.sh
|
||||||
|
|
||||||
|
# plugins
|
||||||
|
#
|
||||||
|
plugins/available/history.plugin.bash
|
||||||
|
plugins/available/history-search.plugin.bash
|
||||||
|
plugins/available/history-substring-search.plugin.bash
|
||||||
|
|
||||||
# themes
|
# themes
|
||||||
#
|
#
|
||||||
themes/agnoster
|
themes/agnoster
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Bash History Handling
|
|
||||||
|
|
||||||
shopt -s histappend # append to bash_history if Terminal.app quits
|
|
||||||
export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups} # erase duplicates; alternative option: export HISTCONTROL=ignoredups
|
|
||||||
export HISTSIZE=${HISTSIZE:-5000} # resize history size
|
|
||||||
export AUTOFEATURE=${AUTOFEATURE:-true autotest} # Cucumber / Autotest integration
|
|
||||||
|
|
||||||
function rh {
|
|
||||||
history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
cite about-plugin
|
||||||
|
about-plugin 'search history using the prefix already entered'
|
||||||
|
|
||||||
|
# enter a few characters and press UpArrow/DownArrow
|
||||||
|
# to search backwards/forwards through the history
|
||||||
|
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||||
|
bind '"\e[A":history-search-backward'
|
||||||
|
bind '"\e[B":history-search-forward'
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
cite about-plugin
|
||||||
|
about-plugin 'search history using the substring already entered'
|
||||||
|
|
||||||
|
# enter a few characters and press UpArrow/DownArrow
|
||||||
|
# to search backwards/forwards through the history
|
||||||
|
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]; then
|
||||||
|
bind '"\e[A":history-substring-search-backward'
|
||||||
|
bind '"\e[B":history-substring-search-forward'
|
||||||
|
fi
|
||||||
|
|
@ -1,9 +1,39 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
cite about-plugin
|
cite about-plugin
|
||||||
about-plugin 'history manipulation'
|
about-plugin 'improve history handling with sane defaults'
|
||||||
# enter a few characters and press UpArrow/DownArrow
|
|
||||||
# to search backwards/forwards through the history
|
# append to bash_history if Terminal.app quits
|
||||||
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]
|
shopt -s histappend
|
||||||
then
|
|
||||||
bind '"[A":history-search-backward'
|
# erase duplicates; alternative option: export HISTCONTROL=ignoredups
|
||||||
bind '"[B":history-search-forward'
|
export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}
|
||||||
fi
|
|
||||||
|
# resize history to 100x the default (500)
|
||||||
|
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