From 2c663313168490d28f607738e962aa45ada0e26b Mon Sep 17 00:00:00 2001 From: Eugen Blattner Date: Tue, 5 Apr 2022 20:48:58 +0200 Subject: [PATCH 1/5] fix: use deflating flag for pixz in unarchive function --- modules/archive/functions/unarchive | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/archive/functions/unarchive b/modules/archive/functions/unarchive index d66fef8..3e58b86 100644 --- a/modules/archive/functions/unarchive +++ b/modules/archive/functions/unarchive @@ -41,7 +41,7 @@ else fi if (( $+commands[pixz] )); then - _xz_bin='pixz' + _xz_bin='pixz -d' else _xz_bin='xz' fi From ac1c39d2e1c730f76b0430915e05d349763ba2e1 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Wed, 30 Mar 2022 12:22:54 -0500 Subject: [PATCH 2/5] completion: Detect Homebrew prefix internally, not idiomatically For performance reasons, we prefer detecting Homebrew prefix internally instead of the more idiomatic form `brew --prefix`. We attempt looking up $HOMEBREW_PREFIX or $HOMEBREW_REPOSITORY first (in case `brew shellenv` has been sourced-in earlier). Else, we look it up by resolving absolute path of $HOMEBREW_REPOSITORY. $HOMEBREW_PREFIX is same as $HOMEBREW_REPOSITORY except when Homebrew is installed in '/usr/local' ($HOMEBREW_REPOSITORY == '/usr/local/Homebrew'). This is usually the case for Intel Macs. This should work for most standard (and officially documented) Homebrew installations. For implementation details in Homebrew, see: https://github.com/Homebrew/brew/blob/2a850e02d8f2dedcad7164c2f4b95d340a7200bb/bin/brew#L62-L70 Co-authored-by: mattmc3 --- modules/completion/init.zsh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index fc5cfd4..9ba9563 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -14,12 +14,16 @@ fi # Add zsh-completions to $fpath. fpath=(${0:h}/external/src $fpath) -# Add completion for keg-only brewed curl when available. -if (( $+commands[brew] )) \ - && [[ -d "${curl_prefix::="$(brew --prefix 2> /dev/null)"/opt/curl}" ]]; then - fpath=($curl_prefix/share/zsh/site-functions $fpath) +# Add completion for keg-only brewed curl on macOS when available. +if (( $+commands[brew] )); then + brew_prefix=${HOMEBREW_PREFIX:-${HOMEBREW_REPOSITORY:-$commands[brew]:A:h:h}} + # $HOMEBREW_PREFIX defaults to $HOMEBREW_REPOSITORY but is explicitly set to + # /usr/local when $HOMEBREW_REPOSITORY is /usr/local/Homebrew. + # https://github.com/Homebrew/brew/blob/2a850e02d8f2dedcad7164c2f4b95d340a7200bb/bin/brew#L66-L69 + [[ $brew_prefix == '/usr/local/Homebrew' ]] && brew_prefix=$brew_prefix:h + fpath=($brew_prefix/opt/curl/share/zsh/site-functions(/N) $fpath) + unset brew_prefix fi -unset curl_prefix # # Options From c857e809c3aca796ec1dc35a01d5b2c0ae535b90 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Fri, 1 Apr 2022 10:51:37 -0500 Subject: [PATCH 3/5] command-not-found: Detect Homebrew repo internally, not idiomatically For performance reasons, we prefer detecting Homebrew prefix internally instead of the more idiomatic form `brew --repository`. We attempt looking up $HOMEBREW_REPOSITORY first (in case `brew shellenv` has been sourced-in earlier). Else, we look it up by resolving absolute path of $HOMEBREW_REPOSITORY. This should work for most standard (and officially documented) Homebrew installations. --- modules/command-not-found/init.zsh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/command-not-found/init.zsh b/modules/command-not-found/init.zsh index d81692d..cf8f64e 100644 --- a/modules/command-not-found/init.zsh +++ b/modules/command-not-found/init.zsh @@ -7,14 +7,14 @@ # # Load command-not-found on Debian-based distributions. -if [[ -s '/etc/zsh_command_not_found' ]]; then - source '/etc/zsh_command_not_found' +if [[ -s /etc/zsh_command_not_found ]]; then + source /etc/zsh_command_not_found # Load command-not-found on Arch Linux-based distributions. -elif [[ -s '/usr/share/doc/pkgfile/command-not-found.zsh' ]]; then - source '/usr/share/doc/pkgfile/command-not-found.zsh' +elif [[ -s /usr/share/doc/pkgfile/command-not-found.zsh ]]; then + source /usr/share/doc/pkgfile/command-not-found.zsh # Load command-not-found on macOS when Homebrew tap is configured. elif (( $+commands[brew] )) \ - && [[ -s "${hb_cnf_handler::="$(brew --repository 2> /dev/null)"/Library/Taps/homebrew/homebrew-command-not-found/handler.sh}" ]]; then + && [[ -s ${hb_cnf_handler::="${HOMEBREW_REPOSITORY:-$commands[brew]:A:h:h}/Library/Taps/homebrew/homebrew-command-not-found/handler.sh"} ]]; then source "$hb_cnf_handler" unset hb_cnf_handler # Return if requirements are not found. From 3dc3fa7f8c484569a721724fa13c77cecd1dd923 Mon Sep 17 00:00:00 2001 From: Indrajit Raychaudhuri Date: Fri, 1 Apr 2022 15:40:01 -0500 Subject: [PATCH 4/5] zprofile: Expand the default list of well known paths Two additional sets of paths are now added to the default list of well known paths: '$HOME/{bin,sbin}' and '/opt/{homebrew,local}/{bin,sbin}'. - '$HOME/{bin,sbin}': Most users have custom scripts in '$HOME/bin' anyway, we might as well honor those. '$HOME/sbin' is not really common, but we can keep it for consistency. - '/opt/{homebrew,local}/{bin,sbin}': With Homebrew changing default installation location in macOS on Apple Silicon which will eventually become ubiquitous, we have a good reason to add these paths by default. While at it, we also honor MacPorts installation. In all cases, we add them _iff_ the paths actually exist, not otherwise. This has the side effect of a newly installed program not available immediately in the '$path' in a mint fresh system (because of the fact that '/opt/{homebrew,local}/{bin,sbin}' won't exist initially) until the shell is reloaded. But that's a minor inconvenience to keep the '$path' from getting unnecessarily bloated. --- runcoms/zprofile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runcoms/zprofile b/runcoms/zprofile index 5b8b638..d2acd31 100644 --- a/runcoms/zprofile +++ b/runcoms/zprofile @@ -49,7 +49,9 @@ typeset -gU cdpath fpath mailpath path # Set the list of directories that Zsh searches for programs. path=( - /usr/local/{bin,sbin} + $HOME/{,s}bin(N) + /opt/{homebrew,local}/{,s}bin(N) + /usr/local/{,s}bin(N) $path ) From dea85a0740253c0e17fa7eadb067694e11f5451c Mon Sep 17 00:00:00 2001 From: Shea690901 Date: Tue, 5 Apr 2022 20:46:49 +0200 Subject: [PATCH 5/5] feat(module/history): add full configurability While previusly configurable, it was inconsistent with other configuration options and it was missing configurability of in memory / on disc history size. Signed-off-by: Shea690901 --- modules/history/README.md | 29 +++++++++++++++++++++++++++++ modules/history/init.zsh | 10 +++++++--- runcoms/zpreztorc | 13 +++++++++++++ 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/modules/history/README.md b/modules/history/README.md index 3806096..25e429d 100644 --- a/modules/history/README.md +++ b/modules/history/README.md @@ -38,6 +38,35 @@ Alternately, you can set `HISTFILE` manually to _`${ZDOTDIR:-$HOME}/.zhistory`_. - `history-stat` lists the ten most used commands +## Settings + +### histfile + +Can be configured either by setting HISTFILE manually before loading this +module or by using zstyle: + +```sh +zstyle ':prezto:module:history' histfile "" +``` + +defaults to "${ZDOTDIR:-$HOME}/.zsh_history". + +## histsize + +```sh +zstyle ':prezto:module:history' histsize +``` + +defaults to 10000. + +## savehist + +```sh +zstyle ':prezto:module:history' savehist +``` + +defaults to histsize + ## Authors _The authors of this module should be contacted via the [issue tracker][2]._ diff --git a/modules/history/init.zsh b/modules/history/init.zsh index 3f815c0..1f9a09b 100644 --- a/modules/history/init.zsh +++ b/modules/history/init.zsh @@ -26,9 +26,13 @@ setopt HIST_BEEP # Beep when accessing non-existent history. # Variables # -HISTFILE="${HISTFILE:-${ZDOTDIR:-$HOME}/.zsh_history}" # The path to the history file. -HISTSIZE=10000 # The maximum number of events to save in the internal history. -SAVEHIST=10000 # The maximum number of events to save in the history file. +zstyle -s ':prezto:module:history' histfile '_pmh_histfile' || _pmh_histfile="${HISTFILE:-${ZDOTDIR:-$HOME}/.zsh_history}" +zstyle -s ':prezto:module:history' histsize '_pmh_histsize' || _pmh_histsize=10000 +zstyle -s ':prezto:module:history' savehist '_pmh_savehist' || _pmh_savehist=${_pmh_histsize} +HISTFILE="${_pmh_histfile}" # The path to the history file. +HISTSIZE="${_pmh_histsize}" # The maximum number of events to save in the internal history. +SAVEHIST="${_pmh_savehist}" # The maximum number of events to save in the history file. +unset _pmh_{hist{file,size},savehist} # # Aliases diff --git a/runcoms/zpreztorc b/runcoms/zpreztorc index cc6ebb4..ae68a89 100644 --- a/runcoms/zpreztorc +++ b/runcoms/zpreztorc @@ -83,6 +83,19 @@ zstyle ':prezto:module:editor' key-bindings 'emacs' # Set the command prefix on non-GNU systems. # zstyle ':prezto:module:gnu-utility' prefix 'g' +# +# History +# + +# Set the file to save the history in when an interactive shell exits. +# zstyle ':prezto:module:history' histfile "${ZDOTDIR:-$HOME}/.zsh_history" + +# Set the maximum number of events stored in the internal history list. +# zstyle ':prezto:module:history' histsize 10000 + +# Set the maximum number of history events to save in the history file. +# zstyle ':prezto:module:history' savehist 10000 + # # History Substring Search #