{

  programs.fzf = {
    enable = true; # TODO: does this conflict with system-wide setup?

    # alt-c
    changeDirWidgetCommand = "fd --type d"; # respects .gitignore
    changeDirWidgetOptions = [ "--preview 'tree -C {} | head -200'" ];

    # ctrl-t
    # fileWidgetCommand = "fd . --type file"; # respects .gitignore
    fileWidgetCommand = "fd . | sort --ignore-case --general-numeric-sort"; # respects .gitignore
    fileWidgetOptions = [
      "--bind 'home:first'"
      "--bind 'end:last'"
      "--cycle"

      # https://man.archlinux.org/man/extra/fzf/fzf.1.en#PREVIEW_WINDOW
      # bat is installed in bat.nix
      # this goes into home.sessionVariables.FZF_CTRL_T_OPTS which goes into a 'export ""' statement, i.e. it will eval bash variables
      #"--preview 'head {}'"
      # "--preview 'bat {}'"
      # "--preview 'tail -n\\$FZF_PREVIEW_LINES {} | bat --file-name {} --paging never --style plain'"
      # "--preview 'bat {} --paging never --style plain' --preview-window follow"
      "--preview 'if [[ -f {} ]]; then tail -n\\$FZF_PREVIEW_LINES {} | bat --paging=never --style=plain --color=always --file-name {} ; elif [[ -e {}/.git ]]; then git -C {} status else file {} ; fi' --preview-window follow"

      # TODO: add viu to ^

      # https://github.com/junegunn/fzf/discussions/3363#discussioncomment-6419463
      "--bind 'ctrl-a:reload:eval \\$FZF_DEFAULT_COMMAND --no-ignore'"
    ];

    # ctrl-r
    #historyWidgetOptions = [ "--sort" "--exact" ];
  };

}
