programs.yazi: add module (#4373)

add module for yazi https://github.com/sxyazi/yazi a terminal rust file browser akin to ranger or joshuto
This commit is contained in:
XYenon 2023-08-28 02:47:47 +08:00 committed by GitHub
parent f8c5fd7509
commit 90e62f96c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 334 additions and 0 deletions

View file

@ -0,0 +1,27 @@
{ ... }:
let
shellIntegration = ''
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 {
programs.bash.enable = true;
programs.yazi = {
enable = true;
enableBashIntegration = true;
};
test.stubs.yazi = { };
nmt.script = ''
assertFileContains home-files/.bashrc '${shellIntegration}'
'';
}

View file

@ -0,0 +1,5 @@
{
yazi-settings = ./settings.nix;
yazi-bash-integration-enabled = ./bash-integration-enabled.nix;
yazi-zsh-integration-enabled = ./zsh-integration-enabled.nix;
}

View file

@ -0,0 +1,27 @@
[[input.keymap]]
exec = "close"
on = ["<C-q>"]
[[input.keymap]]
exec = "close --submit"
on = ["<Enter>"]
[[input.keymap]]
exec = "escape"
on = ["<Esc>"]
[[input.keymap]]
exec = "backspace"
on = ["<Backspace>"]
[[manager.keymap]]
exec = "escape"
on = ["<Esc>"]
[[manager.keymap]]
exec = "quit"
on = ["q"]
[[manager.keymap]]
exec = "close"
on = ["<C-q>"]

View file

@ -0,0 +1,8 @@
[log]
enabled = false
[manager]
show_hidden = false
sort_by = "modified"
sort_dir_first = true
sort_reverse = true

View file

@ -0,0 +1,84 @@
{ ... }:
{
programs.yazi = {
enable = true;
keymap = {
input.keymap = [
{
exec = "close";
on = [ "<C-q>" ];
}
{
exec = "close --submit";
on = [ "<Enter>" ];
}
{
exec = "escape";
on = [ "<Esc>" ];
}
{
exec = "backspace";
on = [ "<Backspace>" ];
}
];
manager.keymap = [
{
exec = "escape";
on = [ "<Esc>" ];
}
{
exec = "quit";
on = [ "q" ];
}
{
exec = "close";
on = [ "<C-q>" ];
}
];
};
settings = {
log = { enabled = false; };
manager = {
show_hidden = false;
sort_by = "modified";
sort_dir_first = true;
sort_reverse = true;
};
};
theme = {
filetype = {
rules = [
{
fg = "#7AD9E5";
mime = "image/*";
}
{
fg = "#F3D398";
mime = "video/*";
}
{
fg = "#F3D398";
mime = "audio/*";
}
{
fg = "#CD9EFC";
mime = "application/x-bzip";
}
];
};
};
};
test.stubs.yazi = { };
nmt.script = ''
assertFileContent home-files/.config/yazi/keymap.toml \
${./keymap-expected.toml}
assertFileContent home-files/.config/yazi/yazi.toml \
${./settings-expected.toml}
assertFileContent home-files/.config/yazi/theme.toml \
${./theme-expected.toml}
'';
}

View file

@ -0,0 +1,15 @@
[[filetype.rules]]
fg = "#7AD9E5"
mime = "image/*"
[[filetype.rules]]
fg = "#F3D398"
mime = "video/*"
[[filetype.rules]]
fg = "#F3D398"
mime = "audio/*"
[[filetype.rules]]
fg = "#CD9EFC"
mime = "application/x-bzip"

View file

@ -0,0 +1,27 @@
{ ... }:
let
shellIntegration = ''
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 {
programs.zsh.enable = true;
programs.yazi = {
enable = true;
enableBashIntegration = true;
};
test.stubs.yazi = { };
nmt.script = ''
assertFileContains home-files/.zshrc '${shellIntegration}'
'';
}