Skip to content

Commit

Permalink
Add zellij action new-tab completions (nushell#821)
Browse files Browse the repository at this point in the history
This PR add completions for this `zellij action new-tab` command, which
is currently missing.
  • Loading branch information
nils-degroot committed Apr 18, 2024
1 parent 1a4c6e9 commit b95f260
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions custom-completions/zellij/zellij-completions.nu
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down

0 comments on commit b95f260

Please sign in to comment.