a guest Jan 11th, 2019 193 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Notes about $PATH
  3. You are probably used to lines like these in your shell config:
  5. ```sh
  6. export PATH="/usr/local/opt/gettext/bin:$PATH"
  7. ```
  9. Now, `$PATH` can also be modified like this in fish. However, it would not be very idiomatic.
  11. ## Adding to $PATH–the fish way
  13. Fish has three excellent ideas:
  15. - "Lists" are a thing. No more `foo:bar:baz`.
  16. - Why not simply allow users to prepend to another variable instead of modifying the global $PATH.
  17. - Changing variables shouldn't be in your config. Persistency is done automatically.
  19. So. Instead of doing the `export` thing. Simply execute this in your terminal. I'm using `gettext` on MacOS as an example:
  21. ```fish
  22. ## Prepend a new bin folder.
  23. # * Separated by spaces as fish_user_paths is a list/array and fish can handle that
  24. # * -U (from `man set`): -U or --universal causes the specified shell variable to be given a universal scope. If this option is supplied, the variable will be shared between all the current user's fish instances on the current computer, and will be preserved across restarts of the shell.
  25. set -U fish_user_paths /usr/local/opt/gettext/bin $fish_user_paths
  26. ```
  28. If you are curious, you can verify that this has indeed been written to `~/.config/fish/fish_variables`
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!