From 552610b48413bed553b204f8d4ba0a8ee64897b0 Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 1 Nov 2023 20:08:51 +0100 Subject: [PATCH] Improve IDE with image preview --- dot_local/share/scripts/executable_ide.nu | 17 +++++++++++++++-- private_dot_config/broot/ide.toml | 8 ++++++++ private_dot_config/zellij/development.kdl | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dot_local/share/scripts/executable_ide.nu b/dot_local/share/scripts/executable_ide.nu index c308f71..6921bce 100644 --- a/dot_local/share/scripts/executable_ide.nu +++ b/dot_local/share/scripts/executable_ide.nu @@ -5,6 +5,19 @@ def main [] { } def `main open-file` [path: string] { - zellij action move-focus right - zellij action write-chars $":open ($path)\r" + match ($path | path parse | get extension | str downcase) { + "png" => { open-image $path } + "jpg" => { open-image $path } + "jpeg" => { open-image $path } + _ => { open-editor $path } + } +} + +def open-editor [path: string] { + zellij ac move-focus right + zellij ac write-chars $":open ($path)\r" +} + +def open-image [path: string] { + zellij ac new-pane -f -- chafa -C on --scale max $path } diff --git a/private_dot_config/broot/ide.toml b/private_dot_config/broot/ide.toml index 2f13c86..a23c35a 100644 --- a/private_dot_config/broot/ide.toml +++ b/private_dot_config/broot/ide.toml @@ -1,4 +1,6 @@ modal = true +default_flags = "g" +show_selection_mark = true [[verbs]] invocation = "open" @@ -6,3 +8,9 @@ key = "enter" external = "nu ~/.local/share/scripts/ide.nu open-file '{file}'" apply_to = "file" leave_broot = false + +[[verbs]] +invocation = "touch {name}" +external = "nu -c \"touch {directory}/{name}\"" +apply_to = "any" +leave_broot = false diff --git a/private_dot_config/zellij/development.kdl b/private_dot_config/zellij/development.kdl index a021f8b..a5c5fa6 100644 --- a/private_dot_config/zellij/development.kdl +++ b/private_dot_config/zellij/development.kdl @@ -11,7 +11,7 @@ layout { tab split_direction="Vertical" { pane split_direction="Vertical" { pane command="nu" size="15%" { - args "-c" "broot --conf ~/.config/broot/ide.toml" + args "-c" "broot --conf ~/.config/broot/ide.toml --sort-by-type-dirs-first" } pane command="nu" size="50%" { args "-c helix"