From e004081c5ac79ecbc6806f8cec7fe572da86aa7e Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 1 Apr 2022 23:30:25 +0200 Subject: [PATCH] Zsh: Use more shell builtins, load modules explicitly --- .config/zsh/.zprofile | 11 +++++++---- .config/zsh/.zshrc | 18 ++++++++++-------- .config/zsh/themes/prompt.zsh | 1 + .config/zsh/zaliases | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index fdb4814..844efd3 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -40,6 +40,9 @@ export ALTERNATE_EDITOR="$(command -v nano)" ############################# Plugins ########################################## +zmodload zsh/stat +zmodload zsh/datetime + if command -v fzf > /dev/null; then # Only load these plugins if fzf was found. local _depends_on_fzf="Aloxaf/fzf-tab" @@ -50,9 +53,9 @@ if command -v antibody > /dev/null; then export ZSH_PLUGIN_SOURCE="${plugin_cache_dir}/antibody-plugins.zsh" if [[ -f "${ZSH_PLUGIN_SOURCE}" ]] \ - && [[ $(stat --format="%s" "${ZSH_PLUGIN_SOURCE}") -ne 0 ]]; then - local _plugins_modified=$(stat --format="%Y" "${ZSH_PLUGIN_SOURCE}") - local _now=$(date '+%s') + && [[ $(zstat +size "${ZSH_PLUGIN_SOURCE}") -ne 0 ]]; then + local _plugins_modified=$(zstat +mtime "${ZSH_PLUGIN_SOURCE}") + local _now=$(strftime '%s') # Update plugins every 10 days if [[ $(( ${_now} - ${_plugins_modified} - 60 * 60 * 24 * 10)) -gt 0 ]]; then print "\e[3;95mUpdating plugins…\e[0m" @@ -171,7 +174,7 @@ export LS_COLORS unfunction _gen_lscolor # Host specific settings. -case $(hostname) in +case ${HOST} in schnibble | gaffer | localhost) export GIT_SSH_COMMAND="ssha" # Termux command for ssh with key-add. export CPATH="/data/data/com.termux/files/usr/local/include" diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index eb64bd2..d1ac039 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -5,11 +5,12 @@ function() # Keep local variables in here. ############################## Completion ###################################### -zmodload -i zsh/complist +zmodload zsh/complist autoload -Uz compinit && compinit -d "${ZSH_CACHE_DIR}/zcompdump" setopt ALWAYS_TO_END COMPLETE_IN_WORD GLOB_COMPLETE +zmodload zsh/zutil # Configure completions. zstyle ':completion:*' use-cache on zstyle ':completion::complete:*' cache-path "${ZSH_CACHE_DIR}/zcompcache" @@ -29,12 +30,6 @@ compdef '_dispatch git git' config # git completions for config. autoload -Uz +X bashcompinit && bashcompinit -# Directory options -setopt AUTO_CD AUTO_PUSHD PUSHD_IGNORE_DUPS PUSHD_MINUS - -# Various options -setopt CORRECT_ALL FLOW_CONTROL INTERACTIVE_COMMENTS LONG_LIST_JOBS - ############################# History ########################################## export HISTSIZE=50000 # In memory. export SAVEHIST=10000 # On disk. @@ -97,8 +92,15 @@ zstyle ':fzf-tab:complete:man:*' fzf-preview 'whatis -l $word | cut -d- -f2,3,4, ################################################################################ +# Directory options +setopt AUTO_CD AUTO_PUSHD PUSHD_IGNORE_DUPS PUSHD_MINUS +# Various options +setopt CORRECT_ALL FLOW_CONTROL INTERACTIVE_COMMENTS LONG_LIST_JOBS + +zmodload zsh/terminfo + # Test for the title setting capability (To Status Line) -if tput tsl > /dev/null; then +if echoti tsl > /dev/null; then # Write some info to terminal title. # This is seen when the shell prompts for input. function _my_title_precmd() { diff --git a/.config/zsh/themes/prompt.zsh b/.config/zsh/themes/prompt.zsh index 354af4a..e6e1967 100644 --- a/.config/zsh/themes/prompt.zsh +++ b/.config/zsh/themes/prompt.zsh @@ -22,6 +22,7 @@ if [[ "${USERNAME}" != "${DEFAULT_USER}" ]] && [[ -n "${USERNAME}" ]]; then fi autoload -Uz vcs_info +zmodload zsh/zutil zstyle ':vcs_info:*' enable git svn hg # vcs_info_printsys zstyle ':vcs_info:*' formats "%F{${zsh_theme_colours[vcs]}}(%b)%u%c%f " diff --git a/.config/zsh/zaliases b/.config/zsh/zaliases index f240a10..f1c2ffc 100644 --- a/.config/zsh/zaliases +++ b/.config/zsh/zaliases @@ -89,7 +89,7 @@ case $(lsb_release -i -s 2> /dev/null) in Gentoo) # Directory aliases for some Gentoo paths for dir in /etc/portage/package.*; do - hash -d -- -$(basename ${dir})=${dir} + hash -d -- -${dir##*/}=${dir} done # Directory aliases for all enabled repos