mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
yazi: add xonsh integration
This commit is contained in:
parent
f5b0284f28
commit
fbf04399ce
3 changed files with 51 additions and 0 deletions
|
@ -39,6 +39,21 @@ let
|
|||
rm -fp $tmp
|
||||
}
|
||||
'';
|
||||
|
||||
xonshIntegration = ''
|
||||
def __yazi_init():
|
||||
def yy(args):
|
||||
tmp = $(mktemp -t "yazi-cwd.XXXXX").strip()
|
||||
$[yazi @(args) @(f"--cwd-file={tmp}")]
|
||||
cwd = fp"{tmp}".read_text()
|
||||
if cwd != "" and cwd != $PWD:
|
||||
xonsh.dirstack.cd((cwd,))
|
||||
$[rm -f -- @(tmp)]
|
||||
|
||||
aliases['yy'] = yy
|
||||
__yazi_init()
|
||||
del __yazi_init
|
||||
'';
|
||||
in {
|
||||
meta.maintainers = with maintainers; [ xyenon eljamm ];
|
||||
|
||||
|
@ -72,6 +87,8 @@ in {
|
|||
default = true;
|
||||
};
|
||||
|
||||
enableXonshIntegration = mkEnableOption "Xonsh integration";
|
||||
|
||||
keymap = mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = { };
|
||||
|
@ -208,6 +225,8 @@ in {
|
|||
programs.nushell.extraConfig =
|
||||
mkIf cfg.enableNushellIntegration nushellIntegration;
|
||||
|
||||
programs.xonsh.xonshrc = mkIf cfg.enableXonshIntegration xonshIntegration;
|
||||
|
||||
xdg.configFile = {
|
||||
"yazi/keymap.toml" = mkIf (cfg.keymap != { }) {
|
||||
source = tomlFormat.generate "yazi-keymap" cfg.keymap;
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix;
|
||||
yazi-fish-integration-enabled = ./fish-integration-enabled.nix;
|
||||
yazi-nushell-integration-enabled = ./nushell-integration-enabled.nix;
|
||||
yazi-xonsh-integration-enabled = ./xonsh-integration-enabled.nix;
|
||||
}
|
||||
|
|
31
tests/modules/programs/yazi/xonsh-integration-enabled.nix
Normal file
31
tests/modules/programs/yazi/xonsh-integration-enabled.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ ... }:
|
||||
|
||||
let
|
||||
shellIntegration = ''
|
||||
def __yazi_init():
|
||||
def ya(args):
|
||||
tmp = $(mktemp -t "yazi-cwd.XXXXX")
|
||||
$[yazi @(args) @(f"--cwd-file={tmp}")]
|
||||
cwd = fp"{tmp}".read_text()
|
||||
if cwd != "" and cwd != $PWD:
|
||||
xonsh.dirstack.cd(cwd)
|
||||
$[rm -f -- @(tmp)]
|
||||
|
||||
aliases['ya'] = ya
|
||||
__yazi_init()
|
||||
del __yazi_init
|
||||
'';
|
||||
in {
|
||||
programs.xonsh.enable = true;
|
||||
|
||||
programs.yazi = {
|
||||
enable = true;
|
||||
enableXonshIntegration = true;
|
||||
};
|
||||
|
||||
test.stubs.yazi = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContains home-files/.config/xonsh/rc.xsh '${shellIntegration}'
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue