fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Mario Rodastreewide: remove marsam as maintainer (#4136)a4817894

master
2.1 KiB92 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.z-lua;
8
9  aliases = {
10    zz = "z -c"; # restrict matches to subdirs of $PWD
11    zi = "z -i"; # cd with interactive selection
12    zf = "z -I"; # use fzf to select in multiple matches
13    zb = "z -b"; # quickly cd to the parent directory
14    zh = "z -I -t ."; # fzf
15  };
16
17in {
18  meta.maintainers = [ ];
19
20  options.programs.z-lua = {
21    enable = mkEnableOption "z.lua";
22
23    options = mkOption {
24      type = types.listOf types.str;
25      default = [ ];
26      example = [ "enhanced" "once" "fzf" ];
27      description = ''
28        List of options to pass to z.lua.
29      '';
30    };
31
32    enableBashIntegration = mkOption {
33      default = true;
34      type = types.bool;
35      description = ''
36        Whether to enable Bash integration.
37      '';
38    };
39
40    enableZshIntegration = mkOption {
41      default = true;
42      type = types.bool;
43      description = ''
44        Whether to enable Zsh integration.
45      '';
46    };
47
48    enableFishIntegration = mkOption {
49      default = true;
50      type = types.bool;
51      description = ''
52        Whether to enable Fish integration.
53      '';
54    };
55
56    enableAliases = mkOption {
57      default = false;
58      type = types.bool;
59      description = ''
60        Whether to enable recommended z.lua aliases.
61      '';
62    };
63  };
64
65  config = mkIf cfg.enable {
66    home.packages = [ pkgs.z-lua ];
67
68    programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
69      eval "$(${pkgs.z-lua}/bin/z --init bash ${
70        concatStringsSep " " cfg.options
71      })"
72    '';
73
74    programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
75      eval "$(${pkgs.z-lua}/bin/z --init zsh ${
76        concatStringsSep " " cfg.options
77      })"
78    '';
79
80    programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
81      source (${pkgs.z-lua}/bin/z --init fish ${
82        concatStringsSep " " cfg.options
83      } | psub)
84    '';
85
86    programs.bash.shellAliases = mkIf cfg.enableAliases aliases;
87
88    programs.zsh.shellAliases = mkIf cfg.enableAliases aliases;
89
90    programs.fish.shellAliases = mkIf cfg.enableAliases aliases;
91  };
92}