completions: improve zsh completions for --cwd, --config-file, prog

Make these complete the appropriate type of thing
This commit is contained in:
Wez Furlong committed 2022-06-19 16:27:59 -07:00
1 parent bbb78b8845
commit 347e1fdc46
6 files changed
+45 -36

No files matched your search

+4 -4
View File
@@ -1,4 +1,4 @@
complete -c wezterm -n "__fish_use_subcommand" -l config-file -d 'Specify the configuration file to use, overrides the normal configuration file resolution' -r
complete -c wezterm -n "__fish_use_subcommand" -l config-file -d 'Specify the configuration file to use, overrides the normal configuration file resolution' -r -F
complete -c wezterm -n "__fish_use_subcommand" -l config -d 'Override specific configuration values' -r
complete -c wezterm -n "__fish_use_subcommand" -s h -l help -d 'Print help information'
complete -c wezterm -n "__fish_use_subcommand" -s V -l version -d 'Print version information'
@@ -15,7 +15,7 @@ complete -c wezterm -n "__fish_use_subcommand" -f -a "record" -d 'Record a termi
complete -c wezterm -n "__fish_use_subcommand" -f -a "replay" -d 'Replay an asciicast terminal session'
complete -c wezterm -n "__fish_use_subcommand" -f -a "shell-completion" -d 'Generate shell completion information'
complete -c wezterm -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c wezterm -n "__fish_seen_subcommand_from start" -l cwd -d 'Specify the current working directory for the initially spawned program' -r
complete -c wezterm -n "__fish_seen_subcommand_from start" -l cwd -d 'Specify the current working directory for the initially spawned program' -r -f -a "(__fish_complete_directories)"
complete -c wezterm -n "__fish_seen_subcommand_from start" -l class -d 'Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs' -r
complete -c wezterm -n "__fish_seen_subcommand_from start" -l workspace -d 'Override the default workspace with the provided name. The default is "default"' -r
complete -c wezterm -n "__fish_seen_subcommand_from start" -l position -d 'Override the position for the initial window launched by this process.' -r
@@ -67,7 +67,7 @@ complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcomm
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l pane-id -d 'Specify the pane that should be split. The default is to use the current pane based on the environment variable WEZTERM_PANE' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l cells -d 'The number of cells that the new split should have. If omitted, 50% of the available space is used' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l percent -d 'Specify the number of cells that the new split should have, expressed as a percentage of the available space' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l cwd -d 'Specify the current working directory for the initially spawned program' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l cwd -d 'Specify the current working directory for the initially spawned program' -r -f -a "(__fish_complete_directories)"
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l move-pane-id -d 'Instead of spawning a new command, move the specified pane into the newly created split' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l horizontal -d 'Equivalent to `--right`. If neither this nor any other direction is specified, the default is equivalent to `--bottom`'
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from split-pane" -l left -d 'Split horizontally, with the new pane on the left'
@@ -79,7 +79,7 @@ complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcomm
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l pane-id -d 'Specify the current pane. The default is to use the current pane based on the environment variable WEZTERM_PANE. The pane is used to determine the current domain and window' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l domain-name -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l window-id -d 'Specify the window into which to spawn a tab. If omitted, the window associated with the current pane is used' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l cwd -d 'Specify the current working directory for the initially spawned program' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l cwd -d 'Specify the current working directory for the initially spawned program' -r -f -a "(__fish_complete_directories)"
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l workspace -d 'When creating a new window, override the default workspace name with the provided name. The default name is "default"' -r
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -l new-window -d 'Spawn into a new window, rather than a new tab'
complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcommand_from spawn" -s h -l help -d 'Print help information'
+12 -12
View File
@@ -15,7 +15,7 @@ _wezterm() {
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
'(-n)--config-file=[Specify the configuration file to use, overrides the normal configuration file resolution]:CONFIG_FILE: ' \
'(-n)--config-file=[Specify the configuration file to use, overrides the normal configuration file resolution]:CONFIG_FILE:_files' \
'*--config=[Override specific configuration values]:name=value: ' \
'-h[Print help information]' \
'--help[Print help information]' \
@@ -33,7 +33,7 @@ _wezterm() {
case $line[1] in
(start)
_arguments "${_arguments_options[@]}" \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD: ' \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
'--class=[Override the default windowing system class. The default is "org.wezfurlong.wezterm". Under X11 and Windows this changes the window class. Under Wayland this changes the app_id. This changes the class for all windows spawned by this instance of wezterm, including error, update and ssh authentication dialogs]:CLASS: ' \
'--workspace=[Override the default workspace with the provided name. The default is "default"]:WORKSPACE: ' \
'--position=[Override the position for the initial window launched by this process.]:POSITION: ' \
@@ -41,7 +41,7 @@ _arguments "${_arguments_options[@]}" \
'--always-new-process[If enabled, don'\''t try to ask an existing wezterm GUI instance to start the command. Instead, always start the GUI in this invocation of wezterm so that you can wait for the command to complete by waiting for this wezterm process to finish]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
&& ret=0
;;
(ssh)
@@ -54,7 +54,7 @@ _arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':user-at-host-and-port -- Specifies the remote system using the form\: `\[username@\]host\[\:port\]`. If `username@` is omitted, then your local $USER is used instead. If `\:port` is omitted, then the standard ssh port (22) is used instead:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm ssh user@host -- bash -l` will spawn bash as if it were a login shell:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm ssh user@host -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
&& ret=0
;;
(serial)
@@ -75,7 +75,7 @@ _arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':domain-name -- Name of the multiplexer domain section from the configuration to which you'\''d like to connect:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm start -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
&& ret=0
;;
(ls-fonts)
@@ -144,7 +144,7 @@ _arguments "${_arguments_options[@]}" \
'--pane-id=[Specify the pane that should be split. The default is to use the current pane based on the environment variable WEZTERM_PANE]:PANE_ID: ' \
'--cells=[The number of cells that the new split should have. If omitted, 50% of the available space is used]:CELLS: ' \
'(--cells)--percent=[Specify the number of cells that the new split should have, expressed as a percentage of the available space]:PERCENT: ' \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD: ' \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
'(--cwd)--move-pane-id=[Instead of spawning a new command, move the specified pane into the newly created split]:MOVE_PANE_ID: ' \
'(--left --right --top --bottom)--horizontal[Equivalent to `--right`. If neither this nor any other direction is specified, the default is equivalent to `--bottom`]' \
'(--right --top --bottom)--left[Split horizontally, with the new pane on the left]' \
@@ -154,7 +154,7 @@ _arguments "${_arguments_options[@]}" \
'--top-level[Rather than splitting the active pane, split the entire window]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli split-pane -- bash -l` will spawn bash as if it were a login shell:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli split-pane -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
&& ret=0
;;
(spawn)
@@ -162,12 +162,12 @@ _arguments "${_arguments_options[@]}" \
'--pane-id=[Specify the current pane. The default is to use the current pane based on the environment variable WEZTERM_PANE. The pane is used to determine the current domain and window]:PANE_ID: ' \
'--domain-name=[]:DOMAIN_NAME: ' \
'--window-id=[Specify the window into which to spawn a tab. If omitted, the window associated with the current pane is used]:WINDOW_ID: ' \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD: ' \
'--cwd=[Specify the current working directory for the initially spawned program]:CWD:_files -/' \
'--workspace=[When creating a new window, override the default workspace name with the provided name. The default name is "default"]:WORKSPACE: ' \
'(--window-id)--new-window[Spawn into a new window, rather than a new tab]' \
'-h[Print help information]' \
'--help[Print help information]' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli spawn -- bash -l` will spawn bash as if it were a login shell:' \
'*::prog -- Instead of executing your shell, run PROG. For example\: `wezterm cli spawn -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \
&& ret=0
;;
(send-text)
@@ -195,15 +195,15 @@ _arguments "${_arguments_options[@]}" \
'--no-preserve-aspect-ratio[Do not respect the aspect ratio. The default is to respect the aspect ratio]' \
'-h[Print help information]' \
'--help[Print help information]' \
'::file-name -- The name of the image file to be displayed. If omitted, will attempt to read it from stdin:' \
'::file-name -- The name of the image file to be displayed. If omitted, will attempt to read it from stdin:_files' \
&& ret=0
;;
(set-working-directory)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::cwd -- The directory to specify. If omitted, will use the current directory of the process itself:' \
'::host -- The hostname to use in the constructed file\:// URL. If omitted, the system hostname will be used:' \
'::cwd -- The directory to specify. If omitted, will use the current directory of the process itself:_files -/' \
'::host -- The hostname to use in the constructed file\:// URL. If omitted, the system hostname will be used:_hosts' \
&& ret=0
;;
(record)
+8 -5
View File
@@ -1,4 +1,4 @@
use clap::Parser;
use clap::{Parser, ValueHint};
use config::{Dimension, GeometryOrigin, SshParameters};
use std::ffi::OsString;
use std::str::FromStr;
@@ -143,6 +143,7 @@ mod test {
}
#[derive(Debug, Parser, Default, Clone)]
#[clap(trailing_var_arg = true)]
pub struct StartCommand {
/// If true, do not connect to domains marked as connect_automatically
/// in your wezterm configuration file.
@@ -158,7 +159,7 @@ pub struct StartCommand {
/// Specify the current working directory for the initially
/// spawned program
#[clap(long = "cwd", parse(from_os_str))]
#[clap(long = "cwd", parse(from_os_str), value_hint=ValueHint::DirPath)]
pub cwd: Option<OsString>,
/// Override the default windowing system class.
@@ -189,11 +190,12 @@ pub struct StartCommand {
/// Instead of executing your shell, run PROG.
/// For example: `wezterm start -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
pub prog: Vec<OsString>,
}
#[derive(Debug, Parser, Clone)]
#[clap(trailing_var_arg = true)]
pub struct SshCommand {
/// Specifies the remote system using the form:
/// `[username@]host[:port]`.
@@ -248,7 +250,7 @@ pub struct SshCommand {
/// Instead of executing your shell, run PROG.
/// For example: `wezterm ssh user@host -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
pub prog: Vec<OsString>,
}
@@ -285,6 +287,7 @@ pub struct SerialCommand {
}
#[derive(Debug, Parser, Clone)]
#[clap(trailing_var_arg = true)]
pub struct ConnectCommand {
/// Name of the multiplexer domain section from the configuration
/// to which you'd like to connect
@@ -317,7 +320,7 @@ pub struct ConnectCommand {
/// Instead of executing your shell, run PROG.
/// For example: `wezterm start -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
pub prog: Vec<OsString>,
}
+3 -2
View File
@@ -3,7 +3,7 @@
use ::window::*;
use anyhow::{anyhow, Context};
use clap::Parser;
use clap::{Parser, ValueHint};
use config::{ConfigHandle, SshDomain, SshMultiplexing};
use mux::activity::Activity;
use mux::domain::{Domain, LocalDomain};
@@ -64,7 +64,8 @@ struct Opt {
#[clap(
long = "config-file",
parse(from_os_str),
conflicts_with = "skip-config"
conflicts_with = "skip-config",
value_hint=ValueHint::FilePath,
)]
config_file: Option<OsString>,
+6 -4
View File
@@ -16,7 +16,8 @@ mod daemonize;
#[derive(Debug, Parser)]
#[clap(
about = "Wez's Terminal Emulator\nhttp://github.com/wez/wezterm",
version = config::wezterm_version()
version = config::wezterm_version(),
trailing_var_arg = true,
)]
struct Opt {
/// Skip loading wezterm.lua
@@ -28,7 +29,8 @@ struct Opt {
#[clap(
long = "config-file",
parse(from_os_str),
conflicts_with = "skip-config"
conflicts_with = "skip-config",
value_hint=ValueHint::FilePath,
)]
config_file: Option<OsString>,
@@ -46,13 +48,13 @@ struct Opt {
/// Specify the current working directory for the initially
/// spawned program
#[clap(long = "cwd", parse(from_os_str))]
#[clap(long = "cwd", parse(from_os_str), value_hint=ValueHint::DirPath)]
cwd: Option<OsString>,
/// Instead of executing your shell, run PROG.
/// For example: `wezterm start -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
prog: Vec<OsString>,
}
+12 -9
View File
@@ -1,6 +1,6 @@
use anyhow::{anyhow, Context};
use chrono::{DateTime, Utc};
use clap::Parser;
use clap::{Parser, ValueHint};
use clap_complete::{generate as generate_completion, Shell};
use config::keyassignment::SpawnTabDomain;
use config::wezterm_version;
@@ -39,7 +39,8 @@ struct Opt {
#[clap(
long = "config-file",
parse(from_os_str),
conflicts_with = "skip-config"
conflicts_with = "skip-config",
value_hint=ValueHint::FilePath
)]
config_file: Option<OsString>,
@@ -200,6 +201,7 @@ enum CliSubCommand {
#[clap(
name = "split-pane",
rename_all = "kebab",
trailing_var_arg = true,
about = "split the current pane.
Outputs the pane-id for the newly created pane on success"
)]
@@ -248,7 +250,7 @@ Outputs the pane-id for the newly created pane on success"
/// Specify the current working directory for the initially
/// spawned program
#[clap(long, parse(from_os_str))]
#[clap(long, parse(from_os_str), value_hint=ValueHint::DirPath)]
cwd: Option<OsString>,
/// Instead of spawning a new command, move the specified
@@ -259,12 +261,13 @@ Outputs the pane-id for the newly created pane on success"
/// Instead of executing your shell, run PROG.
/// For example: `wezterm cli split-pane -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
prog: Vec<OsString>,
},
#[clap(
name = "spawn",
trailing_var_arg = true,
about = "Spawn a command into a new window or tab
Outputs the pane-id for the newly created pane on success"
)]
@@ -292,7 +295,7 @@ Outputs the pane-id for the newly created pane on success"
/// Specify the current working directory for the initially
/// spawned program
#[clap(long = "cwd", parse(from_os_str))]
#[clap(long = "cwd", parse(from_os_str), value_hint=ValueHint::DirPath)]
cwd: Option<OsString>,
/// When creating a new window, override the default workspace name
@@ -303,7 +306,7 @@ Outputs the pane-id for the newly created pane on success"
/// Instead of executing your shell, run PROG.
/// For example: `wezterm cli spawn -- bash -l` will spawn bash
/// as if it were a login shell.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::CommandWithArguments, multiple_values=true)]
prog: Vec<OsString>,
},
@@ -351,7 +354,7 @@ struct ImgCatCommand {
no_preserve_aspect_ratio: bool,
/// The name of the image file to be displayed.
/// If omitted, will attempt to read it from stdin.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::FilePath)]
file_name: Option<OsString>,
}
@@ -389,12 +392,12 @@ impl ImgCatCommand {
struct SetCwdCommand {
/// The directory to specify.
/// If omitted, will use the current directory of the process itself.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::DirPath)]
cwd: Option<OsString>,
/// The hostname to use in the constructed file:// URL.
/// If omitted, the system hostname will be used.
#[clap(parse(from_os_str))]
#[clap(parse(from_os_str), value_hint=ValueHint::Hostname)]
host: Option<OsString>,
}