Skip to content

Instantly share code, notes, and snippets.

@g0xA52A2A
Last active April 20, 2024 20:15
Show Gist options
  • Save g0xA52A2A/94d4d4fda53db8a5cb33d4f036b65818 to your computer and use it in GitHub Desktop.
Save g0xA52A2A/94d4d4fda53db8a5cb33d4f036b65818 to your computer and use it in GitHub Desktop.

Setup $PATH to prepend local installs and ensure all the usual system paths are present preserving preference order.

Born out of a hate of systems removing sbin directories from my $PATH (fuck you there is no a good reason to do this).

Also removes empty items in $PATH because I think blindly having CWD $PATH is insane.

export PATH=$(
    printf '%s:' ~/bin ~/.{cargo,ghc,go}/bin ${PATH} {,/usr,/usr/local}/{,s}bin |
        awk 'BEGIN {RS=":"} $0 && !seen[$0]++' |
        paste -s -d ':' -
)

hash -r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment