diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 14b3916..518ae72 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -45,7 +45,7 @@ in mv = "mv -i"; cd = "z"; - f = ''fzf --multi --bind "enter:become($EDITOR {+})" --preview "bat --color=always --style=header,grid --line-range :500 {+}"''; + f = "fzf --multi --bind \"enter:become($EDITOR {+})\""; nixos-switch = nom-system-command "sudo nixos-rebuild switch --flake ~/.dotfiles"; nixos-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles"; @@ -154,7 +154,6 @@ in enable = true; defaultOptions = [ "--height 50%" - "--bind alt-j:preview-down,alt-k:preview-up" ]; }; zoxide.enable = true; diff --git a/modules/programs/tmux/default.nix b/modules/programs/tmux.nix similarity index 80% rename from modules/programs/tmux/default.nix rename to modules/programs/tmux.nix index c2c620c..32836bd 100644 --- a/modules/programs/tmux/default.nix +++ b/modules/programs/tmux.nix @@ -41,18 +41,32 @@ let ''; }; - tmux-sessionizer = pkgs.writeFishApplication { + tmux-sessionizer = pkgs.writeShellApplication { name = "ts"; - runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd fzf1 tmux-switch ]; - text = readFile ./tmux-sessionizer/script.fish; - completions = readFile ./tmux-sessionizer/completions.fish; + runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd fzf ]; + text = '' + #!/usr/bin/env bash + + selected=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | ${getExe fzf1} "$*") + + selected_name=$(basename "$selected" | tr . _) + + if ! tmux has-session -t="$selected_name" 2> /dev/null; then + tmux new-session -ds "$selected_name" -c "$selected" + fi + + ${getExe tmux-switch} "$selected_name" + ''; }; - tmux-attach = pkgs.writeFishApplication { + tmux-attach = pkgs.writeShellApplication { name = "ta"; - runtimeInputs = with pkgs; [ tmux fzf1 tmux-switch ]; - text = readFile ./tmux-attach/script.fish; - completions = readFile ./tmux-attach/completions.fish; + runtimeInputs = with pkgs; [ tmux ]; + text = '' + #!/usr/bin/env bash + selected=$(tmux list-sessions -F '#{session_name}' | ${getExe fzf1} "$*") + ${getExe tmux-switch} "$selected" + ''; }; in diff --git a/modules/programs/tmux/tmux-attach/completions.fish b/modules/programs/tmux/tmux-attach/completions.fish deleted file mode 100644 index 6e31f9f..0000000 --- a/modules/programs/tmux/tmux-attach/completions.fish +++ /dev/null @@ -1 +0,0 @@ -complete -c ta -f -a '(tmux list-sessions -F "#{session_name}" 2>/dev/null)' diff --git a/modules/programs/tmux/tmux-attach/script.fish b/modules/programs/tmux/tmux-attach/script.fish deleted file mode 100644 index 442dec2..0000000 --- a/modules/programs/tmux/tmux-attach/script.fish +++ /dev/null @@ -1,5 +0,0 @@ -set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf1 $argv) -if not test -n "$selected" - exit 1 -end -tmux-switch "$selected" diff --git a/modules/programs/tmux/tmux-sessionizer/completions.fish b/modules/programs/tmux/tmux-sessionizer/completions.fish deleted file mode 100644 index f48642c..0000000 --- a/modules/programs/tmux/tmux-sessionizer/completions.fish +++ /dev/null @@ -1 +0,0 @@ -complete -c ts -f -a '(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec realpath "{}/.." | xargs -I{} basename {} | string replace "." "")' diff --git a/modules/programs/tmux/tmux-sessionizer/script.fish b/modules/programs/tmux/tmux-sessionizer/script.fish deleted file mode 100644 index d0ca484..0000000 --- a/modules/programs/tmux/tmux-sessionizer/script.fish +++ /dev/null @@ -1,13 +0,0 @@ -set selected (fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf1 $argv) - -set selected_name (basename $selected 2>/dev/null | string replace "." "_") - -if not test -n "$selected_name" - exit 1 -end - -if ! tmux has-session -t $selected_name 2> /dev/null - tmux new-session -ds $selected_name -c $selected -end - -tmux-switch $selected_name diff --git a/overlays/builders.nix b/overlays/builders.nix deleted file mode 100644 index 498ebcc..0000000 --- a/overlays/builders.nix +++ /dev/null @@ -1,49 +0,0 @@ -_: - -final: _: -with final.lib; -{ - writeFishApplication = - { name - , text - , completions ? null - , runtimeInputs ? [ ] - , checkPhase ? null - }: - let - fishFile = destination: content: final.writeTextFile { - inherit name destination; - executable = true; - allowSubstitutes = true; - preferLocalBuild = false; - text = '' - #!${getExe final.fish} - '' + optionalString (runtimeInputs != [ ]) '' - - export PATH="${makeBinPath runtimeInputs}:$PATH" - '' + '' - - ${content} - ''; - - checkPhase = - if checkPhase == null then '' - runHook preCheck - ${getExe final.fish} -n "$target" - runHook postCheck - '' - else checkPhase; - }; - - - script = fishFile "/bin/${name}" text; - - completions_file = fishFile "/share/fish/vendor_completions.d/${name}.fish" completions; - in - final.symlinkJoin { - inherit name; - paths = [ - script - ] ++ optional (completions != null) completions_file; - }; -}