aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2023-11-15 22:55:09 +0800
committerGuangxiong Lin <[email protected]>2023-11-15 22:55:09 +0800
commit7de27509734330495fc54235283047c2e74ee8b3 (patch)
tree1f3a16af4e465c872172eea489e5491392d6dc8e
parentdc7e5a5f94cc89c57c4ff7f20f90a55a1a0e6ec4 (diff)
downloaddotfiles-7de27509734330495fc54235283047c2e74ee8b3.tar.gz
dotfiles-7de27509734330495fc54235283047c2e74ee8b3.tar.bz2
dotfiles-7de27509734330495fc54235283047c2e74ee8b3.zip
Refactor
-rwxr-xr-x.path5
-rw-r--r--.zinitrc14
-rw-r--r--.zshrc11
3 files changed, 19 insertions, 11 deletions
diff --git a/.path b/.path
index b9b5769..844df14 100755
--- a/.path
+++ b/.path
@@ -9,7 +9,10 @@ then
export PATH=$PATH:$(go env GOPATH)/bin
fi
-if gem env user_gemhome &> /dev/null; then
+# gem env is quite slow in macos.
+# Don't set the environment variables as mitigation.
+if [ ! $(uname) = Darwin ] &&
+ gem env user_gemhome &> /dev/null; then
export GEM_HOME="$(gem env user_gemhome)"
export PATH="$PATH:$GEM_HOME/bin"
fi
diff --git a/.zinitrc b/.zinitrc
index b853289..217855a 100644
--- a/.zinitrc
+++ b/.zinitrc
@@ -1,15 +1,17 @@
#!/usr/bin/env zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
-[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
-[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
+[ ! -d $ZINIT_HOME ] &&
+ mkdir -p "$(dirname $ZINIT_HOME)"
+[ ! -d $ZINIT_HOME/.git ] &&
+ git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
source "${ZINIT_HOME}/zinit.zsh"
-autoload -Uz _zinit
-(( ${+_comps} )) && _comps[zinit]=_zinit
-
-zinit wait lucid atload'_zsh_autosuggest_start' light-mode for zsh-users/zsh-autosuggestions
+zinit wait lucid atload'_zsh_autosuggest_start' \
+ light-mode for \
+ zsh-users/zsh-autosuggestions
+ZSH_AUTOSUGGEST_STRATEGY=(history completion)
zinit wait lucid light-mode for \
zsh-users/zsh-syntax-highlighting \
zsh-users/zsh-completions
diff --git a/.zshrc b/.zshrc
index 49de68e..c6182f4 100644
--- a/.zshrc
+++ b/.zshrc
@@ -1,5 +1,3 @@
-setopt histignorealldups sharehistory hist_ignore_space
-
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
@@ -21,6 +19,9 @@ source $HOME/.env
source $HOME/.aliases
source $HOME/.functions
+# If not running interactively, don't do anything
+[[ $- != *i* ]] && return
+
source "$HOME/.zinitrc"
[ -r $HOME/.nnnrc ] && source $HOME/.nnnrc
@@ -28,12 +29,14 @@ source "$HOME/.zinitrc"
command -v zoxide > /dev/null && eval "$(zoxide init --cmd j zsh)"
-if command -v direnv &> /dev/null; then
+if command -v direnv > /dev/null; then
eval "$(direnv hook zsh)"
fi
-if command -v navi &> /dev/null; then
+if command -v navi > /dev/null; then
eval "$(navi widget zsh)"
fi
+autoload -Uz compinit; compinit
+setopt histignorealldups sharehistory hist_ignore_space
[ -r $HOME/.zsh_local ] && source $HOME/.zsh_local