-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh-exports
39 lines (37 loc) · 1.4 KB
/
zsh-exports
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
lazy_load() {
# Act as a stub to another shell function/command. When first run, it will load the actual function/command then execute it.
# E.g. This made my zsh load 0.8 seconds faster by loading `nvm` when "nvm", "npm" or "node" is used for the first time
# $1: space separated list of alias to release after the first load
# $2: file to source
# $3: name of the command to run after it's loaded
# $4+: argv to be passed to $3
# $1.split(' ') using the s flag. In bash, this can be simply ($1) #http://unix.stackexchange.com/questions/28854/list-elements-with-spaces-in-zsh
# Single line won't work: local names=("${(@s: :)${1}}"). Due to http://stackoverflow.com/questions/14917501/local-arrays-in-zsh (zsh 5.0.8 (x86_64-apple-darwin15.0))
local -a names
if [[ -n "$ZSH_VERSION" ]]; then
names=("${(@s: :)${1}}")
else
names=($1)
fi
unalias "${names[@]}"
. $2
shift 2
$*
}
group_lazy_load() {
local script
script=$1
shift 1
for cmd in "$@"; do
alias $cmd="lazy_load \"$*\" $script $cmd"
done
}
export NVM_DIR=~/.nvm
group_lazy_load $HOME/.nvm/nvm.sh node npm nvm
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
export PYENV_ROOT="$HOME/.config/.pyenv/"
export PATH="$PYENV_ROOT/bin:$PATH"
# bun
export BUN_INSTALL="/home/mith/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"