Skip to content

Commit

Permalink
Save another 5ms off ZSH startup time, thanks @keegancsmith!
Browse files Browse the repository at this point in the history
BEFORE:

      φ for i in $(seq 0 10); do time /bin/zsh -i -c exit; done
      /bin/zsh -i -c exit  0.04s user 0.05s system 95% cpu 0.096 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.083 total
      /bin/zsh -i -c exit  0.04s user 0.05s system 96% cpu 0.093 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.085 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.085 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.085 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 96% cpu 0.086 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.083 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 96% cpu 0.083 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.083 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.083 total

AFTER:

      φ for i in $(seq 0 10); do time /bin/zsh -i -c exit; done
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.087 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.079 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.081 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.081 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.078 total
      /bin/zsh -i -c exit  0.04s user 0.04s system 95% cpu 0.079 total
  • Loading branch information
mrnugget committed Feb 24, 2021
1 parent 1b394c4 commit f3eabc7
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions zshrc
Expand Up @@ -5,8 +5,6 @@
typeset -U PATH
autoload colors; colors;

local machine_name=$(uname)

#############
## PRIVATE ##
#############
Expand Down Expand Up @@ -49,7 +47,8 @@ fi

# Speed up completion init, see: https://htr3n.github.io/2018/07/faster-zsh/
autoload -Uz compinit
if [ $machine_name != "Linux" ]; then

if [[ $OSTYPE = darwin* ]]; then
if [ $(date +'%j') != $(/usr/bin/stat -f '%Sm' -t '%j' ${ZDOTDIR:-$HOME}/.zcompdump) ]; then
compinit
else
Expand Down Expand Up @@ -143,10 +142,16 @@ bindkey '^E' end-of-line
# Aliases
#########

local aliasfile="${HOME}/.zsh.d/aliases.${machine_name}.sh"
if [ -e ${aliasfile} ]; then
source ${aliasfile}
fi
case $OSTYPE in
linux*)
local aliasfile="${HOME}/.zsh.d/aliases.Linux.sh"
[[ -e ${aliasfile} ]] && source ${aliasfile}
;;
darwin*)
local aliasfile="${HOME}/.zsh.d/aliases.Darwin.sh"
[[ -e ${aliasfile} ]] && source ${aliasfile}
;;
esac

if type exa &> /dev/null; then
alias ls=exa
Expand Down Expand Up @@ -364,10 +369,16 @@ else
export GIT_EDITOR='vim'
fi

local envfile="${HOME}/.zsh.d/env.${machine_name}.sh"
if [ -e ${envfile} ]; then
. ${envfile}
fi
case $OSTYPE in
linux*)
local envfile="${HOME}/.zsh.d/env.Linux.sh"
[[ -e ${envfile} ]] && source ${envfile}
;;
darwin*)
local envfile="${HOME}/.zsh.d/env.Darwin.sh"
[[ -e ${envfile} ]] && source ${envfile}
;;
esac

export LSCOLORS="Gxfxcxdxbxegedabagacad"

Expand Down

0 comments on commit f3eabc7

Please sign in to comment.