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