Hacker News new | ask | show | jobs
by thefilmore 53 days ago
You can just do:

  PATH=~/.local/bin:$PATH
PATH is already exported. Quotes are also not necessary for assignments.
2 comments

Looks dangerous to put a user writable directory ahead of system directories in PATH
Nah, it's totally normal because you often want to deliberately override or wrap system commands for various good and convenient reasons.

If your concern is that some hacker could put an illicit binary in ~/.local/bin, then your security problems are much deeper than your PATH order.

While we're all getting pedantic and esoteric, in zsh you can do this:

path+=(~/.local/bin)

You don't even have to use the "export" keyword. Not that I would do this, but since we're all pointing out random shell stuff...

(In zsh the lowercase "path" variable is an array that's automatically tied to the $PATH string, so you can just add to it using parens to signify new array elements, separated by a space.)