-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment
141 lines (126 loc) · 3.95 KB
/
environment
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
# syntax: bash
# vim: set filetype=sh:
#
# Environment
#
if uname -a | grep -q -s Microsoft ; then
WSL=$(uname -r) ; export WSL
fi
_sc_select_browser()
{
if [ -n "${BROWSER}" ] ; then
echo "${BROWSER}"
return
fi
if [ -x /usr/bin/open ] ; then
echo /usr/bin/open
elif [ -n "${DISPLAY}" ] ; then
if [ -n "${GNOME_DESKTOP_SESSION_ID}" -a -x /usr/bin/gnome-open ] ; then
echo /usr/bin/gnome-open
elif [ -x /usr/bin/x-www-browser ] ; then
echo /usr/bin/x-www-browser
elif [ -x /usr/bin/xdg-open ] ; then
echo /usr/bin/xdg-open
fi
fi
}
BROWSER=$(_sc_select_browser) ; export BROWSER
EDITOR='vim' ; export EDITOR
HISTCONTROL=ignoreboth ; export HISTCONTROL
LESS='-RXm' ; export LESS
MACHINE_THAT_GOES_PING=1 # illumos / Solaris — exporting would break scripts
SCM_EDITOR='viterm' ; export SCM_EDITOR
if echo "${BROWSER}" | grep -q -s '.vscode-server' ; then
VSCODE_PATH=$(echo "${BROWSER}" | sed -e 's!/helpers.*!/remote-cli!')
fi
_add_to_path_var()
{
local varname="$1"
local dirToAdd="$2"
if [ ! -d "${dirToAdd}" ] ; then
return 1
fi
eval local current=\$${varname}
local newvalue=""
if echo ":${current}:" | grep -q -s ":${dirToAdd}:" ; then
return 0
elif [ -n "${current}" ] ; then
newvalue="${dirToAdd}:${current}"
else
newvalue="${dirToAdd}"
fi
eval ${varname}=\"${newvalue}\"
return 0
}
add_to_path_var()
{
_add_to_path_var "$@" || true
return 0
}
add_to_path_var_and_export()
{
local varname="$1"
if _add_to_path_var "$@" ; then
export "${varname}"
fi
}
_extract_base_path()
{
case "$PATH" in
${HOME}/*)
return
;;
esac
# Use path_helper to reconstruct the default path from /etc/paths.d.
# The clearing of $PATH is important as path_helper will by default append
# the current contents of $PATH
eval $(env -u PATH /usr/libexec/path_helper -s)
}
fix_degenerate_macos_path()
{
# iTerm can end up with a degenerate path when started from Finder by a
# workflow or Automator action. This is because the script which starts
# iTerm runs as a login shell and /etc/profile will run
# /usr/libexec/path_helper which will move any user directories to the end
# of the path. There's a good explanation at:
# https://checkoway.net/musings/nix/#fixing-shell-integration
if [ "$(uname -s)" != "Darwin" ] ; then
return
fi
_extract_base_path
}
if [ -z "${CDPATH}" ] ; then
add_to_path_var CDPATH "/Users/Shared"
add_to_path_var CDPATH "${HOME}"
add_to_path_var CDPATH "${HOME}/repos"
add_to_path_var CDPATH "."
VIM_CDPATH="${CDPATH}" ; export VIM_CDPATH
fi
add_to_path_var MANPATH "$HOME/.local/share/man"
fix_degenerate_macos_path
add_to_path_var PATH "/usr/local/go/bin"
add_to_path_var PATH "/usr/local/opt/ruby/bin"
add_to_path_var PATH "/opt/homebrew/opt/ruby/bin"
if [ -n "$(which ruby)" ] ; then
add_to_path_var PATH "$(ruby -e 'puts Gem.bindir()' 2>/dev/null)"
fi
add_to_path_var PATH "/opt/homebrew/bin"
add_to_path_var PATH "/Applications/SCM.app/Contents/Resources/scm/bin"
add_to_path_var PATH "/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
add_to_path_var PATH "${HOME}/Applications/SCM.app/Contents/Resources/scm/bin"
add_to_path_var PATH "/Users/Shared/tools/scripts"
if [ -n "${VSCODE_PATH}" ] ; then
add_to_path_var PATH "${VSCODE_PATH}"
fi
add_to_path_var PATH "${HOME}/.local/bin"
add_to_path_var PATH "${HOME}/go/bin"
add_to_path_var PATH "${HOME}/dotfiles/bin"
add_to_path_var PATH "${HOME}/bin"
add_to_path_var_and_export PYTHONPATH /Users/Shared/tools/libs/python
add_to_path_var_and_export RUBYLIB /Users/Shared/tools/libs/ruby
# After $PATH has been set
if command -v code >/dev/null 2>&1 ; then
# Use vscode as the visual editor
GIT_EDITOR="code --wait" ; export GIT_EDITOR
SCM_EDITOR="code --wait --goto" # already exported
fi