Skip to content

Commit

Permalink
refactor all history modifications into discrete plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
cornfeedhobo committed Jan 15, 2021
1 parent 5e667ed commit 61f727f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
6 changes: 6 additions & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ hooks
.gitattributes
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/agnoster
Expand Down
12 changes: 0 additions & 12 deletions lib/history.bash

This file was deleted.

9 changes: 9 additions & 0 deletions plugins/available/history-search.plugin.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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
9 changes: 9 additions & 0 deletions plugins/available/history-substring-search.plugin.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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
18 changes: 10 additions & 8 deletions plugins/available/history.plugin.bash
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
cite about-plugin
about-plugin 'history manipulation'
# enter a few characters and press UpArrow/DownArrow
# to search backwards/forwards through the history
if [[ ${SHELLOPTS} =~ (vi|emacs) ]]
then
bind '"":history-search-backward'
bind '"":history-search-forward'
fi
about-plugin 'improve history handling with sane defaults'

# append to bash_history if Terminal.app quits
shopt -s histappend

# erase duplicates; alternative option: export HISTCONTROL=ignoredups
export HISTCONTROL=${HISTCONTROL:-ignorespace:erasedups}

# resize history to 100x the default (500)
export HISTSIZE=${HISTSIZE:-50000}

0 comments on commit 61f727f

Please sign in to comment.