Skip to content

Commit

Permalink
299 setup yazi (#302)
Browse files Browse the repository at this point in the history
* Enable yazi

* Setup yazi-picker for helix

Used https://yazi-rs.github.io/docs/tips/#helix-with-zellij to set this up.
  • Loading branch information
francishamel authored Sep 6, 2024
1 parent f6184ef commit 57f4a31
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions home-manager/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
./modules/terminal.nix
./modules/vscode.nix
./modules/wezterm.nix
./modules/yazi.nix
./modules/zellij.nix
];
home.stateVersion = "22.11";
Expand Down
20 changes: 19 additions & 1 deletion home-manager/modules/helix.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
{ pkgs, ... }:
{ config, lib, pkgs, ... }:

let
yaziPicker = pkgs.writeShellScriptBin "yazi-picker" ''
paths=$(${pkgs.yazi}/bin/yazi --chooser-file=/dev/stdout | while read -r; do printf "%q " "$REPLY"; done)
if [[ -n "$paths" ]]; then
${pkgs.zellij}/bin/zellij action toggle-floating-panes
${pkgs.zellij}/bin/zellij action write 27 # send <Escape> key
${pkgs.zellij}/bin/zellij action write-chars ":open $paths"
${pkgs.zellij}/bin/zellij action write 13 # send <Enter> key
${pkgs.zellij}/bin/zellij action toggle-floating-panes
fi
${pkgs.zellij}/bin/zellij action close-pane
'';
in
{
programs.helix = {
enable = true;
Expand All @@ -14,6 +29,9 @@
};
settings = {
editor.line-number = "relative";
keys.normal = {
"C-y" = lib.mkIf config.programs.yazi.enable ":sh ${pkgs.zellij}/bin/zellij run -f -n yazi-picker -x 10% -y 10% --width 80% --height 80% -- ${yaziPicker}/bin/yazi-picker";
};
};
};
}
8 changes: 8 additions & 0 deletions home-manager/modules/yazi.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ ... }:

{
programs.yazi = {
enable = true;
enableZshIntegration = true;
};
}

0 comments on commit 57f4a31

Please sign in to comment.