Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zsh HISTFILE, HISTSIZE not set? #177

Closed
krey opened this issue Jan 12, 2018 · 5 comments
Closed

zsh HISTFILE, HISTSIZE not set? #177

krey opened this issue Jan 12, 2018 · 5 comments

Comments

@krey
Copy link

krey commented Jan 12, 2018

I don't know if this is an issue with home-manager or something bigger than that, but I'm not able to set my HISTSIZE by doing

programs.zsh.history.size = 10000;

or

programs.zsh.profileExtra = "HISTSIZE=10000";

since it's overwritten by /etc/zshrc.

The post that prompted it on reddit: https://www.reddit.com/r/NixOS/comments/7pt34f/how_to_stop_etczshrc_from_overwriting_histfile/

@uvNikita
Copy link
Collaborator

uvNikita commented Jan 12, 2018

Thanks for reporting the issue. I confirm that programs.zsh.history.size indeed doesn't change the HISTSIZE env variable when oh-my-zsh is enabled.

The reason is that $ZSH/oh-my-zsh.sh is sourced after .zshenv file where we set this variable. oh-my-sh sources all .zsh config files in its lib folder, including lib/history.zsh. There HISTSIZE is set to 10000 unconditionally.

I'll create PR in oh-my-zsh to add condition similar to HISTFILE. In the meantime, quickfix would be to add programs.zsh.initExtra = "HISTSIZE=10000"; to your config file since it adds lines after oh-m-zsh.sh sourcing.

@uvNikita
Copy link
Collaborator

Seems like this issue was already brought up in oh-my-zsh, but PR was reverted: ohmyzsh/ohmyzsh#3359. I guess we will have to fix it on our side.

uvNikita added a commit to uvNikita/home-manager that referenced this issue Jan 12, 2018
HISTSIZE has to be set before sourcing oh-my-zsh
since otherwise it will be overridden. Fixes nix-community#177.
@krey
Copy link
Author

krey commented Jan 12, 2018

Thanks for the speedy response, Nikita. I'm a little confused though, since I do not use oh-my-zsh.
Are you able to reproduce the issue in an environment without oh-my-zsh?

@uvNikita
Copy link
Collaborator

No, with oh-my-zsh disabled, HISTSIZE is set correctly for me.

Do you have programs.zsh.enable = true in your system configuration? If that's the case then, as you mentioned, and according to https://www-s.acm.illinois.edu/workshops/zsh/startup_files.html, /etc/zshrc will be read after ~/.zshenv and it will result in the same issue.

So it seems that it works for me with oh-my-zsh disabled because I only have users.users.myuser.shell = pkgs.zsh; in the system configuration and therefore don't have the default /etc/zshrc at all.

The proposed patch should fix your case too, but I see that we should do the same for SAVEHIST and HISTFILE variables since they are also defined in /etc/zshrc.

uvNikita added a commit to uvNikita/home-manager that referenced this issue Jan 12, 2018
HISTSIZE and HISTFILE have to be set in ~/.zshrc and before
sourcing oh-my-zsh since otherwise it will be overridden.
Fixes nix-community#177.
@krey
Copy link
Author

krey commented Jan 12, 2018

Thank you for the explanation and the fast fix.

uvNikita added a commit to uvNikita/home-manager that referenced this issue Jan 13, 2018
HISTSIZE and HISTFILE should be set in ~/.zshrc and before
sourcing oh-my-zsh since otherwise it will be overridden.
Fixes nix-community#177.
jeffkreeftmeijer pushed a commit to jeffkreeftmeijer/system that referenced this issue Mar 13, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer pushed a commit to jeffkreeftmeijer/system that referenced this issue Mar 13, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer pushed a commit to jeffkreeftmeijer/system that referenced this issue Mar 13, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer pushed a commit to jeffkreeftmeijer/system that referenced this issue Mar 13, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 15, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 15, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 15, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 16, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 16, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 18, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
jeffkreeftmeijer added a commit to jeffkreeftmeijer/system that referenced this issue Mar 22, 2023
Much like Nix's tmux defaults, the Home Manager's defaults for zsh
have a lot of configurations set by default:

    cat ~/.zshrc

    typeset -U path cdpath fpath manpath

    for profile in ${(z)NIX_PROFILES}; do
      fpath+=($profile/share/zsh/site-functions $profile/share/zsh/$ZSH_VERSION/functions $profile/share/zsh/vendor-completions)
    done

    HELPDIR="/nix/store/xkr4dr8zhi1r1k4x0w17hhprj62cjxw2-zsh-5.9/share/zsh/$ZSH_VERSION/help"

    # Oh-My-Zsh/Prezto calls compinit during initialization,
    # calling it twice causes slight start up slowdown
    # as all $fpath entries will be traversed again.
    autoload -U compinit && compinit

    # History options should be set in .zshrc and after oh-my-zsh sourcing.
    # See nix-community/home-manager#177.
    HISTSIZE="10000"
    SAVEHIST="10000"

    HISTFILE="$HOME/.zsh_history"
    mkdir -p "$(dirname "$HISTFILE")"

    setopt HIST_FCNTL_LOCK
    setopt HIST_IGNORE_DUPS
    setopt HIST_IGNORE_SPACE
    unsetopt HIST_EXPIRE_DUPS_FIRST
    setopt SHARE_HISTORY
    unsetopt EXTENDED_HISTORY

    # Aliases

    # Named Directory Hashes

I'm not too familiar with how Nix works, but I'd assume that the first
part is there to make sure Nix can properly function.

Then, the compinit line can be disabled by switching off
`enableCompletion`:

    programs.zsh = {
      enable = true;
      enableCompletion = false;
    };

Aside from that, there doesn't seem to be a way to turn the hisotry
settings off outside of overwriting their values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants