Skip to content

Commit 6c900a1

Browse files
committed
Shave 150ms off ZSH startup time
1 parent b62eb30 commit 6c900a1

File tree

1 file changed

+39
-66
lines changed

1 file changed

+39
-66
lines changed

zshrc

+39-66
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,37 @@ fi
5555

5656
unsetopt menu_complete
5757
unsetopt flowcontrol
58-
setopt prompt_subst
5958
setopt auto_menu
6059
setopt complete_in_word
6160
setopt always_to_end
6261
setopt auto_pushd
63-
zmodload -i zsh/complist
64-
65-
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
66-
zstyle ':completion:*' list-colors ''
67-
zstyle ':completion:*' special-dirs true
68-
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
69-
zstyle ':completion::complete:*' use-cache 1
70-
zstyle ':completion::complete:*' cache-path $ZSH/cache/
71-
zstyle ':completion:*:*:*:*:*' menu select
72-
73-
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
74-
zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
75-
76-
# use /etc/hosts and known_hosts for hostname completion
77-
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
78-
[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
79-
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
80-
hosts=(
81-
"$_ssh_config[@]"
82-
"$_global_ssh_hosts[@]"
83-
"$_ssh_hosts[@]"
84-
"$_etc_hosts[@]"
85-
"$HOST"
86-
localhost
87-
)
88-
zstyle ':completion:*:hosts' hosts $hosts
89-
zstyle ':completion:*' users off
62+
# zmodload -i zsh/complist
63+
#
64+
# zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
65+
# zstyle ':completion:*' list-colors ''
66+
# zstyle ':completion:*' special-dirs true
67+
# zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
68+
# zstyle ':completion::complete:*' use-cache 1
69+
# zstyle ':completion::complete:*' cache-path $ZSH/cache/
70+
# zstyle ':completion:*:*:*:*:*' menu select
71+
#
72+
# zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
73+
# zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w"
74+
#
75+
# # use /etc/hosts and known_hosts for hostname completion
76+
# [ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
77+
# [ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
78+
# [ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
79+
# hosts=(
80+
# "$_ssh_config[@]"
81+
# "$_global_ssh_hosts[@]"
82+
# "$_ssh_hosts[@]"
83+
# "$_etc_hosts[@]"
84+
# "$HOST"
85+
# localhost
86+
# )
87+
# zstyle ':completion:*:hosts' hosts $hosts
88+
# zstyle ':completion:*' users off
9089

9190
###############
9291
# KEY BINDINGS
@@ -138,7 +137,8 @@ bindkey '^E' end-of-line
138137
# Aliases
139138
#########
140139

141-
local aliasfile="${HOME}/.zsh.d/aliases.`uname`.sh"
140+
local machine_name=$(uname)
141+
local aliasfile="${HOME}/.zsh.d/aliases.${machine_name}.sh"
142142
if [ -r ${aliasfile} ]; then
143143
source ${aliasfile}
144144
fi
@@ -241,6 +241,8 @@ s3() {
241241
# PROMPT
242242
#########
243243

244+
setopt prompt_subst
245+
244246
git_prompt_info() {
245247
local dirstatus=" OK"
246248
local dirty="%{$fg_bold[red]%} X%{$reset_color%}"
@@ -357,7 +359,7 @@ else
357359
export GIT_EDITOR='vim'
358360
fi
359361

360-
local envfile="${HOME}/.zsh.d/env.`uname`.sh"
362+
local envfile="${HOME}/.zsh.d/env.${machine_name}.sh"
361363
if [ -r ${envfile} ]; then
362364
. ${envfile}
363365
fi
@@ -372,22 +374,15 @@ export KEYTIMEOUT=1
372374
# homebrew
373375
export PATH="/usr/local/bin:$PATH"
374376

375-
# rbenv
376-
if which rbenv &> /dev/null; then
377-
export PATH="$HOME/.rbenv/bin:$PATH"
378-
eval "$(rbenv init - --no-rehash)"
379-
fi
380-
381377
# asdf
382-
if [ -f /usr/local/opt/asdf/asdf.sh ]; then
383-
source /usr/local/opt/asdf/asdf.sh
384-
fi
385-
378+
# if [ -f /usr/local/opt/asdf/asdf.sh ]; then
379+
# source /usr/local/opt/asdf/asdf.sh
380+
# fi
381+
#
386382
if [ -f ~/.asdf/asdf.sh ]; then
387383
source ~/.asdf/asdf.sh
388384
fi
389385

390-
391386
# Encoding problems with gem
392387
export LC_ALL=en_US.UTF-8
393388
export LANG=en_US.UTF-8
@@ -416,12 +411,12 @@ if [ -e /usr/local/opt/fzf/shell/completion.zsh ]; then
416411
fi
417412

418413
# fzf via local installation
419-
if [[ ! "$PATH" == */home/mrnugget/.fzf/bin* ]]; then
420-
export PATH="$PATH:/home/mrnugget/.fzf/bin"
414+
if [[ ! "$PATH" == *$HOME.fzf/bin* ]]; then
415+
export PATH="$PATH:$HOME/.fzf/bin"
421416
fi
422417
if [ -e ~/.fzf ]; then
423418
source ~/.fzf/shell/key-bindings.zsh
424-
source ~/.fzf/shell/completion.zsh
419+
# source ~/.fzf/shell/completion.zsh
425420
fi
426421

427422
if which fzf &> /dev/null && which rg &> /dev/null; then
@@ -431,25 +426,6 @@ if which fzf &> /dev/null && which rg &> /dev/null; then
431426
set_fzf_default_opts
432427
fi
433428

434-
# rust
435-
export PATH="$HOME/.cargo/bin:$PATH"
436-
if which rustc &> /dev/null; then
437-
export RUST_SRC_PATH="$(rustc --print sysroot)/lib/rustlib/src/rust/src"
438-
fi
439-
440-
# python
441-
if which pyenv &> /dev/null; then
442-
eval "$(pyenv init -)"
443-
export PATH="$HOME/.local/bin:$PATH"
444-
fi
445-
446-
# Deactive this until this is fixed: https://github.com/BurntSushi/ripgrep/issues/375
447-
if which rg &> /dev/null; then
448-
compdef -d rg
449-
alias gr='rg' # Because in Vim you `:gr[ep]`
450-
fi
451-
# export PATH="/usr/local/opt/curl/bin:$PATH"
452-
453429
# Try out `z`
454430
if [ -e /usr/local/etc/profile.d/z.sh ]; then
455431
source /usr/local/etc/profile.d/z.sh
@@ -462,9 +438,6 @@ if which bat &> /dev/null; then
462438
alias cat=bat
463439
fi
464440

465-
# opam configuration
466-
test -r $HOME/.opam/opam-init/init.zsh && . $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null || true
467-
468441
# Export my personal ~/bin as last one to have highest precedence
469442
export PATH="$HOME/bin:$PATH"
470443

0 commit comments

Comments
 (0)