From c0897e502783f40fba1bfab866417ebe0e446201 Mon Sep 17 00:00:00 2001 From: Nils de Groot Date: Thu, 18 Apr 2024 08:29:16 +0200 Subject: [PATCH 1/2] Add `zellij action new-tab` completions --- custom-completions/zellij/zellij-completions.nu | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/custom-completions/zellij/zellij-completions.nu b/custom-completions/zellij/zellij-completions.nu index 14d369b32..c2c962e1c 100644 --- a/custom-completions/zellij/zellij-completions.nu +++ b/custom-completions/zellij/zellij-completions.nu @@ -81,6 +81,13 @@ def "nu-complete sessions" [] { ^zellij ls -n | lines | parse "{value} {description}" } +def "nu-complete zellij layouts" [] { + ls ~/.config/zellij/layouts/ + | where name =~ "\\.kdl" + | get name + | each { |$it| { value: ($it | path basename | str replace ".kdl" ""), description: $it } } +} + # Turned off since it messes with sub-commands #export extern "zellij" [ # command?: string@"nu-complete zellij" @@ -106,6 +113,15 @@ export extern "zellij action rename-tab" [ name: string # Name for the tab ] +# Create a new tab, optionally with a specified tab layout and name +export extern "zellij action new-tab" [ + --cwd(-c): path # Change the working directory of the new tab + --help(-h) # Print help information + --layout(-l): string@"nu-complete zellij layouts" # Layout ot use for the new tab + --layout-dir: path # Default folder to look for layouts + --name(-n): string # Name for the tab +] + # Attach to a session export extern "zellij attach" [ session_name: string@"nu-complete sessions" # Name of the session to attach to From 9fa4c2404f5f1aaaa29dd0b22357520587e3dd5d Mon Sep 17 00:00:00 2001 From: Nils de Groot Date: Thu, 18 Apr 2024 14:14:07 +0200 Subject: [PATCH 2/2] More extensive configuration path check --- custom-completions/zellij/zellij-completions.nu | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/custom-completions/zellij/zellij-completions.nu b/custom-completions/zellij/zellij-completions.nu index c2c962e1c..68291ada9 100644 --- a/custom-completions/zellij/zellij-completions.nu +++ b/custom-completions/zellij/zellij-completions.nu @@ -82,7 +82,17 @@ def "nu-complete sessions" [] { } def "nu-complete zellij layouts" [] { - ls ~/.config/zellij/layouts/ + let layout_dir = if 'ZELLIJ_CONFIG_DIR' in $env { + [$env.ZELLIJ_CONFIG_DIR "layouts"] | path join + } else { + match $nu.os-info.name { + "linux" => "~/.config/zellij/layouts/" + "mac" => "~/Library/Application Support/org.Zellij-Contributors.Zellij/layouts" + _ => (error make { msg: "Unsupported OS for zellij" }) + } + } + + ls ( $layout_dir | path expand ) | where name =~ "\\.kdl" | get name | each { |$it| { value: ($it | path basename | str replace ".kdl" ""), description: $it } }