mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-09 02:06:53 +00:00
yazi: organization tweak
Moving variable declaration closer to usage so it's easier to manage / see.
This commit is contained in:
parent
b34b56689d
commit
5795f792ab
1 changed files with 40 additions and 39 deletions
|
@ -1,5 +1,4 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
literalExpression mapAttrsToList mkEnableOption mkIf mkOption optionalString
|
literalExpression mapAttrsToList mkEnableOption mkIf mkOption optionalString
|
||||||
|
@ -7,38 +6,6 @@ let
|
||||||
|
|
||||||
cfg = config.programs.yazi;
|
cfg = config.programs.yazi;
|
||||||
tomlFormat = pkgs.formats.toml { };
|
tomlFormat = pkgs.formats.toml { };
|
||||||
|
|
||||||
bashIntegration = ''
|
|
||||||
function ${cfg.shellWrapperName}() {
|
|
||||||
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
|
|
||||||
yazi "$@" --cwd-file="$tmp"
|
|
||||||
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
|
||||||
builtin cd -- "$cwd"
|
|
||||||
fi
|
|
||||||
rm -f -- "$tmp"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
|
|
||||||
fishIntegration = ''
|
|
||||||
set -l tmp (mktemp -t "yazi-cwd.XXXXX")
|
|
||||||
command yazi $argv --cwd-file="$tmp"
|
|
||||||
if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
|
|
||||||
builtin cd -- "$cwd"
|
|
||||||
end
|
|
||||||
rm -f -- "$tmp"
|
|
||||||
'';
|
|
||||||
|
|
||||||
nushellIntegration = ''
|
|
||||||
def --env ${cfg.shellWrapperName} [...args] {
|
|
||||||
let tmp = (mktemp -t "yazi-cwd.XXXXX")
|
|
||||||
yazi ...$args --cwd-file $tmp
|
|
||||||
let cwd = (open $tmp)
|
|
||||||
if $cwd != "" and $cwd != $env.PWD {
|
|
||||||
cd $cwd
|
|
||||||
}
|
|
||||||
rm -fp $tmp
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
in {
|
in {
|
||||||
meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ];
|
meta.maintainers = with lib.maintainers; [ eljamm khaneliman xyenon ];
|
||||||
|
|
||||||
|
@ -194,15 +161,49 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
|
programs = let
|
||||||
|
bashIntegration = ''
|
||||||
|
function ${cfg.shellWrapperName}() {
|
||||||
|
local tmp="$(mktemp -t "yazi-cwd.XXXXX")"
|
||||||
|
yazi "$@" --cwd-file="$tmp"
|
||||||
|
if cwd="$(cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
|
||||||
|
builtin cd -- "$cwd"
|
||||||
|
fi
|
||||||
|
rm -f -- "$tmp"
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration bashIntegration;
|
fishIntegration = ''
|
||||||
|
set -l tmp (mktemp -t "yazi-cwd.XXXXX")
|
||||||
|
command yazi $argv --cwd-file="$tmp"
|
||||||
|
if set cwd (cat -- "$tmp"); and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
|
||||||
|
builtin cd -- "$cwd"
|
||||||
|
end
|
||||||
|
rm -f -- "$tmp"
|
||||||
|
'';
|
||||||
|
|
||||||
programs.fish.functions.${cfg.shellWrapperName} =
|
nushellIntegration = ''
|
||||||
|
def --env ${cfg.shellWrapperName} [...args] {
|
||||||
|
let tmp = (mktemp -t "yazi-cwd.XXXXX")
|
||||||
|
yazi ...$args --cwd-file $tmp
|
||||||
|
let cwd = (open $tmp)
|
||||||
|
if $cwd != "" and $cwd != $env.PWD {
|
||||||
|
cd $cwd
|
||||||
|
}
|
||||||
|
rm -fp $tmp
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
bash.initExtra = mkIf cfg.enableBashIntegration bashIntegration;
|
||||||
|
|
||||||
|
zsh.initExtra = mkIf cfg.enableZshIntegration bashIntegration;
|
||||||
|
|
||||||
|
fish.functions.${cfg.shellWrapperName} =
|
||||||
mkIf cfg.enableFishIntegration fishIntegration;
|
mkIf cfg.enableFishIntegration fishIntegration;
|
||||||
|
|
||||||
programs.nushell.extraConfig =
|
nushell.extraConfig =
|
||||||
mkIf cfg.enableNushellIntegration nushellIntegration;
|
mkIf cfg.enableNushellIntegration nushellIntegration;
|
||||||
|
};
|
||||||
|
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"yazi/keymap.toml" = mkIf (cfg.keymap != { }) {
|
"yazi/keymap.toml" = mkIf (cfg.keymap != { }) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue