diff --git a/functions/_append_path.fish b/functions/_append_path.fish index 7c7b54a..d917e65 100644 --- a/functions/_append_path.fish +++ b/functions/_append_path.fish @@ -1,6 +1,10 @@ # Appends the path to the specified path list. If no list specified, # defaults to $PATH function _append_path + set_color red + echo '_append_path function deprecated. Rename to _prepend_path.' + set_color normal + set -l path PATH if test (echo $argv | wc -w) -eq 2 diff --git a/functions/_prepend_path.fish b/functions/_prepend_path.fish new file mode 100644 index 0000000..4797108 --- /dev/null +++ b/functions/_prepend_path.fish @@ -0,0 +1,14 @@ +# Prepends the path to the specified path list. If no list specified, defaults to $PATH +function _prepend_path + set -l path PATH + + if test (echo $argv | wc -w) -eq 2 + set path $argv[2] + end + + if test -d $argv[1] + if not contains $argv[1] $$path + set $path $argv[1] $$path + end + end +end diff --git a/oh-my-fish.fish b/oh-my-fish.fish index 3686a1a..a15912e 100644 --- a/oh-my-fish.fish +++ b/oh-my-fish.fish @@ -6,16 +6,16 @@ function _fish_add_plugin set -l plugin $argv[1] set -l plugin_path "plugins/$plugin" - _append_path $fish_path/$plugin_path fish_function_path - _append_path $fish_custom/$plugin_path fish_function_path + _prepend_path $fish_path/$plugin_path fish_function_path + _prepend_path $fish_custom/$plugin_path fish_function_path end function _fish_add_completion set -l plugin $argv[1] set -l completion_path "plugins/$plugin/completions" - _append_path $fish_path/$completion_path fish_complete_path - _append_path $fish_custom/$completion_path fish_complete_path + _prepend_path $fish_path/$completion_path fish_complete_path + _prepend_path $fish_custom/$completion_path fish_complete_path end function _fish_source_plugin_load_file @@ -32,8 +32,8 @@ function _fish_source_plugin_load_file end function _fish_load_theme - _append_path $fish_path/themes/$fish_theme fish_function_path - _append_path $fish_custom/themes/$fish_theme fish_function_path + _prepend_path $fish_path/themes/$fish_theme fish_function_path + _prepend_path $fish_custom/themes/$fish_theme fish_function_path end ### diff --git a/plugins/android-sdk/android-sdk.load b/plugins/android-sdk/android-sdk.load index e8e11dc..633802e 100644 --- a/plugins/android-sdk/android-sdk.load +++ b/plugins/android-sdk/android-sdk.load @@ -1,7 +1,7 @@ if test -n "$ANDROID_SDK_ROOT" - _append_path $ANDROID_SDK_ROOT/tools - _append_path $ANDROID_SDK_ROOT/platform-tools + _prepend_path $ANDROID_SDK_ROOT/tools + _prepend_path $ANDROID_SDK_ROOT/platform-tools else - _append_path /opt/android-sdk/tools - _append_path /opt/android-sdk/platform-tools + _prepend_path /opt/android-sdk/tools + _prepend_path /opt/android-sdk/platform-tools end diff --git a/plugins/ccache/ccache.load b/plugins/ccache/ccache.load index ec22c18..38184d0 100644 --- a/plugins/ccache/ccache.load +++ b/plugins/ccache/ccache.load @@ -3,7 +3,7 @@ set -gx USE_CCACHE 1 if test -n "$CCACHE_ROOT" - _append_path $CCACHE_ROOT + _prepend_path $CCACHE_ROOT else - _append_path /usr/lib/ccache/bin + _prepend_path /usr/lib/ccache/bin end diff --git a/plugins/gem/gem.load b/plugins/gem/gem.load index d2a2878..9664478 100644 --- a/plugins/gem/gem.load +++ b/plugins/gem/gem.load @@ -1,4 +1,4 @@ if test -n "$GEM_ROOT" set -gx GEM_HOME $GEM_ROOT - _append_path $GEM_ROOT/bin + _prepend_path $GEM_ROOT/bin end diff --git a/plugins/gvm/gvm.load b/plugins/gvm/gvm.load index d5b5c82..db881e7 100644 --- a/plugins/gvm/gvm.load +++ b/plugins/gvm/gvm.load @@ -1,3 +1,3 @@ for gvm_path in (find $HOME/.gvm/*/current/bin -maxdepth 0) - _append_path $gvm_path -end \ No newline at end of file + _prepend_path $gvm_path +end diff --git a/plugins/ndenv/ndenv.load b/plugins/ndenv/ndenv.load index 697645c..cf3f478 100644 --- a/plugins/ndenv/ndenv.load +++ b/plugins/ndenv/ndenv.load @@ -1,7 +1,7 @@ if test -n "$NDENV_ROOT" - _append_path $NDENV_ROOT/bin - _append_path $NDENV_ROOT/shims + _prepend_path $NDENV_ROOT/bin + _prepend_path $NDENV_ROOT/shims else - _append_path $HOME/.ndenv/bin - _append_path $HOME/.ndenv/shims + _prepend_path $HOME/.ndenv/bin + _prepend_path $HOME/.ndenv/shims end diff --git a/plugins/node/node.load b/plugins/node/node.load index a72dec8..f934652 100644 --- a/plugins/node/node.load +++ b/plugins/node/node.load @@ -1,4 +1,4 @@ ### Main program -_append_path /usr/local/share/npm/bin +_prepend_path /usr/local/share/npm/bin set PATH ./node_modules/.bin $PATH diff --git a/plugins/nodenv/nodenv.load b/plugins/nodenv/nodenv.load index fdcd8f4..3203ae0 100644 --- a/plugins/nodenv/nodenv.load +++ b/plugins/nodenv/nodenv.load @@ -1,7 +1,7 @@ if test -n "$NODENV_ROOT" - _append_path $NODENV_ROOT/bin + _prepend_path $NODENV_ROOT/bin else - _append_path $HOME/.nodenv/bin + _prepend_path $HOME/.nodenv/bin end status --is-interactive; and source (nodenv init - | psub) diff --git a/plugins/plenv/plenv.load b/plugins/plenv/plenv.load index 107b6bf..42b202b 100644 --- a/plugins/plenv/plenv.load +++ b/plugins/plenv/plenv.load @@ -1,2 +1,2 @@ -_append_path $HOME/.plenv/bin -_append_path $HOME/.plenv/shims +_prepend_path $HOME/.plenv/bin +_prepend_path $HOME/.plenv/shims diff --git a/plugins/pyenv/pyenv.load b/plugins/pyenv/pyenv.load index 5d771f6..022d43f 100644 --- a/plugins/pyenv/pyenv.load +++ b/plugins/pyenv/pyenv.load @@ -1,7 +1,7 @@ if test -n "$PYENV_ROOT" - _append_path $PYENV_ROOT/bin - _append_path $PYENV_ROOT/shims + _prepend_path $PYENV_ROOT/bin + _prepend_path $PYENV_ROOT/shims else - _append_path $HOME/.pyenv/bin - _append_path $HOME/.pyenv/shims + _prepend_path $HOME/.pyenv/bin + _prepend_path $HOME/.pyenv/shims end diff --git a/plugins/rbenv/rbenv.load b/plugins/rbenv/rbenv.load index 7becc30..c907dc9 100644 --- a/plugins/rbenv/rbenv.load +++ b/plugins/rbenv/rbenv.load @@ -1,7 +1,7 @@ if test -n "$RBENV_ROOT" - _append_path $RBENV_ROOT/bin - _append_path $RBENV_ROOT/shims + _prepend_path $RBENV_ROOT/bin + _prepend_path $RBENV_ROOT/shims else - _append_path $HOME/.rbenv/bin - _append_path $HOME/.rbenv/shims + _prepend_path $HOME/.rbenv/bin + _prepend_path $HOME/.rbenv/shims end