From 31f7c9e8017feea5f525c74e27c4ce68bd34875f Mon Sep 17 00:00:00 2001 From: Filippo Berto Date: Sun, 22 Oct 2023 17:37:34 +0200 Subject: [PATCH] yazi: bettr integration (waiting for home-manager stable release) --- modules/hm/sxhkd.nix | 24 ++++++++++++++++++------ modules/hm/yazi.nix | 18 +++++++++++++++--- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/modules/hm/sxhkd.nix b/modules/hm/sxhkd.nix index 916f1c8..097b2bc 100644 --- a/modules/hm/sxhkd.nix +++ b/modules/hm/sxhkd.nix @@ -1,11 +1,12 @@ { pkgs, lib, ... }: { imports = [ - ./nautilus.nix - # ./thunar.nix - ./nemo.nix - ./terminator.nix # ./alacritty.nix ./kitty.nix + # ./nautilus.nix + ./nemo.nix + ./terminator.nix + # ./thunar.nix + ./yazi.nix ]; home.packages = builtins.attrValues { inherit (pkgs) @@ -16,8 +17,19 @@ let primaryTerminal = "kitty"; secondaryTerminal = "terminator"; - fileManager = "nemo"; - secondaryFileManager = "nautilus"; + fileManager = + let + ya = pkgs.writeShellScript "ya" '' + tmp="$(mktemp -t "yazi-cwd.XXXXX")" + yazi --cwd-file="$tmp" + if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then + cd -- "$cwd" + fi + rm -f -- "$tmp" + ''; + in + "kitty -e bash ${ya}"; + secondaryFileManager = "nemo"; emojiChooser = "rofimoji --skin-tone light -a copy"; windowSwitcher = "rofi -show window"; diff --git a/modules/hm/yazi.nix b/modules/hm/yazi.nix index 9fd6660..7d7a616 100644 --- a/modules/hm/yazi.nix +++ b/modules/hm/yazi.nix @@ -1,10 +1,20 @@ { pkgs, ... }: -let tomlGenerate = (pkgs.formats.toml { }).generate; in +let + tomlGenerate = (pkgs.formats.toml { }).generate; + bashIntegration = '' + function ya() { + tmp="$(mktemp -t "yazi-cwd.XXXXX")" + yazi --cwd-file="$tmp" + if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then + cd -- "$cwd" + fi + rm -f -- "$tmp" + } + ''; +in { home.packages = [ pkgs.unstable_pkgs.yazi pkgs.ffmpegthumbnailer pkgs.exiftool pkgs.mediainfo ]; - home.shellAliases."yz" = "yazi"; - xdg.configFile."yazi/yazi.toml".source = tomlGenerate "yazi.toml" { manager = { sort_by = "natural"; @@ -49,5 +59,7 @@ let tomlGenerate = (pkgs.formats.toml { }).generate; in # enableBashIntegration = true; # enableZshIntegration = true; # }; + programs.bash.initExtra = bashIntegration; + programs.zsh.initExtra = bashIntegration; }