Zsh + async + zsh-snap #227
Replies: 2 comments
-
Well, I fixed it a bit like this, but I still haven't managed to activate the plugins properly. Click to expand# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# Download Znap, if it's not there yet.
[[ -f ~/Git/zsh-snap/znap.zsh ]] ||
git clone --depth 1 -- \
https://github.com/marlonrichert/zsh-snap.git ~/Git/zsh-snap
source ~/Git/zsh-snap/znap.zsh # Start Znap
znap source mafredri/zsh-async
autoload -Uz async && async
async_init
## history config
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=100000
setopt HIST_SAVE_BY_COPY
# Enable zsh-history-substring-search plugin
autoload -Uz history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
zle -N history-search-end-end history-search-end
zstyle ':zsh-history-substring-search:*' max-entries 1000
# Configure keybindings for history search
bindkey -v
bindkey '\e[A' history-beginning-search-backward
bindkey '\e[B' history-beginning-search-forward
async_start_worker active_prompt -n
# `znap prompt` makes your prompt visible in just 15-40ms!
async_job active_prompt znap prompt romkatv/powerlevel10k
# znap prompt sindresorhus/pure
async_start_worker source_plugins -n
# `znap source` automatically downloads and starts your plugins.
async_job source_plugins znap source supercrabtree/k
async_job source_plugins znap source marlonrichert/zsh-hist
async_job source_plugins znap source zsh-users/zsh-syntax-highlighting
async_job source_plugins znap source zsh-users/zsh-completions
# Async run zsh-autosuggestions
function zvm_after_init() {
ZSH_AUTOSUGGEST_STRATEGY=( history )
export ZSH_AUTO_SUGGEST_USE_ASYNC=true
}
async_job source_plugins znap source zsh-users/zsh-autosuggestions
async_job source_plugins znap source zsh-users/zsh-history-substring-search
async_job source_plugins znap source marlonrichert/zcolors
async_job source_plugins znap source djui/alias-tips
export ALIAS_TIPS_EXPAND=false
async_job source_plugins znap source ohmyzsh/ohmyzsh lib/completion
async_job source_plugins znap source ohmyzsh/ohmyzsh plugins/wd
async_job source_plugins znap source ohmyzsh/ohmyzsh plugins/git
async_job source_plugins znap source ohmyzsh/ohmyzsh plugins/fasd
async_job source_plugins znap source ohmyzsh/ohmyzsh plugins/colored-man-pages
async_job source_plugins znap source ohmyzsh/ohmyzsh plugins/virtualenvwrapper
async_start_worker eval_active -n
# `znap eval` caches and runs any kind of command output for you
async_job eval_active znap eval zcolors "zcolors ${(q)LS_COLORS}"
async_job eval_active znap eval pip-completion 'pip completion --zsh'
# `znap function` lets you lazy-load features you don't always need.
znap fpath _rustup 'rustup completions zsh'
znap fpath _cargo 'rustup completions zsh cargo'
# set default terminal text editor
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='vim'
else
export EDITOR='nvim'
fi
# aliases
alias vi='nvim'
alias refonts='sudo fc-cache -f -r -v'
alias softar='sudo pacman -Rn $(pacman -Qdtq)'
alias ar='sudo pacman -Rsn $(pacman -Qdtq)'
alias p='yay'
alias upgk="sudo mkinitcpio -P && sudo grub-mkconfig -o /boot/grub/grub.cfg"
alias AReboot='systemctl --user restart pipewire pipewire-pulse && systemctl --user daemon-reload'
alias DAReboot='killall Discord && ((discord &) &>/dev/null)'
alias reflectmirrors='reflector --verbose --latest 20 --age 12 --protocol https,rsync --sort rate --save /etc/pacman.d/mirrorlist && cat /etc/pacman.d/mirrorlist'
alias reboot='sudo reboot'
alias repack_arch='pacman -Qnq | sudo pacman -S - '
function mkcd
{
dir="$*";
mkdir -p "$dir" && cd "$dir";
}
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
typeset -g "POWERLEVEL9K_INSTANT_PROMPT=quiet"
|
Beta Was this translation helpful? Give feedback.
-
First of all, you do not need exec {fd}< <( ... ) like Second, asynchronous processes do not run in the main shell. They are subprocesses and those cannot affect the main shell directly. So, running your plugins asynchronously won't do a thing in your interactive shell. Thirdly, you do not need to do any of this. You are already using Powerlevel10k's instant prompt feature. Fourthly, doing |
Beta Was this translation helpful? Give feedback.
-
was trying to rewrite my zsh config processes for more speed (as well as optimization) using the
mafredri/zsh-async
plugin.Of course, my knowledge about this is limited, but I rewrote the config as follows:
Click to expand
Now there are problems (zsh-snap) does not activate any of the plugins, what is the reason for the problem?!
Beta Was this translation helpful? Give feedback.
All reactions