aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-22 16:43:55 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-01-22 16:43:55 +0100
commit9e36977b9d4641c9fc67eee9b36bdfa8a3b85bbd (patch)
treeec7328de8715c2452453482d82ba879f006ce518
parent364494371016d140478d45b7c57c926b82e3c610 (diff)
downloadzuwu-9e36977b9d4641c9fc67eee9b36bdfa8a3b85bbd.tar.gz
zuwu-9e36977b9d4641c9fc67eee9b36bdfa8a3b85bbd.tar.bz2
zuwu-9e36977b9d4641c9fc67eee9b36bdfa8a3b85bbd.tar.lz
zuwu-9e36977b9d4641c9fc67eee9b36bdfa8a3b85bbd.zip

fix: avoid grepping shell rc file, and avoid calling __sethist if not defined

-rwxr-xr-xzuwu.zsh7
1 files changed, 3 insertions, 4 deletions
diff --git a/zuwu.zsh b/zuwu.zsh
index 00f788f..afa26fb 100755
--- a/zuwu.zsh
+++ b/zuwu.zsh
@@ -19,9 +19,8 @@ eval_append() {
<<<"$2" >> "$1"
eval "$2"
}
-if ! grep '# The following lines were added by compinstall' ~/.zshrc >/dev/null 2>/dev/null && ! grep 'compinit' ~/.zshrc >/dev/null 2>/dev/null; then
+if ! test compinit >/dev/null 2>/dev/null; then
eval_append ~/.zshrc "$(<<EOF
-# Note: Do not remove the 'The following lines were...' comment!
# The following lines were added by compinstall
zstyle ':completion:*' completer _complete _ignored _correct
zstyle ':completion:*' format 'Completing %d'
@@ -275,7 +274,7 @@ __sethist() {
__sethist
# History Size Determination
-if ! grep 'HISTSIZE' ~/.zshrc >/dev/null 2>/dev/null; then
+if ! [ -n "${HISTSIZE+1}" ]; then
eval_append ~/.zshrc "$(<<EOF
# Lines configured by zsh-newuser-install
HISTFILE="~/.histfile"
@@ -284,7 +283,7 @@ SAVEHIST="10000"
# End of lines configured by zsh-newuser-install
# Overwrite histfile with zuwu implementation, using HISTDIR and HISTID - if you don't want this implementation, comment out the next line.
-__sethist
+typeset -f __sethist >/dev/null 2>/dev/null && __sethist || true
EOF
)"
fi