From 80a448072d3efb1796ca9a347b6d2072e910d470 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 12:52:59 +1100 Subject: [PATCH 1/6] Disable magic-enter, it makes autosuggestions misbehave --- dot-config/zsh/zimrc.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/dot-config/zsh/zimrc.zsh b/dot-config/zsh/zimrc.zsh index 6cf6b27..5fd3c8f 100644 --- a/dot-config/zsh/zimrc.zsh +++ b/dot-config/zsh/zimrc.zsh @@ -5,7 +5,6 @@ zmodule mafredri/zsh-async --source async.zsh zmodule input zmodule run-help -zmodule magic-enter zmodule termtitle zmodule utility From 73ee5d18d6cdc2a0e99c8b5dbc091fdfb438b3cf Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 14:32:39 +1100 Subject: [PATCH 2/6] Add zeval for caching eval $() tools --- dot-config/zsh/zimrc.zsh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/dot-config/zsh/zimrc.zsh b/dot-config/zsh/zimrc.zsh index 5fd3c8f..c27a05e 100644 --- a/dot-config/zsh/zimrc.zsh +++ b/dot-config/zsh/zimrc.zsh @@ -1,3 +1,21 @@ +# Rather than writing eval "$(something init)" and having it called on every +# shell initialisation, zeval will use Zim's --on-pull hook to run the command +# once and cache the output, as well as zcompile it. Pass a descriptive, unique +# name as the first argument and the Zsh command you'd normally write inside +# $() as the second. For example, to hook Direnv into your shell: +# zeval direnv 'direnv hook zsh' +zeval() { + zmodule https://git.00dani.me/00dani/null --name zeval-$1 --on-pull "$2 >! init.zsh" +} + +# Hook a command into Zsh, only if that command is installed. Pass the +# command's name as the first argument and the commandline you want to evaluate +# as the second. Works in the same way as zeval, but silently omits the module +# from your setup if the necessary command is not installed. +zeval-if-installed() { + (( ${+commands[$1]} )) && zeval "$@" +} + zmodule willghatch/zsh-saneopt --source saneopt.plugin.zsh zmodule environment @@ -9,14 +27,15 @@ zmodule termtitle zmodule utility zmodule romkatv/powerlevel10k --use degit -zmodule ryanccn/vivid-zsh --cmd 'vivid_theme=molokai source {}/vivid-zsh.plugin.zsh' --on-pull '(( ${+commands[vivid]} )) && ./build.sh' +zeval-if-installed vivid 'echo export LS_COLORS=${(qqq)"$(vivid generate molokai)"}' zmodule hlissner/zsh-autopair zmodule mollifier/cd-gitroot --fpath . --autoload cd-gitroot -zmodule kiesman99/zim-zoxide zmodule zsh-users/zsh-autosuggestions (( ${+commands[brew]} )) && zmodule homebrew +zeval-if-installed direnv 'direnv hook zsh' +zeval-if-installed zoxide 'zoxide init zsh' # Additional completion definitions for Zsh. zmodule zsh-users/zsh-completions --fpath src @@ -26,3 +45,5 @@ zmodule completion # Fish-style syntax highlighting as you type, making the Zsh experience much more friendly! zmodule zdharma-continuum/fast-syntax-highlighting + +unfunction zeval zeval-if-installed From f726ccc185f1e23bc218b220e3a53ed0fa5f9c92 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 14:37:52 +1100 Subject: [PATCH 3/6] Remove hardcoded Direnv setup, since zeval can handle it --- dot-config/zsh/interactive/direnv | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 dot-config/zsh/interactive/direnv diff --git a/dot-config/zsh/interactive/direnv b/dot-config/zsh/interactive/direnv deleted file mode 100644 index ba862dc..0000000 --- a/dot-config/zsh/interactive/direnv +++ /dev/null @@ -1,12 +0,0 @@ -#! zsh -_direnv_hook() { - trap -- '' SIGINT - emulate zsh -c "$(direnv export zsh)" - trap - SIGINT -} - -typeset -ag precmd_functions chpwd_functions -if (( $+commands[direnv] )); then - [[ -z ${precmd_functions[(r)_direnv_hook]} ]] && precmd_functions+=(_direnv_hook) - [[ -z ${chpwd_functions[(r)_direnv_hook]} ]] && chpwd_functions+=(_direnv_hook) -fi From 7a3921ad91a2232f99af7167b6ba8e64eefa8e37 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 14:44:08 +1100 Subject: [PATCH 4/6] Skip manually loading Zoxide since zeval is doing it --- dot-config/zsh/interactive/z | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 dot-config/zsh/interactive/z diff --git a/dot-config/zsh/interactive/z b/dot-config/zsh/interactive/z deleted file mode 100644 index 351cea0..0000000 --- a/dot-config/zsh/interactive/z +++ /dev/null @@ -1,2 +0,0 @@ -#! zsh -eval "$(zoxide init zsh)" From 89e3f7f93ae99694d379b5c6bd1ac907e9a4d34a Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 14:45:12 +1100 Subject: [PATCH 5/6] Init Zoxide after compinit so its compdef works --- dot-config/zsh/zimrc.zsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dot-config/zsh/zimrc.zsh b/dot-config/zsh/zimrc.zsh index c27a05e..fb8db06 100644 --- a/dot-config/zsh/zimrc.zsh +++ b/dot-config/zsh/zimrc.zsh @@ -35,14 +35,16 @@ zmodule zsh-users/zsh-autosuggestions (( ${+commands[brew]} )) && zmodule homebrew zeval-if-installed direnv 'direnv hook zsh' -zeval-if-installed zoxide 'zoxide init zsh' # Additional completion definitions for Zsh. zmodule zsh-users/zsh-completions --fpath src # Enables and configures smart and extensive tab completion. -# completion *must* be sourced after all modules that add completion definitions. +# completion *must* be sourced after all modules that add completion definitions to fpath. zmodule completion +# Initialise Zoxide after compinit, because it calls compdef if available. +zeval-if-installed zoxide 'zoxide init zsh' + # Fish-style syntax highlighting as you type, making the Zsh experience much more friendly! zmodule zdharma-continuum/fast-syntax-highlighting From 651b4ae517ea4b6beab098153ec36a4d2a5f4b1e Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Tue, 21 Nov 2023 14:45:57 +1100 Subject: [PATCH 6/6] Enable scmpuff integration if installed --- dot-config/zsh/zimrc.zsh | 1 + 1 file changed, 1 insertion(+) diff --git a/dot-config/zsh/zimrc.zsh b/dot-config/zsh/zimrc.zsh index fb8db06..8467ac1 100644 --- a/dot-config/zsh/zimrc.zsh +++ b/dot-config/zsh/zimrc.zsh @@ -35,6 +35,7 @@ zmodule zsh-users/zsh-autosuggestions (( ${+commands[brew]} )) && zmodule homebrew zeval-if-installed direnv 'direnv hook zsh' +zeval-if-installed scmpuff 'scmpuff init --shell=zsh' # Additional completion definitions for Zsh. zmodule zsh-users/zsh-completions --fpath src