-
Notifications
You must be signed in to change notification settings - Fork 2
/
zshenv
80 lines (77 loc) · 1.97 KB
/
zshenv
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Important environment variables
## define utilities
get_var () {
eval 'printf "%s\n" "${'"$1"'}"'
}
set_var () {
eval "$1=\"\$2\""
}
dedup_var () {
var_name="$1"
var_value="$(get_var "$var_name")"
deduped_var="$(perl -e 'print join(":",grep { not $seen{$_}++ } split(/:/, $ARGV[0]))' "$var_value")"
set_var "$var_name" "$deduped_var"
}
add_to_var () {
var_name="$1"
var_value="$(get_var "$var_name")"
case ":$var_value:" in
*:"$2":*)
;;
*)
if [ "$3" = "after" ] ; then
new_var=$var_value:$2
else
new_var=$2:$var_value
fi
set_var "$var_name" "$new_var"
esac
}
## munge PATH
dedup_var PATH
add_to_var PATH "$HOME/.conda/envs/app/bin"
add_to_var PATH "$HOME/.cargo/bin"
add_to_var PATH "$HOME/.local/bin"
add_to_var PATH "$HOME/download/nvim-linux64/bin"
add_to_var PATH "$HOME/download/typos-vscode/target/release"
add_to_var PATH "$HOME/download/linux_binaries/xclip/bin" after
## munge LD_LIBRARY_PATH
dedup_var LD_LIBRARY_PATH
add_to_var LD_LIBRARY_PATH "$HOME/.conda/envs/app/lib" after
add_to_var LD_LIBRARY_PATH /usr/local/lib
add_to_var LD_LIBRARY_PATH /usr/local/lib64
# enable 256 color
if [ -n "$TMUX" ]; then
export TERM="tmux-256color"
else
export TERM="xterm-256color"
fi
## enable mouse in less
export LESS="--mouse --wheel-lines=3"
## define other useful variables
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/usr/local/include
export CPLUS_INCLUDE_PATH=$C_INCLUDE_PATH
## undef utilities
unset -f get_var set_var dedup_var add_to_var
# mkdir + cd
mcd () {
mkdir -p "$@" && cd "${@:$#}" || return 1
}
# vim -> nvim
vim () {
if (( $+commands[nvim] )); then
/usr/bin/env nvim "$@"
else
/usr/bin/env vim "$@"
fi
}
alias vi=vim
# Other configurations
## git editor
(( $+commands[nvim] )) && export EDITOR=nvim
## proxy server
#export ALL_PROXY=socks5://localhost:1080
## using ccache for cmake
export CMAKE_C_COMPILER_LAUNCHER=ccache
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export CMAKE_CUDA_COMPILER_LAUNCHER=ccache