2020-11-19 19:16:17 +00:00
|
|
|
function _maybe_set --description "Either appends or prepends to a variable if the file or directory exists and isn't already present"
|
|
|
|
# Replicate some of the `set` args
|
|
|
|
argparse 'a/append' 'p/prepend' 'x/export' 'g/global' -- $argv
|
|
|
|
if [ (count $argv) -ne 2 ]
|
|
|
|
echo "_maybe_set Requires exactly two arguments"
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
set -l var_name "$argv[1]"
|
|
|
|
set -l existing_val (eval 'echo $'(echo $var_name))
|
|
|
|
set -l new_value "$argv[2]"
|
|
|
|
if not contains -- "$new_value" "$existing_val" ;and test -e "$new_value"
|
|
|
|
set $_flag_append $_flag_prepend $_flag_export $_flag_global $var_name $new_value
|
|
|
|
end
|
|
|
|
end
|
2015-06-05 19:16:12 +00:00
|
|
|
|
2020-11-19 19:16:17 +00:00
|
|
|
set det_os "unknown"
|
2015-06-05 19:16:12 +00:00
|
|
|
switch (uname)
|
|
|
|
case "Darwin"
|
|
|
|
set det_os "mac"
|
|
|
|
case "Linux"
|
|
|
|
set det_os "linux"
|
|
|
|
case '*'
|
|
|
|
set det_os "unknown"
|
|
|
|
end
|
|
|
|
|
|
|
|
# opt directory
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -p PATH /opt/local/sbin
|
|
|
|
_maybe_set -p PATH /opt/local/bin
|
2021-12-08 18:04:39 +00:00
|
|
|
if test -e "/opt/local/lib"
|
|
|
|
set -gx --append LDFLAGS "-L/opt/local/lib"
|
|
|
|
end
|
|
|
|
if test -e "/opt/local/include"
|
|
|
|
set -gx --append CFLAGS "-I/opt/local/include"
|
|
|
|
end
|
2015-06-13 00:34:49 +00:00
|
|
|
|
2020-11-19 19:16:17 +00:00
|
|
|
# Set python paths
|
|
|
|
if [ $det_os = "mac" ]
|
2015-06-13 00:34:49 +00:00
|
|
|
# Fix Python path on OSX to avoid considering System extras over newer versions
|
2019-10-29 01:15:00 +00:00
|
|
|
# Local
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -p PATH "$HOME/Library/Python/2.7/bin"
|
2023-01-26 00:01:15 +00:00
|
|
|
_maybe_set -p PATH "$HOME/Library/Python/3.8/bin"
|
2021-10-25 20:57:27 +00:00
|
|
|
_maybe_set -p PATH "$HOME/Library/Python/3.9/bin"
|
2023-01-26 00:01:15 +00:00
|
|
|
_maybe_set -p PATH "$HOME/Library/Python/3.10/bin"
|
2023-10-31 15:58:30 +00:00
|
|
|
_maybe_set -p PATH "$HOME/Library/Python/3.11/bin"
|
2019-11-14 01:23:15 +00:00
|
|
|
# set -gx PYTHONPATH $HOME/Library/Python/2.7/lib/python/site-packages:$PYTHONPATH
|
2019-10-29 01:15:00 +00:00
|
|
|
# Macports
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -a PATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin
|
2019-10-29 01:15:00 +00:00
|
|
|
# set -gx PYTHONPATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/lib $PYTHONPATH
|
|
|
|
# set -gx PYTHONPATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages /Library/Python/2.7/site-packages $PYTHONPATH
|
2015-06-05 19:16:12 +00:00
|
|
|
end
|
|
|
|
|
2019-10-29 01:15:40 +00:00
|
|
|
# NPM paths
|
2021-07-26 01:38:57 +00:00
|
|
|
if command -q npm
|
2020-02-21 18:57:11 +00:00
|
|
|
set npm_path "$HOME/.npm/bin"
|
|
|
|
if [ ! -d "$npm_path" ]
|
|
|
|
# It's more robust to use the subshell, but far slower
|
|
|
|
set npm_path (npm bin -g 2> /dev/null)
|
|
|
|
end
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -a PATH "$npm_path"
|
2019-10-29 01:15:40 +00:00
|
|
|
end
|
|
|
|
|
2021-12-15 02:06:30 +00:00
|
|
|
# Add luarocks paths
|
|
|
|
if command -q luarocks
|
|
|
|
eval (luarocks path | sed "s/export/set -gx/;s/=/ /")
|
|
|
|
_maybe_set -a PATH "$HOME/.luarocks/bin"
|
|
|
|
end
|
|
|
|
|
2020-11-19 19:16:17 +00:00
|
|
|
# Add rust cargo path
|
|
|
|
_maybe_set -p PATH "$HOME/.cargo/bin"
|
2018-02-02 01:11:41 +00:00
|
|
|
|
2018-08-04 02:14:41 +00:00
|
|
|
# Golang paths
|
|
|
|
set -gx GOPATH $HOME/workspace/go_path
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -p PATH "$GOPATH/bin"
|
2021-07-26 01:43:12 +00:00
|
|
|
_maybe_set -p PATH "/usr/local/go/bin"
|
2015-08-26 21:29:51 +00:00
|
|
|
|
2016-02-04 18:33:08 +00:00
|
|
|
# Android paths
|
2020-11-19 19:16:17 +00:00
|
|
|
if [ $det_os = "linux" ]
|
|
|
|
set -gx ANDROID_HOME "$HOME/workspace/adt-bundle-linux/sdk"
|
|
|
|
else if [ $det_os = "mac" ]
|
|
|
|
set -gx ANDROID_HOME "$HOME/workspace/android-sdk-macosx"
|
2017-03-23 22:42:54 +00:00
|
|
|
end
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -a PATH "$ANDROID_PATH/platform-tools"
|
|
|
|
_maybe_set -a PATH "$ANDROID_PATH/tools"
|
2015-06-05 19:16:12 +00:00
|
|
|
|
2017-11-16 18:22:02 +00:00
|
|
|
# Ruby paths
|
2019-06-12 18:06:33 +00:00
|
|
|
if type -q rbenv ; and status --is-interactive
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -a PATH "$HOME/.rbenv/shims"
|
2019-06-12 18:06:33 +00:00
|
|
|
else if [ -d "$HOME/.rvm" ]
|
2020-11-19 19:16:17 +00:00
|
|
|
_maybe_set -a PATH "$HOME/.rvm/bin"
|
2019-06-12 18:06:33 +00:00
|
|
|
source "$HOME/.rvm/scripts/extras/rvm.fish"
|
2017-11-16 18:22:02 +00:00
|
|
|
end
|
|
|
|
|
2020-11-19 19:16:17 +00:00
|
|
|
# Home paths to take final precedent
|
|
|
|
_maybe_set -p PATH "$HOME/.local/bin"
|
|
|
|
_maybe_set -p PATH "$HOME/bin"
|