From b95f260bb41b5950dbd1c9519261081f206124b2 Mon Sep 17 00:00:00 2001 From: nils-degroot <53556985+nils-degroot@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:28:15 +0200 Subject: [PATCH] Add `zellij action new-tab` completions (#821) This PR add completions for this `zellij action new-tab` command, which is currently missing. --- .../zellij/zellij-completions.nu | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/custom-completions/zellij/zellij-completions.nu b/custom-completions/zellij/zellij-completions.nu index 14d369b3..68291ada 100644 --- a/custom-completions/zellij/zellij-completions.nu +++ b/custom-completions/zellij/zellij-completions.nu @@ -81,6 +81,23 @@ def "nu-complete sessions" [] { ^zellij ls -n | lines | parse "{value} {description}" } +def "nu-complete 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 } } +} + # Turned off since it messes with sub-commands #export extern "zellij" [ # command?: string@"nu-complete zellij" @@ -106,6 +123,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