-
Notifications
You must be signed in to change notification settings - Fork 7
/
profile
executable file
·161 lines (143 loc) · 4.24 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/sh
# ~/.profile is read by the display manager on login.
export _SOURCED_PROFILE='yes'
export OS_TYPE
OS_TYPE="$(uname -s)"
# General config
export DOTFILES_HOME="/p/dots"
export DOTFILES_WORK="/p/dotsw"
if [ "$OS_TYPE" = 'Darwin' ]; then
DOTFILES_HOME="/opt${DOTFILES_HOME}"
DOTFILES_WORK="/opt${DOTFILES_WORK}"
fi
export XDG_CONFIG_HOME="${HOME}/.config"
export DISTRO_TYPE='unknown'
if [ -r /etc/debian_version ]; then
DISTRO_TYPE='debian'
elif [ -r /etc/arch-release ]; then
DISTRO_TYPE='arch'
fi
# Set terminal property (used by msgid-chooser).
export COLORTERM="yes"
export CLICOLOR=1
export PAGER=${PAGER:-less}
# Editors
export ALTERNATE_EDITOR="emacs"
export EDITOR="emacsclient -nw"
export VISUAL="emacsclient --alternate-editor=emacs"
export DOOMDIR="${DOTFILES_HOME}/doom"
# Go setup
export GOPATH='/go'
if [ "$OS_TYPE" = 'Darwin' ]; then
GOPATH='/opt/go'
fi
# Linux brew setup
if [ -d '/home/linuxbrew/.linuxbrew' ]; then
export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew";
export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar";
export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew";
export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}";
export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:";
export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}";
fi
# Ruby setup
GEM_HOME="$HOME/.gems"
if [ -d "$GEM_HOME" ]; then
export GEM_HOME
fi
ANDROID_SDK_ROOT=/d/android/sdk
if [ -d "$ANDROID_SDK_ROOT" ]; then
export ANDROID_SDK_ROOT
fi
# For zsh compatibility with bash.
if [ -z "$HOSTNAME" ]; then
export HOSTNAME=$HOST
fi
if [ "${OS_TYPE}" != 'Darwin' ]; then
if [ ! -d "${HOME}/.terminfo" ]; then
print "Adding xterm-24bit as terminal description."
/usr/bin/tic -x -o "${HOME}/.terminfo" "${DOTFILES_HOME}/terminfo/xterm-24bit.terminfo"
fi
export TERM=xterm-24bit
fi
# Set the NPM auth token if it exists.
npm_auth_token_file="$HOME/.config/npm/npm-auth-token"
if [ -f "$npm_auth_token_file" ]; then
NPM_AUTH_TOKEN="$(cat "${HOME}/.config/npm/npm-auth-token")"
export NPM_AUTH_TOKEN
fi
unset npm_auth_token_file
# Mac specific
if [ "${OS_TYPE}" = 'Darwin' ]; then
github_personal_token_file="$HOME/.config/github/personal-token"
if [ -f "$github_personal_token_file" ]; then
HOMEBREW_GITHUB_API_TOKEN="$(cat "${github_personal_token_file}")"
export HOMEBREW_GITHUB_API_TOKEN
fi
unset github_personal_token_file
fi
# prepend_to_path adds args the beginning of the path
# https://unix.stackexchange.com/a/4973/179300
prepend_to_path() {
for d; do
# canonicalize symbolic links
d=$({ cd -- "$d" && { pwd -P || pwd; }; } 2>/dev/null)
# skip nonexistent directory
if [ -z "$d" ]; then continue; fi
case ":$PATH:" in
# skip if path already in entry
*":$d:"*) : ;;
*) PATH=$d:$PATH ;;
esac
done
}
# List in reverse order so that the last entry has the highest priority.
prepend_to_path \
/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin \
"${HOME}/.pub-cache/bin" \
/snap/bin/ \
"/usr/share/texmf-dist/scripts/texlive" \
"/usr/local/bin" \
"${GEM_HOME}/bin" \
"/opt/homebrew/bin" \
"${HOME}/.yarn/bin" \
"${HOME}/.cargo/bin" \
'/d/node/bin' \
"${HOME}/.cask/bin" \
"${GOPATH}/bin" \
"${HOME}/.cargo/bin" \
"/d/go/bin" \
"${DOTFILES_HOME}/zsh/iosource" \
"${HOME}/bin" \
"${DOTFILES_HOME}/bin" \
"${DOTFILES_WORK}/bin"
unset -f prepend_to_path
# clean_path removes directories that don't exist and removes unused
# directories like /usr/local/games.
# https://stackoverflow.com/a/53223471/30900
clean_path() {
# IFS characters are stripped when using `read`
oldIFS="$IFS"
IFS=''
# Beware pipes. They imply subshells. The usual alternative is to use
# process substitution, but it won't work with dash, so I used file
# descriptor redirections instead.
#
# read -rd is safe with dash.
# shellcheck disable=SC2039
{
PATH="$(echo "$PATH" | {
P=""
while read -rd: dir; do
if [ "$dir" = '/usr/games' ] || [ "$dir" = '/usr/local/games' ]; then
continue
elif [ -d "$dir" ]; then
P="$P:$dir"
fi
done
echo "${P#?}"
})"
} 3>&1
IFS="$oldIFS"
}
clean_path && unset -f clean_path