Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. .zshenv
  2. [Read every time]
  3.  
  4. It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or its associated counterpart path) is a good example because you probably don't want to restart your whole session to make it update. By setting it in that file, reopening a terminal emulator will start a new Zsh instance with the PATH value updated.
  5.  
  6. But be aware that this file is read even when Zsh is launched to run a single command (with the -c option), even by another tool like make. You should be very careful to not modify the default behavior of standard commands as it may break some tools which use them (by setting aliases for example). For sure, it is not forbidden as you know what you are doing.
  7.  
  8. .zprofile
  9. [Read at login]
  10.  
  11. I personally treat that file like .zshenv but for commands and variables which should be set once or which don't need to be updated frequently:
  12.  
  13. environment variables to configure tools (flags for compilation, data folder location, etc.)
  14. configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.
  15. If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:
  16.  
  17. exec zsh --login
  18. .zshrc
  19. [Read when interactive]
  20.  
  21. I put here everything needed only for interactive usage:
  22.  
  23. prompt,
  24. command completion,
  25. command correction,
  26. command suggestion,
  27. command highlighting,
  28. output coloring,
  29. aliases,
  30. key bindings,
  31. commands history management,
  32. other miscellaneous interactive tools (auto_cd, manydots-magic)...
  33. .zlogin
  34. [Read at login]
  35.  
  36. This file is like .zshprofile, but is read after .zshrc. I consider the shell to be fully set up at this time.
  37.  
  38. So, I use it to launch external commands which do not modify the shell behaviors (e.g. a login manager).
  39.  
  40. .zlogout
  41. [Read at logout][Within login shell]
  42.  
  43. Here, you can clear your terminal or any other resource setup at login.
  44.  
  45. How I choose where to put a setting
  46. it is needed by a command run non-interactively: .zshenv
  47. it should be updated on new shell: .zshenv
  48. it runs a command which may take some time to complete: .zprofile
  49. it is related to interactive usage: .zshrc
  50. it is a command to be run when the shell is fully setup: .zlogin
  51. it releases a resource acquired at login: .zlogout
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement