{ config, pkgs, ... }:

{
  environment = {
    systemPackages = [ pkgs.zsh ];

    shells = [ pkgs.zsh ];
    pathsToLink = [ "/share/zsh" ];
  };
  
  # Otherwise the user won't appear on the GDM login screen
  programs.zsh.enable = true;

  home-manager.users."${config.system.singleUser}".programs.zsh = {
    enable = true;
    history.ignoreSpace = true;
    shellAliases = {
      ls = "ls --color=always";
      ".." = "cd ..";
      "..." = "cd ../../";
      dev = "cd $HOME/Development";
      home = "cd $HOME";
      reload = "$SHELL -l";
      gs = "git status";
      gd = "git diff";
      gds = "git diff --staged";
      c = "clear";
      suspend = "systemctl suspend";
    };
    initExtra = ''
      bindkey "^[[1;5C" forward-word
      bindkey "^[[1;5D" backward-word
      bindkey "\e[3~" delete-char
    '';
    history.share = true;
    plugins = [
      {
        name = "pure.zsh";
        file = "pure.zsh";
        src = pkgs.fetchFromGitHub {
          owner = "sindresorhus";
          repo = "pure";
          rev = "v1.17.0";
          sha256 = "0qfs7rvpyd8jb7x4ziqrkh0b6g9ldds8sn6qbqgrir80vdk90gpa";
        };
      }
      {
        name = "zsh-history-substring-search";
        src = pkgs.fetchFromGitHub {
          owner = "zsh-users";
          repo = "zsh-history-substring-search";
          rev = "0f80b8eb3368b46e5e573c1d91ae69eb095db3fb";
          sha256 = "0y8va5kc2ram38hbk2cibkk64ffrabfv1sh4xm7pjspsba9n5p1y";
        };
      }
      {
        name = "zsh-completions";
        src = pkgs.fetchFromGitHub {
          owner = "zsh-users";
          repo = "zsh-completions";
          rev = "d4511c23659381b56dec8be8c8553b7ff3dc5fd8";
          sha256 = "1y8wkmhgkkyfz91y1f8crh6cg912n87gmcchc8xhnwji11n1mqrq";
        };
      }
    ];
  };
}