mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 00:36:31 +00:00
Use set -p and set -a for setting fish paths
This commit is contained in:
parent
ddabb854f5
commit
ef344dfb4d
@ -1,7 +1,11 @@
|
||||
set -gx fish_function_path "$fish_synced_dir/functions" $fish_function_path
|
||||
set -gx fish_complete_path "$fish_synced_dir/completions" $fish_complete_path
|
||||
if not contains -- "$fish_synced_dir/functions" $fish_function_path
|
||||
set -p fish_function_path "$fish_synced_dir/functions"
|
||||
end
|
||||
if not contains -- "$fish_synced_dir/completions" $fish_complete_path
|
||||
set -p fish_complete_path "$fish_synced_dir/completions"
|
||||
end
|
||||
|
||||
function source_synced --description "Sources file from synced dir as well as optional local file"
|
||||
function _source_synced --description "Sources file from synced dir as well as optional local file"
|
||||
# Sources a config file and corresponding local config file if it exists
|
||||
set -l shared_config "$fish_synced_dir/$argv[1].fish"
|
||||
set -l local_config "$fish_synced_dir/$argv[1].local.fish"
|
||||
@ -14,7 +18,7 @@ function source_synced --description "Sources file from synced dir as well as op
|
||||
end
|
||||
|
||||
if status --is-interactive
|
||||
source_synced 'init/alias'
|
||||
_source_synced 'init/alias'
|
||||
end
|
||||
source_synced 'init/paths'
|
||||
source_synced 'init/env'
|
||||
_source_synced 'init/paths'
|
||||
_source_synced 'init/env'
|
||||
|
@ -1,5 +1,19 @@
|
||||
set det_os "unknown"
|
||||
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
|
||||
|
||||
set det_os "unknown"
|
||||
switch (uname)
|
||||
case "Darwin"
|
||||
set det_os "mac"
|
||||
@ -10,21 +24,18 @@ switch (uname)
|
||||
end
|
||||
|
||||
# opt directory
|
||||
if [ -d /opt/local ]
|
||||
set -gx PATH /opt/local/bin /opt/local/sbin $PATH
|
||||
end
|
||||
|
||||
if [ $det_os = "linux" ]
|
||||
set android_sdk $HOME/workspace/adt-bundle-linux/sdk
|
||||
else if [ $det_os = "mac" ]
|
||||
set android_sdk $HOME/workspace/android-sdk-macosx
|
||||
_maybe_set -p PATH /opt/local/sbin
|
||||
_maybe_set -p PATH /opt/local/bin
|
||||
|
||||
# Set python paths
|
||||
if [ $det_os = "mac" ]
|
||||
# Fix Python path on OSX to avoid considering System extras over newer versions
|
||||
# Local
|
||||
set -gx PATH $HOME/Library/Python/3.7/bin $HOME/Library/Python/2.7/bin $PATH
|
||||
_maybe_set -p PATH "$HOME/Library/Python/2.7/bin"
|
||||
_maybe_set -p PATH "$HOME/Library/Python/3.7/bin"
|
||||
# set -gx PYTHONPATH $HOME/Library/Python/2.7/lib/python/site-packages:$PYTHONPATH
|
||||
# Macports
|
||||
set -gx PATH $PATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin
|
||||
_maybe_set -a PATH /opt/local/Library/Frameworks/Python.framework/Versions/Current/bin
|
||||
# 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
|
||||
end
|
||||
@ -36,41 +47,33 @@ if type -q npm
|
||||
# It's more robust to use the subshell, but far slower
|
||||
set npm_path (npm bin -g 2> /dev/null)
|
||||
end
|
||||
if [ -d "$npm_path" ]
|
||||
set -gx PATH $PATH $npm_path
|
||||
end
|
||||
_maybe_set -a PATH "$npm_path"
|
||||
end
|
||||
|
||||
# Add rust path
|
||||
if [ -d "$HOME/.cargo/bin" ]
|
||||
set -gx PATH $HOME/.cargo/bin $PATH
|
||||
end
|
||||
# Add rust cargo path
|
||||
_maybe_set -p PATH "$HOME/.cargo/bin"
|
||||
|
||||
# Golang paths
|
||||
set -gx GOPATH $HOME/workspace/go_path
|
||||
if [ -d "$GOPATH" ]
|
||||
set -gx PATH $GOPATH/bin $PATH
|
||||
end
|
||||
_maybe_set -p PATH "$GOPATH/bin"
|
||||
|
||||
# Android paths
|
||||
if [ -d "$android_sdk" ]
|
||||
set -gx ANDROID_HOME $android_sdk
|
||||
set -gx PATH $PATH $android_sdk/platform-tools $android_sdk/tools
|
||||
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"
|
||||
end
|
||||
_maybe_set -a PATH "$ANDROID_PATH/platform-tools"
|
||||
_maybe_set -a PATH "$ANDROID_PATH/tools"
|
||||
|
||||
# Ruby paths
|
||||
if type -q rbenv ; and status --is-interactive
|
||||
set -gx PATH $PATH $HOME/.rbenv/shims
|
||||
_maybe_set -a PATH "$HOME/.rbenv/shims"
|
||||
else if [ -d "$HOME/.rvm" ]
|
||||
set -gx PATH $PATH $HOME/.rvm/bin
|
||||
_maybe_set -a PATH "$HOME/.rvm/bin"
|
||||
source "$HOME/.rvm/scripts/extras/rvm.fish"
|
||||
end
|
||||
|
||||
# Home paths
|
||||
if [ -d "$HOME/.local/bin" ]
|
||||
set -gx PATH $HOME/.local/bin $PATH
|
||||
end
|
||||
|
||||
if [ -d "$HOME/bin" ]
|
||||
set -gx PATH $HOME/bin $PATH
|
||||
end
|
||||
# Home paths to take final precedent
|
||||
_maybe_set -p PATH "$HOME/.local/bin"
|
||||
_maybe_set -p PATH "$HOME/bin"
|
||||
|
Loading…
Reference in New Issue
Block a user