Show HN: Justpath – a simple utility to explore the PATH environment variable
1–10 of 29 posts
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#2Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#3Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#4Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#5 ### Setup PATH
dirs=(
/usr/lib/ccache/bin # ccache
~/.local/script ~/.local/bin # My local scripts.
~/.local/gobin # GOBIN
/usr/local/bin /usr/local/sbin # local takes precedence
/bin /sbin /usr/bin /usr/sbin # Standard Unix
/usr/pkg/bin /usr/pkg/sbin # NetBSD
/usr/X11R6/bin /usr/X11R6/sbin # OpenBSD
/opt/ooce/bin # illumos
~/.local/share/gem/ruby/*/bin(N[-1]) # Ruby
~/.luarocks/bin(N[-1]) # Lua
~/.local/dotnet/root ~/.local/dotnet/tools # .NET
/usr/lib/plan9/bin # Plan 9 from userspace
~/code/Vim/gopher.vim/tools/bin # gopher.vim
~/.nimble/bin # Nim
~/.cargo/bin # Rust
~/.ghcup/bin # Haskell
)
typeset -U path=() # No duplicates
# Use full path so /bin and /usr/bin aren't duplicated if it's a symlink.
for d in $dirs:A; [[ -d $d ]] && path+=($d)
unset dirs d
typeset -U makes the $path array "unique", and :A ensures the full path is always used (in case of symlinks).You can probably do something similar with bash, but idk.
$path is tied to $PATH and an array, so you can use it as such for some of the other things:
print ${(F)path} | grep /bin # (F) to print one array per line
print ${(F)path} | sort # can also use (o) to print orderedRe: Show HN: Justpath – a simple utility to explore the PATH environment variable
#6I’m struggling to understand the use case for this aside from just checking if your own directory is on the path.
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#7For zsh I use this to setup $PATH, which seems to address most of the use cases of this tool: ### Setup PATH dirs=( /usr/lib/ccache/bin # ccache ~/.local/script ~/.local/bin # My local scripts. ~/.local/gobin # GOBIN /usr/local/bin /usr/local/sbin # local takes precedence /bin /sbin /usr/bin /usr/sbin # Standard Unix /usr/pkg/bin /usr/pkg/sbin # NetBSD /usr/X11R6/bin /usr/X11R6/sbin # OpenBSD /opt/ooce/bin # illumos…
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#8- Use `~/.zprofile` to set the PATH and EDITOR environment variables. - Use `~/.zshrc` for aliases and a custom prompt, or anything tweaking the appearance and behavior of the terminal.
It seems the advantage of the `~/.zprofile` file versus `~/.zshenv` is that it sets environment variables such as `$PATH` without override from macOS. It seems the `~/.zshrc` file could be used for `$PATH` but, by convention and design, is intended for customizing the look and feel of the interactive terminal.
Frankly, saying `~/.zprofile` is better than `~/.zshrc` for setting `$PATH` only "by convention and design" feels like a cop-out. Wondering if anyone knows better.
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#9I’m struggling to understand the use case for this aside from just checking if your own directory is on the path.
https://systemweakness.com/linux-privilege-escalation-using-...