-
Notifications
You must be signed in to change notification settings - Fork 9
/
profile
147 lines (131 loc) · 3.47 KB
/
profile
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
UNAME="$(uname)"
if [ "$UNAME" = 'Darwin' ]; then
# /usr/libexec/path_helper is problematic
# https://stackoverflow.com/a/48228223/3108885
# https://github.com/rbenv/rbenv/issues/369#issuecomment-36010083
if [ -f /etc/profile ]; then
PATH=""
source /etc/profile
fi
export LANG=en_US.UTF-8
fi
if [ -n "$ZSH_VERSION" ]; then
# Oh My Zsh sets custom LSCOLORS from lib/theme-and-appearance.zsh
# This is default LSCOLORS from the man page of ls
[ "$UNAME" = 'Darwin' ] && export LSCOLORS=exfxcxdxbxegedabagacad
fi
add_to_path_once() {
case ":$PATH:" in
*":$1:"*)
;;
*)
export PATH="$1:$PATH"
;;
esac
}
# Load Homebrew for macOS
if [ "$UNAME" = 'Darwin' ]; then
# macOS Intel
if [ -e /usr/local/bin/brew ]; then
eval $(/usr/local/bin/brew shellenv)
fi
# Apple silicon
if [ -d /opt/homebrew ]; then
eval $(/opt/homebrew/bin/brew shellenv)
fi
fi
# Load Linuxbrew
if [ -d "$HOME/.linuxbrew" ]; then
eval $("$HOME/.linuxbrew/bin/brew" shellenv)
elif [ -d "/home/linuxbrew/.linuxbrew" ]; then
eval $("/home/linuxbrew/.linuxbrew/bin/brew" shellenv)
fi
# Set PATH to include user's bin if it exists
if [ -d "$HOME/bin" ]; then
add_to_path_once "$HOME/bin"
fi
if [ -d "$HOME/.local/bin" ]; then
add_to_path_once "$HOME/.local/bin"
fi
# Load n
if command -v n >/dev/null; then
export N_PREFIX="$HOME/.n"
add_to_path_once "$N_PREFIX/bin"
elif [ -e "$HOME/.n" ]; then
export N_PREFIX="$HOME/.n"
add_to_path_once "$N_PREFIX/bin"
fi
# Set GOPATH for Go
if command -v go >/dev/null; then
[ ! -e "$HOME/.go" ] && mkdir "$HOME/.go"
export GOPATH="$HOME/.go"
case ":$PATH:" in
*":$GOPATH/bin:"*)
;;
*)
export PATH="$PATH:$GOPATH/bin"
;;
esac
fi
# Set PATH for Rust
if [ -d "$HOME/.cargo" ]; then
add_to_path_once "$HOME/.cargo/bin"
fi
# Load mise
if command -v mise >/dev/null; then
if [ -n "$BASH_VERSION" ]; then
eval "$(mise activate bash --shims)"
elif [ -n "$ZSH_VERSION" ]; then
eval "$(mise activate zsh --shims)"
fi
elif [ -e "$HOME/.local/bin/mise" ]; then
if [ -n "$BASH_VERSION" ]; then
eval "$("$HOME/.local/bin/mise" activate bash --shims)"
elif [ -n "$ZSH_VERSION" ]; then
eval "$("$HOME/.local/bin/mise" activate zsh --shims)"
fi
fi
# Load rbenv
if [ -e "$HOME/.rbenv" ]; then
add_to_path_once "$HOME/.rbenv/bin"
fi
# Load pyenv
if command -v pyenv >/dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
eval "$(pyenv init --path 2>/dev/null)"
elif [ -e "$HOME/.pyenv" ]; then
export PYENV_ROOT="$HOME/.pyenv"
add_to_path_once "$HOME/.pyenv/bin"
eval "$(pyenv init --path 2>/dev/null)"
fi
# Unset local functions and variables
unset -f add_to_path_once
unset UNAME
# WSL
# See https://github.com/microsoft/WSL/issues/423
if [ -e /proc/sys/kernel/osrelease ] && grep -q WSL /proc/sys/kernel/osrelease; then
export COLORTERM='truecolor'
fi
# Set VISUAL
if command -v vim >/dev/null; then
export VISUAL="$(command -v vim)"
fi
# if running bash
if [ -n "$BASH_VERSION" ]; then
# Homebrew shell completion
if command -v brew >/dev/null; then
BREW_PREFIX="$(brew --prefix)"
if [ -e "$BREW_PREFIX/etc/profile.d/bash_completion.sh" ]; then
source "$BREW_PREFIX/etc/profile.d/bash_completion.sh"
else
for COMPLETION in "$BREW_PREFIX/etc/bash_completion.d/"*; do
[ -e "$COMPLETION" ] && source "$COMPLETION"
done
fi
unset BREW_PREFIX
fi
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi