about summary refs log tree commit diff
path: root/modules/programs/fish/fasd.nix
blob: ce00d32036bf8610422eb37c2e5ab0cb83b11122 (plain) (blame)
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
{ pkgs, config, lib, ... }:

with lib;

let cfg = config.vuizvui.programs.fish.fasd;
in

{
  options.vuizvui.programs.fish.fasd = {
    enable = mkEnableOption "fasd integration in fish";
  };

  config = mkIf cfg.enable {

    environment.systemPackages = [ pkgs.fasd ];

    programs.fish = {
      interactiveShellInit = let fasd = "${pkgs.fasd}/bin/fasd"; in ''
        function _run_fasd -e fish_preexec
          ${fasd} --proc (${fasd} --sanitize "$argv") > "/dev/null" 2>&1
        end
        function z --description "Jump to folder by usage frequency"
          cd (fasd -d -e 'printf %s' "$argv")
        end
        set PATH (dirname ${fasd}) $PATH
      '';
    };

  };
}