dotfiles/modules/common/shell/fzf.nix

46 lines
1.0 KiB
Nix
Raw Permalink Normal View History

2024-04-20 13:42:06 +00:00
{ config, pkgs, ... }:
{
2022-05-06 13:29:25 +00:00
2023-07-31 00:26:23 +00:00
# FZF is a fuzzy-finder for the terminal
2022-05-06 13:29:25 +00:00
home-manager.users.${config.user} = {
programs.fzf.enable = true;
programs.fish = {
functions = {
projects = {
description = "Jump to a project";
body = ''
2022-06-20 19:20:20 +00:00
set projdir ( \
fd \
2022-06-21 21:51:27 +00:00
--search-path $HOME/dev \
2022-06-20 19:20:20 +00:00
--type directory \
--exact-depth 2 \
2024-01-22 18:03:46 +00:00
| ${pkgs.proximity-sort}/bin/proximity-sort $PWD \
| sed 's/\\/$//' \
| fzf --tiebreak=index \
2022-06-27 01:53:08 +00:00
)
2022-06-20 19:49:25 +00:00
and cd $projdir
2022-05-06 13:29:25 +00:00
and commandline -f execute
'';
};
};
2024-04-20 13:42:06 +00:00
shellAbbrs = {
lsf = "ls -lh | fzf";
};
2022-05-06 13:29:25 +00:00
};
2022-05-29 17:44:45 +00:00
# Global fzf configuration
2024-04-20 13:42:06 +00:00
home.sessionVariables =
let
fzfCommand = "fd --type file";
in
{
FZF_DEFAULT_COMMAND = fzfCommand;
FZF_CTRL_T_COMMAND = fzfCommand;
FZF_DEFAULT_OPTS = "-m --height 50% --border";
};
2022-05-06 13:29:25 +00:00
};
}