Skip to content

Commit

Permalink
fix: Do NOT load on WSL1 because of microsoft/WSL#2395
Browse files Browse the repository at this point in the history
* zdharma/fast-syntax-highlighting MUST load before zsh-users/zsh-autosuggestions or auto-complate will NOT work
+ Add `duf` for better `df`
  • Loading branch information
nobitagamer committed Oct 9, 2024
1 parent 8a43727 commit 0a862f9
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 9 deletions.
1 change: 1 addition & 0 deletions meta/configs/brew.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- direnv
- screen # 5.0 to support True Color
- byobu # screen + tmux
- duf # a better 'df' alternative, see https://freedium.cfd/https://blog.devops.dev/6-linux-utilities-you-should-install-right-now-75470963a021

- link:
~/.screenrc: apps/screen/screenrc
64 changes: 55 additions & 9 deletions shells/zsh/config/zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ for file in ${${config_files:#*/path.zsh}:#*/completion.zsh}; do
source "$file"
done

# !NOTE: use Calling compinit With Turbo Mode instead, see https://github.com/zdharma-continuum/zinit?tab=readme-ov-file#calling-compinit-with-turbo-mode
# autoload -Uz compinit
# typeset -i updated_at=$(date +'%j' -r ${ZDOTDIR:-$HOME}/.zcompdump 2>/dev/null || stat -f '%Sm' -t '%j' ${ZDOTDIR:-$HOME}/.zcompdump 2>/dev/null)
# if [ $(date +'%j') != $updated_at ]; then
Expand All @@ -45,10 +46,10 @@ done
# compinit -C -i
# fi

# load every completion after autocomplete loads
for file in ${(M)config_files:#*/completion.zsh}; do
source "$file"
done
# # load every completion after autocomplete loads
# for file in ${(M)config_files:#*/completion.zsh}; do
# source "$file"
# done

unset config_files updated_at

Expand Down Expand Up @@ -218,7 +219,6 @@ zinit wait lucid light-mode for \
OMZL::directories.zsh \
OMZL::grep.zsh \
OMZL::key-bindings.zsh \
atuinsh/atuin \
OMZP::fzf \
atload"
alias dcupb='docker-compose up --build'
Expand Down Expand Up @@ -251,11 +251,13 @@ zinit wait lucid light-mode for \
# IMPORTANT:
# These plugins should be loaded after ohmyzsh plugins

# !NOTE: zdharma/fast-syntax-highlighting MUST load before zsh-users/zsh-autosuggestions or auto-complate will not work
# See https://github.com/zdharma-continuum/fast-syntax-highlighting#zinit
zinit wait lucid for \
light-mode atinit"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20" atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
light-mode atinit"typeset -gA FAST_HIGHLIGHT; FAST_HIGHLIGHT[git-cmsg-len]=100; ZINIT[COMPINIT_OPTS]=-C; zpcompinit; zpcdreplay" \
zdharma/fast-syntax-highlighting \
light-mode atinit"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=20" atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions \
atpull"%atclone" atclone"_fix-omz-plugin" \
OMZP::colored-man-pages \
atpull"%atclone" atclone"_fix-omz-plugin" nocompile \
Expand Down Expand Up @@ -351,7 +353,9 @@ zinit wait lucid light-mode for \
if"[[ $+commands[go] ]]" OMZP::golang \
if"[[ $+commands[npm] ]]" OMZP::npm \
OMZP::urltools \
pick"zshrc" tcnksm/docker-alias
pick"zshrc" tcnksm/docker-alias \
if"[[ $+commands[atuin] ]] && [[ ! $(uname -r) =~ ^.*Microsoft$ ]]" atuinsh/atuin # !BUG: Do NOT load on WSL1 because of https://github.com/microsoft/WSL/issues/2395

# !BUG: svn: E160013: '/sorin-ionescu/prezto/trunk/modules/archive' path not found
# See https://github.blog/news-insights/product-news/sunsetting-subversion-support/
# zinit svn wait'!' for \
Expand All @@ -365,7 +369,7 @@ zinit wait lucid light-mode for \
# !NOTE: MUST reload using wait'!' at last for history to work? (ENTER any command also make history work)
# wait'!...', prompt is reset after load. Zsh can start 80% (i.e.: 5x) faster thanks to postponed loading.
zinit wait'!' silent light-mode for \
atpull"%atclone" atclone"_fix-pzt-module" \
atpull"%atclone" atclone"_fix-pzt-module" atload"unalias duf" \
PZTM::utility

# ###############################################################################
Expand Down Expand Up @@ -847,6 +851,48 @@ fi
debug_echo "Loading Mise for ZSH..."
eval "$(mise activate zsh)"

# See https://news.ycombinator.com/item?id=35249933
CUR_SHELL=zsh
atuin-setup() {
if ! which atuin &> /dev/null; then return 1; fi
bindkey '^E' _atuin_search_widget

export ATUIN_NOBIND="true"
eval "$(atuin init "$CUR_SHELL")"
fzf-atuin-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2>/dev/null

# local atuin_opts="--cmd-only --limit ${ATUIN_LIMIT:-5000}"
local atuin_opts="--cmd-only"
local fzf_opts=(
--height=${FZF_TMUX_HEIGHT:-80%}
--tac
"-n2..,.."
--tiebreak=index
"--query=${LBUFFER}"
"+m"
"--bind=ctrl-d:reload(atuin search $atuin_opts -c $PWD),ctrl-r:reload(atuin search $atuin_opts)"
)

selected=$(
eval "atuin search ${atuin_opts}" |
fzf "${fzf_opts[@]}"
)
local ret=$?
if [ -n "$selected" ]; then
# the += lets it insert at current pos instead of replacing
LBUFFER+="${selected}"
fi
zle reset-prompt
return $ret
}
zle -N fzf-atuin-history-widget
bindkey '^R' fzf-atuin-history-widget
}
# !BUG: atuin still throw `Error: error returned from database: (code: 4618) disk I/O error` on WSL1 because of https://github.com/microsoft/WSL/issues/2395
# atuin-setup

# Display message of the day
# run-parts /etc/update-motd.d 2>/dev/null

Expand Down

0 comments on commit 0a862f9

Please sign in to comment.