zsh/history: optimize history options with array-based loops
Replace individual setopt/unsetopt statements for history options with efficient array-based loops. Also optimize history substring search key bindings using the same pattern. Use lib.hm.zsh.define for consistent array formatting and add unset statements to clean up temporary variables. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
c26a2ac2e4
commit
04f672b5db
4 changed files with 116 additions and 43 deletions
|
|
@ -15,16 +15,25 @@ HISTFILE="/home/hm-user/.zsh_history"
|
|||
mkdir -p "$(dirname "$HISTFILE")"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
unsetopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
unsetopt HIST_IGNORE_ALL_DUPS
|
||||
unsetopt HIST_SAVE_NO_DUPS
|
||||
unsetopt HIST_FIND_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
unsetopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt SHARE_HISTORY
|
||||
unsetopt EXTENDED_HISTORY
|
||||
|
||||
# Enabled history options
|
||||
enabled_opts=(
|
||||
HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY
|
||||
)
|
||||
for opt in "${enabled_opts[@]}"; do
|
||||
setopt "$opt"
|
||||
done
|
||||
unset opt enabled_opts
|
||||
|
||||
# Disabled history options
|
||||
disabled_opts=(
|
||||
APPEND_HISTORY EXTENDED_HISTORY HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
|
||||
HIST_IGNORE_ALL_DUPS HIST_SAVE_NO_DUPS
|
||||
)
|
||||
for opt in "${disabled_opts[@]}"; do
|
||||
unsetopt "$opt"
|
||||
done
|
||||
unset opt disabled_opts
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,16 +32,25 @@
|
|||
mkdir -p "$(dirname "$HISTFILE")"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
unsetopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
unsetopt HIST_IGNORE_ALL_DUPS
|
||||
unsetopt HIST_SAVE_NO_DUPS
|
||||
unsetopt HIST_FIND_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
unsetopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt SHARE_HISTORY
|
||||
unsetopt EXTENDED_HISTORY
|
||||
|
||||
# Enabled history options
|
||||
enabled_opts=(
|
||||
HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY
|
||||
)
|
||||
for opt in "''${enabled_opts[@]}"; do
|
||||
setopt "$opt"
|
||||
done
|
||||
unset opt enabled_opts
|
||||
|
||||
# Disabled history options
|
||||
disabled_opts=(
|
||||
APPEND_HISTORY EXTENDED_HISTORY HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
|
||||
HIST_IGNORE_ALL_DUPS HIST_SAVE_NO_DUPS
|
||||
)
|
||||
for opt in "''${disabled_opts[@]}"; do
|
||||
unsetopt "$opt"
|
||||
done
|
||||
unset opt disabled_opts
|
||||
|
||||
alias -- test1=alias
|
||||
alias -- test2=alias2
|
||||
|
|
|
|||
|
|
@ -50,16 +50,25 @@
|
|||
mkdir -p "$(dirname "$HISTFILE")"
|
||||
|
||||
setopt HIST_FCNTL_LOCK
|
||||
unsetopt APPEND_HISTORY
|
||||
setopt HIST_IGNORE_DUPS
|
||||
unsetopt HIST_IGNORE_ALL_DUPS
|
||||
unsetopt HIST_SAVE_NO_DUPS
|
||||
unsetopt HIST_FIND_NO_DUPS
|
||||
setopt HIST_IGNORE_SPACE
|
||||
unsetopt HIST_EXPIRE_DUPS_FIRST
|
||||
setopt SHARE_HISTORY
|
||||
unsetopt EXTENDED_HISTORY
|
||||
|
||||
# Enabled history options
|
||||
enabled_opts=(
|
||||
HIST_IGNORE_DUPS HIST_IGNORE_SPACE SHARE_HISTORY
|
||||
)
|
||||
for opt in "''${enabled_opts[@]}"; do
|
||||
setopt "$opt"
|
||||
done
|
||||
unset opt enabled_opts
|
||||
|
||||
# Disabled history options
|
||||
disabled_opts=(
|
||||
APPEND_HISTORY EXTENDED_HISTORY HIST_EXPIRE_DUPS_FIRST HIST_FIND_NO_DUPS
|
||||
HIST_IGNORE_ALL_DUPS HIST_SAVE_NO_DUPS
|
||||
)
|
||||
for opt in "''${disabled_opts[@]}"; do
|
||||
unsetopt "$opt"
|
||||
done
|
||||
unset opt disabled_opts
|
||||
|
||||
# Default priority
|
||||
echo "Default priority content"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue