Skip to content

Commit

Permalink
reinstate fzf over gum filter for:
Browse files Browse the repository at this point in the history
- shell integration
  - fuzzy completion on `cd <stuff>**` -> Tab
  - hotkeys
- file/folder previews
- working with enhancd (`cd`): https://codeberg.org/kiara/cfg/issues/130
- supporting pageup / pagedown: charmbracelet/gum#499
- actually allowing querying out of order
  - charmbracelet/gum#500
  - anyrun-org/anyrun#135
  • Loading branch information
KiaraGrouwstra committed Feb 25, 2024
1 parent 162976b commit 28ac8aa
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 12 deletions.
2 changes: 0 additions & 2 deletions home-manager/kiara/features/tools/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
];
};

fzf.enable = true;

# argument completer
carapace = {
enable = true;
Expand Down
46 changes: 46 additions & 0 deletions home-manager/kiara/fzf.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{pkgs, inputs, ...}:

with (import ./commands.nix {inherit pkgs inputs;});
{

programs.fzf = {
enable = true;
# https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh
enableZshIntegration = true;
# colors = {
# bg = "#000000";
# "bg+" = "#FF00FF";
# fg = "#FF00FF";
# "fg+" = "#000000";
# };
defaultOptions = [
"--sort"
"--height 100%"
"--border"
"--preview '${pistol} {}'"
];
# hotkeys: https://github.com/junegunn/fzf#key-bindings-for-command-line
# CTRL-T: take file
fileWidgetOptions = [
"--preview '${pistol} {}'"
];
# CTRL-R: redo
historyWidgetOptions = [
"--sort"
"--exact"
"--preview 'echo {}'"
"--preview-window up:3:hidden:wrap"
"--bind 'ctrl-/:toggle-preview'"
"--bind 'ctrl-y:execute-silent(echo -n {2..} | ${wl-copy})+abort'"
"--color header:italic"
"--header 'Press CTRL-Y to copy command into clipboard'"
];
# ALT-C: cd
changeDirWidgetOptions = [
"--preview '${pistol} {}'"
];
};

home.sessionVariables.ENHANCD_FILTER = "${fzf} --preview '${pistol} {}'";

}
6 changes: 0 additions & 6 deletions home-manager/kiara/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
_JAVA_AWT_WM_NONREPARENTING = "1";
MOZ_ENABLE_WAYLAND = "1";
PAGER = "${gum} pager";
ENHANCD_FILTER = ''
${fzf} --preview '${eza} -al --tree --level 1 --group-directories-first --git-ignore
--header --git --no-user --no-time --no-filesize --no-permissions {}'
--preview-window right,50% --height 35% --reverse --ansi
:gum choose --no-limit
'';
};

# https://github.com/NixOS/nixpkgs/issues/245772#issuecomment-1675034089
Expand Down
1 change: 1 addition & 0 deletions home-manager/kiara/imports.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
./emacs.nix
./firefox.nix
./font.nix
./fzf.nix
./gammastep.nix
./git.nix
./gtk.nix
Expand Down
4 changes: 2 additions & 2 deletions home-manager/kiara/scripts/jit.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env -S nix shell nixpkgs#bash nixpkgs#nix nixpkgs#nix-index nixpkgs#gum github:Mic92/nix-index-database#default --command bash
#!/usr/bin/env -S nix shell nixpkgs#bash nixpkgs#nix nixpkgs#nix-index nixpkgs#fzf github:Mic92/nix-index-database#default --command bash
# https://discourse.nixos.org/t/nixpkgs-desktop/39781/6

set -euo pipefail

APPS=$(nix-locate --minimal --regex '/share/applications/.*\.desktop$' \
| sed 's/\.out$//;/(.*)/d' \
| sort -u)
SELECTION=$(gum filter --no-limit <<< "$APPS")
SELECTION=$(fzf --border --reverse --prompt='Demo Application: ' <<< "$APPS")
# tighten the sandbox to what you need
# $HOME is tmpfs to the app so it puts its trash into a trash can
# bwrap --dev-bind / / \
Expand Down
4 changes: 2 additions & 2 deletions home-manager/kiara/scripts/pick-character.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env -S nix shell nixpkgs#wl-clipboard nixpkgs#gum --command sh
cat $1 | gum filter | cut -d ' ' -f 1 | tr -d '\n' | wl-copy
#!/usr/bin/env -S nix shell nixpkgs#wl-clipboard nixpkgs#fzf --command sh
cat $1 | fzf | cut -d ' ' -f 1 | tr -d '\n' | wl-copy
3 changes: 3 additions & 0 deletions hosts/hammer/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ in {

services.gnome.gnome-keyring.enable = true; # flare-signal

# used by enhancd
programs.fzf.fuzzyCompletion = true;

environment.sessionVariables = {
# qt wayland: https://discourse.nixos.org/t/problem-with-qt-apps-styling/29450/8
QT_QPA_PLATFORM = "wayland";
Expand Down

0 comments on commit 28ac8aa

Please sign in to comment.