What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












105














The title says it all. I'm looking for guidelines on what one should and should not include in the various startup files for zsh.



I understand the order of sourcing of these files, and the conditions under which they are sourced, but it is still not clear to me what should go in each.










share|improve this question





















  • see zsh.sourceforge.net/Intro/intro_3.html
    – Alexej Magura
    Dec 5 '13 at 16:56















105














The title says it all. I'm looking for guidelines on what one should and should not include in the various startup files for zsh.



I understand the order of sourcing of these files, and the conditions under which they are sourced, but it is still not clear to me what should go in each.










share|improve this question





















  • see zsh.sourceforge.net/Intro/intro_3.html
    – Alexej Magura
    Dec 5 '13 at 16:56













105












105








105


68





The title says it all. I'm looking for guidelines on what one should and should not include in the various startup files for zsh.



I understand the order of sourcing of these files, and the conditions under which they are sourced, but it is still not clear to me what should go in each.










share|improve this question













The title says it all. I'm looking for guidelines on what one should and should not include in the various startup files for zsh.



I understand the order of sourcing of these files, and the conditions under which they are sourced, but it is still not clear to me what should go in each.







zsh startup






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 4 '13 at 23:42









kjo

4,04393763




4,04393763











  • see zsh.sourceforge.net/Intro/intro_3.html
    – Alexej Magura
    Dec 5 '13 at 16:56
















  • see zsh.sourceforge.net/Intro/intro_3.html
    – Alexej Magura
    Dec 5 '13 at 16:56















see zsh.sourceforge.net/Intro/intro_3.html
– Alexej Magura
Dec 5 '13 at 16:56




see zsh.sourceforge.net/Intro/intro_3.html
– Alexej Magura
Dec 5 '13 at 16:56










3 Answers
3






active

oldest

votes


















128














Here is a non-exclusive list of what each file tends to contain:



  • Since .zshenv is always sourced, it often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


  • .zshrc is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


  • .zlogin is sourced on the start of a login shell. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.


  • .zprofile is basically the same as .zlogin except that it's sourced directly before .zshrc is sourced instead of directly after it. According to the zsh documentation, ".zprofile is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."


  • .zlogout is sometimes used to clear and reset the terminal.

You should go through the configuration files of random Github users to get a better idea of what each file should contain.






share|improve this answer


















  • 3




    Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
    – Aaron
    Mar 31 '15 at 16:09






  • 7




    Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
    – Beau Barker
    Oct 6 '15 at 0:19










  • Where should $LANG and $LC_ALL go?
    – Lenar Hoyt
    Nov 24 '15 at 19:41






  • 16




    Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
    – Gabriel L.
    May 18 '16 at 20:48



















0














Don't put ssh-agent calls in .zshenv. It caused my less command to not display any text files anymore, probably because its options were customized by Prezto (export LESS='-F -g -i -M -R -S -w -X -z-4' in .zprofile).






share|improve this answer




























    0














    Here a list of what each file should/should'nt contain, in my opinion:



    .zshenv



    [Read everytime]



    It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or it's associative 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.



    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.



    .zprofile



    [Read at login]



    I personnaly treat that file like .zshenv but for commands and variables which should be set only one time or which don't need to be updated frequently:



    • environment variables to configure tools (flags for compilation, data folder location, etc.)

    • configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.

    If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:



    exec zsh --login


    .zshrc



    [Read when interactive]



    I put here everything needed only for interactive usage:



    • prompt,

    • command completion,

    • command correction,

    • command suggestion,

    • command highlighting,

    • output coloring,

    • aliases,

    • key bindings,

    • commands history management,

    • other miscellaneous interactive tools (auto_cd, manydots-magic)...

    .zlogin



    [Read at login]



    This file is like .zshprofile, but is read after .zshrc. So, I use it to launch interactive commands (like a login manager).



    .zlogout



    [Read at logout][Within login shell]



    Here, you can clear your terminal or any other resource setup at login.



    How I choose where to put a setting



    • it is needed by a command run non-interactively: .zshenv

    • it should be updated on new shell: .zshenv

    • it runs a command which may take some time to complete: .zprofile

    • it is related to interactive usage: .zprofile

    • it is command to be run when the shell is fully setup: .zlogin

    • it releases a resource acquired at login: .zlogout





    share|improve this answer




















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f71253%2fwhat-should-shouldnt-go-in-zshenv-zshrc-zlogin-zprofile-zlogout%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      128














      Here is a non-exclusive list of what each file tends to contain:



      • Since .zshenv is always sourced, it often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


      • .zshrc is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


      • .zlogin is sourced on the start of a login shell. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.


      • .zprofile is basically the same as .zlogin except that it's sourced directly before .zshrc is sourced instead of directly after it. According to the zsh documentation, ".zprofile is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."


      • .zlogout is sometimes used to clear and reset the terminal.

      You should go through the configuration files of random Github users to get a better idea of what each file should contain.






      share|improve this answer


















      • 3




        Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
        – Aaron
        Mar 31 '15 at 16:09






      • 7




        Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
        – Beau Barker
        Oct 6 '15 at 0:19










      • Where should $LANG and $LC_ALL go?
        – Lenar Hoyt
        Nov 24 '15 at 19:41






      • 16




        Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
        – Gabriel L.
        May 18 '16 at 20:48
















      128














      Here is a non-exclusive list of what each file tends to contain:



      • Since .zshenv is always sourced, it often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


      • .zshrc is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


      • .zlogin is sourced on the start of a login shell. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.


      • .zprofile is basically the same as .zlogin except that it's sourced directly before .zshrc is sourced instead of directly after it. According to the zsh documentation, ".zprofile is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."


      • .zlogout is sometimes used to clear and reset the terminal.

      You should go through the configuration files of random Github users to get a better idea of what each file should contain.






      share|improve this answer


















      • 3




        Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
        – Aaron
        Mar 31 '15 at 16:09






      • 7




        Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
        – Beau Barker
        Oct 6 '15 at 0:19










      • Where should $LANG and $LC_ALL go?
        – Lenar Hoyt
        Nov 24 '15 at 19:41






      • 16




        Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
        – Gabriel L.
        May 18 '16 at 20:48














      128












      128








      128






      Here is a non-exclusive list of what each file tends to contain:



      • Since .zshenv is always sourced, it often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


      • .zshrc is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


      • .zlogin is sourced on the start of a login shell. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.


      • .zprofile is basically the same as .zlogin except that it's sourced directly before .zshrc is sourced instead of directly after it. According to the zsh documentation, ".zprofile is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."


      • .zlogout is sometimes used to clear and reset the terminal.

      You should go through the configuration files of random Github users to get a better idea of what each file should contain.






      share|improve this answer














      Here is a non-exclusive list of what each file tends to contain:



      • Since .zshenv is always sourced, it often contains exported variables that should be available to other programs. For example, $PATH, $EDITOR, and $PAGER are often set in .zshenv. Also, you can set $ZDOTDIR in .zshenv to specify an alternative location for the rest of your zsh configuration.


      • .zshrc is for interactive shell configuration. You set options for the interactive shell there with the setopt and unsetopt commands. You can also load shell modules, set your history options, change your prompt, set up zle and completion, et cetera. You also set any variables that are only used in the interactive shell (e.g. $LS_COLORS).


      • .zlogin is sourced on the start of a login shell. This file is often used to start X using startx. Some systems start X on boot, so this file is not always very useful.


      • .zprofile is basically the same as .zlogin except that it's sourced directly before .zshrc is sourced instead of directly after it. According to the zsh documentation, ".zprofile is meant as an alternative to `.zlogin' for ksh fans; the two are not intended to be used together, although this could certainly be done if desired."


      • .zlogout is sometimes used to clear and reset the terminal.

      You should go through the configuration files of random Github users to get a better idea of what each file should contain.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Apr 5 '13 at 1:18

























      answered Apr 5 '13 at 1:12







      user26112














      • 3




        Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
        – Aaron
        Mar 31 '15 at 16:09






      • 7




        Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
        – Beau Barker
        Oct 6 '15 at 0:19










      • Where should $LANG and $LC_ALL go?
        – Lenar Hoyt
        Nov 24 '15 at 19:41






      • 16




        Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
        – Gabriel L.
        May 18 '16 at 20:48













      • 3




        Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
        – Aaron
        Mar 31 '15 at 16:09






      • 7




        Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
        – Beau Barker
        Oct 6 '15 at 0:19










      • Where should $LANG and $LC_ALL go?
        – Lenar Hoyt
        Nov 24 '15 at 19:41






      • 16




        Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
        – Gabriel L.
        May 18 '16 at 20:48








      3




      3




      Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
      – Aaron
      Mar 31 '15 at 16:09




      Just as a point of clarity, .zlogin is sourced after .zshrc (see man zshall for details).
      – Aaron
      Mar 31 '15 at 16:09




      7




      7




      Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
      – Beau Barker
      Oct 6 '15 at 0:19




      Be aware when setting $PATH in .zshenv, various other files all are sourced after this file that will override this value. See zsh.org/mla/users/2003/msg00600.html.
      – Beau Barker
      Oct 6 '15 at 0:19












      Where should $LANG and $LC_ALL go?
      – Lenar Hoyt
      Nov 24 '15 at 19:41




      Where should $LANG and $LC_ALL go?
      – Lenar Hoyt
      Nov 24 '15 at 19:41




      16




      16




      Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
      – Gabriel L.
      May 18 '16 at 20:48





      Just for my own notes / confirmation and to help anybody else, the ultimate order is .zshenv → [.zprofile if login] → [.zshrc if interactive] → [.zlogin if login] → [.zlogout sometimes].
      – Gabriel L.
      May 18 '16 at 20:48














      0














      Don't put ssh-agent calls in .zshenv. It caused my less command to not display any text files anymore, probably because its options were customized by Prezto (export LESS='-F -g -i -M -R -S -w -X -z-4' in .zprofile).






      share|improve this answer

























        0














        Don't put ssh-agent calls in .zshenv. It caused my less command to not display any text files anymore, probably because its options were customized by Prezto (export LESS='-F -g -i -M -R -S -w -X -z-4' in .zprofile).






        share|improve this answer























          0












          0








          0






          Don't put ssh-agent calls in .zshenv. It caused my less command to not display any text files anymore, probably because its options were customized by Prezto (export LESS='-F -g -i -M -R -S -w -X -z-4' in .zprofile).






          share|improve this answer












          Don't put ssh-agent calls in .zshenv. It caused my less command to not display any text files anymore, probably because its options were customized by Prezto (export LESS='-F -g -i -M -R -S -w -X -z-4' in .zprofile).







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 24 '16 at 7:16









          egpbos

          1091




          1091





















              0














              Here a list of what each file should/should'nt contain, in my opinion:



              .zshenv



              [Read everytime]



              It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or it's associative 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.



              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.



              .zprofile



              [Read at login]



              I personnaly treat that file like .zshenv but for commands and variables which should be set only one time or which don't need to be updated frequently:



              • environment variables to configure tools (flags for compilation, data folder location, etc.)

              • configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.

              If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:



              exec zsh --login


              .zshrc



              [Read when interactive]



              I put here everything needed only for interactive usage:



              • prompt,

              • command completion,

              • command correction,

              • command suggestion,

              • command highlighting,

              • output coloring,

              • aliases,

              • key bindings,

              • commands history management,

              • other miscellaneous interactive tools (auto_cd, manydots-magic)...

              .zlogin



              [Read at login]



              This file is like .zshprofile, but is read after .zshrc. So, I use it to launch interactive commands (like a login manager).



              .zlogout



              [Read at logout][Within login shell]



              Here, you can clear your terminal or any other resource setup at login.



              How I choose where to put a setting



              • it is needed by a command run non-interactively: .zshenv

              • it should be updated on new shell: .zshenv

              • it runs a command which may take some time to complete: .zprofile

              • it is related to interactive usage: .zprofile

              • it is command to be run when the shell is fully setup: .zlogin

              • it releases a resource acquired at login: .zlogout





              share|improve this answer

























                0














                Here a list of what each file should/should'nt contain, in my opinion:



                .zshenv



                [Read everytime]



                It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or it's associative 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.



                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.



                .zprofile



                [Read at login]



                I personnaly treat that file like .zshenv but for commands and variables which should be set only one time or which don't need to be updated frequently:



                • environment variables to configure tools (flags for compilation, data folder location, etc.)

                • configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.

                If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:



                exec zsh --login


                .zshrc



                [Read when interactive]



                I put here everything needed only for interactive usage:



                • prompt,

                • command completion,

                • command correction,

                • command suggestion,

                • command highlighting,

                • output coloring,

                • aliases,

                • key bindings,

                • commands history management,

                • other miscellaneous interactive tools (auto_cd, manydots-magic)...

                .zlogin



                [Read at login]



                This file is like .zshprofile, but is read after .zshrc. So, I use it to launch interactive commands (like a login manager).



                .zlogout



                [Read at logout][Within login shell]



                Here, you can clear your terminal or any other resource setup at login.



                How I choose where to put a setting



                • it is needed by a command run non-interactively: .zshenv

                • it should be updated on new shell: .zshenv

                • it runs a command which may take some time to complete: .zprofile

                • it is related to interactive usage: .zprofile

                • it is command to be run when the shell is fully setup: .zlogin

                • it releases a resource acquired at login: .zlogout





                share|improve this answer























                  0












                  0








                  0






                  Here a list of what each file should/should'nt contain, in my opinion:



                  .zshenv



                  [Read everytime]



                  It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or it's associative 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.



                  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.



                  .zprofile



                  [Read at login]



                  I personnaly treat that file like .zshenv but for commands and variables which should be set only one time or which don't need to be updated frequently:



                  • environment variables to configure tools (flags for compilation, data folder location, etc.)

                  • configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.

                  If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:



                  exec zsh --login


                  .zshrc



                  [Read when interactive]



                  I put here everything needed only for interactive usage:



                  • prompt,

                  • command completion,

                  • command correction,

                  • command suggestion,

                  • command highlighting,

                  • output coloring,

                  • aliases,

                  • key bindings,

                  • commands history management,

                  • other miscellaneous interactive tools (auto_cd, manydots-magic)...

                  .zlogin



                  [Read at login]



                  This file is like .zshprofile, but is read after .zshrc. So, I use it to launch interactive commands (like a login manager).



                  .zlogout



                  [Read at logout][Within login shell]



                  Here, you can clear your terminal or any other resource setup at login.



                  How I choose where to put a setting



                  • it is needed by a command run non-interactively: .zshenv

                  • it should be updated on new shell: .zshenv

                  • it runs a command which may take some time to complete: .zprofile

                  • it is related to interactive usage: .zprofile

                  • it is command to be run when the shell is fully setup: .zlogin

                  • it releases a resource acquired at login: .zlogout





                  share|improve this answer












                  Here a list of what each file should/should'nt contain, in my opinion:



                  .zshenv



                  [Read everytime]



                  It is always sourced, so it should set environment variables which need to be updated frequently. PATH (or it's associative 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.



                  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.



                  .zprofile



                  [Read at login]



                  I personnaly treat that file like .zshenv but for commands and variables which should be set only one time or which don't need to be updated frequently:



                  • environment variables to configure tools (flags for compilation, data folder location, etc.)

                  • configuration which execute commands (like SCONSFLAGS="--jobs=$(( $(nproc) - 1 ))") as it may take some time to execute.

                  If you modify that file, you can get the configuration updates by replacing the current shell with a new one as login shell:



                  exec zsh --login


                  .zshrc



                  [Read when interactive]



                  I put here everything needed only for interactive usage:



                  • prompt,

                  • command completion,

                  • command correction,

                  • command suggestion,

                  • command highlighting,

                  • output coloring,

                  • aliases,

                  • key bindings,

                  • commands history management,

                  • other miscellaneous interactive tools (auto_cd, manydots-magic)...

                  .zlogin



                  [Read at login]



                  This file is like .zshprofile, but is read after .zshrc. So, I use it to launch interactive commands (like a login manager).



                  .zlogout



                  [Read at logout][Within login shell]



                  Here, you can clear your terminal or any other resource setup at login.



                  How I choose where to put a setting



                  • it is needed by a command run non-interactively: .zshenv

                  • it should be updated on new shell: .zshenv

                  • it runs a command which may take some time to complete: .zprofile

                  • it is related to interactive usage: .zprofile

                  • it is command to be run when the shell is fully setup: .zlogin

                  • it releases a resource acquired at login: .zlogout






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 14 at 0:09









                  Damien Flament

                  1015




                  1015



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f71253%2fwhat-should-shouldnt-go-in-zshenv-zshrc-zlogin-zprofile-zlogout%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?