Show HN: Justpath – a simple utility to explore the PATH environment variable
11–20 of 29 posts
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#12I think for most of its use-cases, you could replace it with a one-liner: alias path='echo -e ${PATH//:/\\n} ' and work with it via sort and uniq. I've had this alias in my configuration for a couple of decades now, so I'm not bashing on its usefulness though.
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#13I'd like to hear viewpoints on using `~/.zprofile` versus `~/.zshrc` for setting `$PATH` on macOS. I was bothered for years that I didn't know the difference so I dived down the rabbit hole and wrote a guide [1]. In the end, I concluded: - 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 termin…
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#14I'd like to hear viewpoints on using `~/.zprofile` versus `~/.zshrc` for setting `$PATH` on macOS. I was bothered for years that I didn't know the difference so I dived down the rabbit hole and wrote a guide [1]. In the end, I concluded: - 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 termin…
In your guide, under ~/.zshenv, you mention that "macOS overrides this for PATH settings for interactive shells", without mentioning why or how. What's happening is that macOS sets your path in /etc/zprofile.
It seems your guide is missing a few global configfiles :) This is the order for an interactive login shell [1]:
/etc/zshenv
${ZDOTDIR:-$HOME}/.zshenv
/etc/zprofile (login)
${ZDOTDIR:-$HOME}/.zprofile (login)
/etc/zshrc (interactive)
${ZDOTDIR:-$HOME}/.zshrc (interactive)
/etc/zlogin (login)
${ZDOTDIR:-$HOME}/.zlogin (login)
/etc/zlogout (login - loaded on logout)
${ZDOTDIR:-$HOME}/.zlogout (login - loaded on logout)
In fact, the configfiles you mention are only loaded the way you've mentioned them, if the option GLOBAL_RCS is unset. And if GLOBAL_RCS is unset, macOS does not override your PATH, because/etc/zprofile is not loaded :)1: https://zsh.sourceforge.io/Doc/Release/Files.html>
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#15For 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
#16For 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…
I use 'path=( ${(u)^path:A}(N-/) )' instead of that for loop
PATH=$(perl -e 'print join ":", grep -d, split ":", $ENV{PATH}')
but that's because as a 20 year perl hacker and thus connoiseur of line noise, I'd rather read that than the shell clever.(this doesn't mean the shell clever is bad, it just means I don't find -that- dialect of line noise as skimmable)
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#17I'd like to hear viewpoints on using `~/.zprofile` versus `~/.zshrc` for setting `$PATH` on macOS. I was bothered for years that I didn't know the difference so I dived down the rabbit hole and wrote a guide [1]. In the end, I concluded: - 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 termin…
I set $PATH in ~/.zshenv. If you don't, you can't use any of your "extra stuff" in your zsh-scripts, as they do not use login or interactive sessions. And then I unset GLOBAL_RCS so the system configfiles don't override my settings. In your guide, under ~/.zshenv, you mention that "macOS overrides this for PATH settings for interactive shells", without mentioning why or how. What's happening is that macOS sets your p…
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#18Kinda pointless
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#19Kinda pointless
I like it! I do the steps involved in this occasionally, manually. It’s not hard but this makes it nice. Not sure I’ll use it since it is one more thing to install and remember, but the author had an itch and scratched it. Well done.
Re: Show HN: Justpath – a simple utility to explore the PATH environment variable
#20I’m struggling to understand the use case for this aside from just checking if your own directory is on the path.