Skip to content

Commit

Permalink
feat: add fzf-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
s3igo committed Oct 11, 2024
1 parent 10eae24 commit 0294c5a
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
4 changes: 3 additions & 1 deletion home/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ in
./helix.nix
./joshuto.nix
./fish.nix
./fzf-patch.nix
./starship.nix
./zsh.nix
./wezterm
Expand All @@ -38,7 +39,8 @@ in
fzf = {
enable = true;
changeDirWidgetCommand = "fd --type directory --hidden --follow --exclude .git";
changeDirWidgetOptions = [ "--preview 'ls -la {}'" ];
changeDirWidgetOptions = [ "--preview 'ls -la --color=always {}'" ];
fileWidgetCommand = ""; # To disable ctrl-t
defaultCommand = "fd --type file --hidden --follow --exclude .git";
};
jq.enable = true;
Expand Down
6 changes: 0 additions & 6 deletions home/fish.nix
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,5 @@ in
## functions
# bind \cg __ghq-fzf
'';
shellInitLast = ''
# disable the `fzf-file-widget` keybind and use <C-t> to `transpose-chars`
if status --is-interactive
bind --erase \ct
end
'';
};
}
37 changes: 37 additions & 0 deletions home/fzf-patch.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
args@{
config,
lib,
pkgs,
modulesPath,
inputs,
...
}:

let
inherit (lib) optional concatStringsSep getExe;
cfg = config.programs.fzf;

variablesToDisableKeyBindings =
let
ctrl-t = optional (cfg.fileWidgetCommand == "") "FZF_CTRL_T_COMMAND=";
alt-c = optional (cfg.changeDirWidgetCommand == "") "FZF_ALT_C_COMMAND=";
in
concatStringsSep " " (ctrl-t ++ alt-c);

prev = import (inputs.home-manager + "/modules/programs/fzf.nix") args;
in

lib.attrsets.recursiveUpdate prev {
disabledModules = [ "${modulesPath}/programs/fzf.nix" ];

options.programs.fzf.package.default = pkgs.fzf.overrideAttrs {
# Prevent shell integrations from installing automatically
postInstall = ''
installManPage man/man1/fzf.1
'';
};

config.content.programs.fish.interactiveShellInit.content = ''
${getExe cfg.package} --fish | ${variablesToDisableKeyBindings} source
'';
}
2 changes: 1 addition & 1 deletion modules/darwin/home-manager.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {
inherit user;
inherit user inputs;
inherit (inputs) self;
};
users.${user} = import ../../home;
Expand Down

0 comments on commit 0294c5a

Please sign in to comment.