From 0b7e18a3f599ff8e5dc463ee2452513c5a57e091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 26 Apr 2023 11:23:28 +0200 Subject: [PATCH] feat(tmux-sessionizer): fuzzy match input --- modules/programs/tmux.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix index e6ebf98..7d5677c 100644 --- a/modules/programs/tmux.nix +++ b/modules/programs/tmux.nix @@ -9,11 +9,15 @@ let runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ]; text = '' #!/usr/bin/env bash + + options=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf --filter "''$*") - if [[ $# -eq 1 ]]; then - selected=$1 + if [[ -z $options ]]; then + return 1 + elif [[ $(wc -l <<< "$options") -eq 1 ]]; then + selected="$options" else - selected=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf) + echo "$options" | fzf --query="$*" fi if [[ -z $selected ]]; then