From d943ab8b6dfaca331c2f4f717eb305f1a5a0909b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 4 Oct 2023 15:02:27 +0200 Subject: [PATCH] feat(tmux): various improvements --- modules/profiles/base.nix | 4 ++++ modules/programs/tmux/default.nix | 4 ++-- modules/programs/tmux/tmux-attach/script.fish | 2 +- .../programs/tmux/tmux-sessionizer/script.fish | 9 ++++++++- overlays/packages.nix | 15 --------------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index b0396ca..e5f4774 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -124,6 +124,10 @@ in "C-l" = "send-keys C-l"; "R" = "source-file $XDG_CONFIG_HOME/tmux/tmux.conf \\; display-message 'Reloaded tmux.conf'"; }; + root = { + "C-f" = "new-window ts"; + "C-a" = "new-window ta"; + }; copy-mode-vi = { "v" = "send -X begin-selection"; "V" = "send -X select-line"; diff --git a/modules/programs/tmux/default.nix b/modules/programs/tmux/default.nix index 6469f96..3f832e3 100644 --- a/modules/programs/tmux/default.nix +++ b/modules/programs/tmux/default.nix @@ -19,14 +19,14 @@ let tmux-sessionizer = pkgs.writeFishApplication { name = "ts"; - runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd fzf1 tmux-switch ]; + runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd tmux-switch ]; text = readFile ./tmux-sessionizer/script.fish; completions = readFile ./tmux-sessionizer/completions.fish; }; tmux-attach = pkgs.writeFishApplication { name = "ta"; - runtimeInputs = with pkgs; [ tmux fzf1 tmux-switch ]; + runtimeInputs = with pkgs; [ tmux tmux-switch ]; text = readFile ./tmux-attach/script.fish; completions = readFile ./tmux-attach/completions.fish; }; diff --git a/modules/programs/tmux/tmux-attach/script.fish b/modules/programs/tmux/tmux-attach/script.fish index 442dec2..1a4ddd6 100644 --- a/modules/programs/tmux/tmux-attach/script.fish +++ b/modules/programs/tmux/tmux-attach/script.fish @@ -1,4 +1,4 @@ -set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf1 $argv) +set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf $argv) if not test -n "$selected" exit 1 end diff --git a/modules/programs/tmux/tmux-sessionizer/script.fish b/modules/programs/tmux/tmux-sessionizer/script.fish index d0ca484..311ec4a 100644 --- a/modules/programs/tmux/tmux-sessionizer/script.fish +++ b/modules/programs/tmux/tmux-sessionizer/script.fish @@ -1,4 +1,11 @@ -set selected (fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf1 $argv) +set pipe (mktemp --dry-run) +mkfifo $pipe + +fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | tee $pipe >/dev/null & +fd . ~/ --min-depth 1 --max-depth 3 --type d | tee $pipe >/dev/null & + +set selected (cat $pipe | fzf $argv) +rm -f "$pipe" set selected_name (basename $selected 2>/dev/null | string replace "." "_") diff --git a/overlays/packages.nix b/overlays/packages.nix index be4efad..b4f2473 100644 --- a/overlays/packages.nix +++ b/overlays/packages.nix @@ -11,19 +11,4 @@ final: prev: }); timers = inputs.timers.packages.${prev.system}.default; hyprland = inputs.hyprland.packages.${prev.system}.default; - - fzf1 = final.writeShellApplication { - name = "fzf1"; - runtimeInputs = with final; [ coreutils fzf fd ]; - text = '' - #!/usr/bin/env bash - selected=$(fzf --query="$*" -1 < /dev/stdin) - - if [[ -z $selected ]]; then - exit 0 - fi - - echo "$selected" - ''; - }; }