dotfiles/zsh/zshrc

59 lines
1.2 KiB
Bash

#!/usr/bin/env zsh
ZSH_DOTFILES="${0:h}"
autoload -U colors && colors
# Performance {{{
zmodload zsh/datetime
typeset -A _perf_timers
_perf_timer_start() {
local name="$1"
if [[ -z "$name" ]]; then
print >&2 "$0: usage: $0 <name>"
return 1
fi
_perf_timers[$name]="$EPOCHREALTIME"
}
_perf_timer_stop() {
local name="$1"
if [[ -z "$name" ]]; then
print >&2 "$0: usage: $0 <name>"
return 1
fi
local stop_time="$EPOCHREALTIME" start_time="${_perf_timers[$name]}"
local -i duration="$(( (stop_time - start_time) * 1000 ))"
print -- "$(print -P '%F{8}==>%f') ${name}: ${duration}ms"
}
# }}}
_perf_timer_start "total"
# platform identification {{{
if [[ "$OSTYPE" == linux* ]]; then
_is_linux=1
if [[ "$OSTYPE" == linux-android ]]; then
_is_android=1
fi
fi
if [[ "$OSTYPE" == darwin* ]]; then
_is_macos=1
fi
# }}}
for script in functions options path env plugins aliases completion zle prompt colorscheme; do
_perf_timer_start "$script.zsh"
source "$ZSH_DOTFILES/$script.zsh"
_perf_timer_stop "$script.zsh"
done
command_exists rbenv && eval "$(rbenv init -)"
_perf_timer_stop "total"
welcome