aboutsummaryrefslogtreecommitdiff
path: root/modules/home-manager/zsh.nix
blob: 3e91058fcf95d57b26b39c226f8f785627f1cec4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{ config, lib, ... }:

{
  options.zsh.enable = lib.mkEnableOption "Configure zsh";
  config = lib.mkIf config.zsh.enable {
    programs.zsh = {
      enable = true;
      enableCompletion = true;
      autosuggestion.enable = true;
      syntaxHighlighting.enable = true;

      initContent = ''
        # view man pages with nvim
        export MANPAGER="nvim +Man!"

        # Directory completion with trailing slash
        zstyle ':completion:*' list-dirs-first true
        zstyle ':completion:*' special-dirs true
        zstyle ':completion:*' squeeze-slashes true
        zstyle ':completion:*' add-space false

        # Case-insensitive completion
        zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'

        # vim keybindings
        bindkey -v

        # imagemagick wrapper function to remove background
        remove_bg() {
          if [[ $# -lt 2 ]]; then
            echo 'Usage: remove_bg <input_file> <fuzz_percentage> [transparent_color] [output_file]'
            return 1
          fi

          local input_file=$1
          local fuzz=$2
          local transparent_color=$3
          local output_file=$4

					magick "$input_file" \
						-fuzz 12% -transparent "$transparent_color" \
						-alpha on -channel A -blur 0x2 -level 5%,100% +channel \
						"$output_file"

          echo "Saved transparent image to: $output_file"
        }

        eval "$(zoxide init zsh)"
      '';

      shellAliases = {
        ls = "ls --color=auto";
				nixceck = "nix flake check --all-systems";
      };

      zplug = {
        enable = true;
        plugins = [
          { name = "mafredri/zsh-async"; }
          { name = "sindresorhus/pure"; tags = [ "as:theme" "use:pure.zsh" ]; }
          { name = "zdharma-continuum/fast-syntax-highlighting"; }
          { name = "zsh-users/zsh-autosuggestions"; }
        ];
      };
    };
  };
}