#!/bin/sh # This file is gonna be hell, we need to make sure that we don't duplicate # items on path. # This includes resolving symlinks at the /bin level for merged-usr systems. ## PATH UPDATE FUNCTION updatepath() { front=$1 new="$(realpath "$2" 2>/dev/null)" if [ ! -d "$new" ]; then return fi case ":${PATH:=$new}:" in *:"$new":*) ;; *) if [ "$front" -eq 1 ]; then PATH="$new:$PATH" else PATH="$PATH:$new" fi ;; esac } ## Use the function to make changes to path. ## ensure the base path is there updatepath 0 '/bin' updatepath 0 '/sbin' updatepath 0 '/usr/bin' updatepath 0 '/usr/sbin' updatepath 0 '/usr/local/bin' updatepath 0 '/usr/local/sbin' updatepath 0 '/snap/bin' # Because sometimes people use snap ## THIS MUST BE SOURCED AFTER XDG_SHENANIGANS FOR THIS TO WORK updatepath 0 "$GOPATH/bin" updatepath 0 "$GEM_HOME/bin" updatepath 1 "$HOME/perl5/bin" updatepath 0 "$DOTNET_ROOT/bin" updatepath 0 "$DOTNET_ROOT/tools" updatepath 0 "$CARGO_HOME/bin" updatepath 1 "${XDG_DATA_HOME}/neovim/bin" updatepath 0 "$HOME/.dotnet/tools" ## NOW WE ADD ~/.local/bin ## THIS IS SPECIAL SINCE IT ALLOWS FOR YOU ADD ALL SUB-DIRECTORIES TOO ## ALSO DIRECTLY MODIFIES PATH if [ -d "${HOME}/.local/bin" ]; then Local=$(find -L "$HOME"/.local/bin -type d -not -path '*/.git*' -printf "%p:") PATH="${Local}${PATH}" fi export PATH