Skip to content

zsh: plugins #55

@dermetfan

Description

@dermetfan

I recently extended the zsh module by a plugins option in my dotfiles:

programs.zsh.plugins = [
  {
    file = "zsh-256color.plugin.zsh";
    src = pkgs.fetchFromGitHub {
      owner = "chrissicool";
      repo = "zsh-256color";
      rev = "ae40a49ccfc7520d2d7b575aaea160ff876fe3dc";
      sha256 = "0c2yzbd4y0fyn9yycrxh32am27r0df0x3r526gf1pmyqiv49rg5z";
    };
  }
  {
    file = "fast-syntax-highlighting.plugin.zsh";
    src = pkgs.fetchFromGitHub {
      owner = "zdharma";
      repo = "fast-syntax-highlighting";
      rev = "5fab542516579bdea5cc8b94137d9d85a0c3fda5";
      sha256 = "1ff1z2snbl9rx3mrcjbamlvc21fh9l32zi2hh9vcgcwbjwn5kikg";
    };
  }
];

The result looks like this in .zshrc:

autoload -Uz compinit; compinit -iCd $HOME/.zcompdump
path+="/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src"
fpath+="/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src"
source "/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src/zsh-256color.plugin.zsh"
path+="/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src"
fpath+="/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src"
source "/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src/fast-syntax-highlighting.plugin.zsh"

I also tried this syntax but the order is not preserved. Maybe when toposort is implemented in #50 we can use it here:

programs.zsh.plugins = with pkgs; {
  "zsh-256color".src = fetchFromGitHub {
    owner = "chrissicool";
    repo = "zsh-256color";
    rev = "ae40a49ccfc7520d2d7b575aaea160ff876fe3dc";
    sha256 = "0c2yzbd4y0fyn9yycrxh32am27r0df0x3r526gf1pmyqiv49rg5z";
  };

  "fast-syntax-highlighting".src = fetchFromGitHub {
    owner = "zdharma";
    repo = "fast-syntax-highlighting";
    rev = "5fab542516579bdea5cc8b94137d9d85a0c3fda5";
    sha256 = "1ff1z2snbl9rx3mrcjbamlvc21fh9l32zi2hh9vcgcwbjwn5kikg";
  };
};

In an attempt to reduce my zsh startup time I switched from oh-my-zsh to antigen to zr but I could not bring it below ~0.95 sec. Using the plugins option I get a consistent 0.05 sec with the same plugins loaded. I'm not sure what the cause is (may be related to #54) but I like the simple approach.

Would this be a desirable feature for home-manager?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions