Skip to content

Commit

Permalink
add wezterm record --cwd argument
Browse files Browse the repository at this point in the history
refs: #4333
  • Loading branch information
wez committed Sep 29, 2023
1 parent 845fa5d commit 5e0fd1a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
6 changes: 5 additions & 1 deletion assets/shell-completion/bash
Original file line number Diff line number Diff line change
Expand Up @@ -1574,12 +1574,16 @@ _wezterm() {
return 0
;;
wezterm__record)
opts="-h --help [PROG]..."
opts="-h --cwd --help [PROG]..."
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
--cwd)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
*)
COMPREPLY=()
;;
Expand Down
11 changes: 6 additions & 5 deletions assets/shell-completion/fish
Original file line number Diff line number Diff line change
Expand Up @@ -168,25 +168,26 @@ complete -c wezterm -n "__fish_seen_subcommand_from cli; and __fish_seen_subcomm
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l width -d 'Specify the display width; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal width' -r
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l height -d 'Specify the display height; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal height' -r
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l position -d 'Set the cursor position prior to displaying the image. The default is to use the current cursor position. Coordinates are expressed in cells with 0,0 being the top left cell position' -r
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l tmux-passthru -d 'How to manage passing the escape through to tmux' -r -f -a "{disable ,enable ,detect }"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l tmux-passthru -d 'How to manage passing the escape through to tmux' -r -f -a "{disable '',enable '',detect ''}"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l max-pixels -d 'Set the maximum number of pixels per image frame. Images will be scaled down so that they do not exceed this size, unless `--no-resample` is also used. The default value matches the limit set by wezterm. Note that resampling the image here will reduce any animated images to a single frame' -r
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l resample-format -d 'Specify the image format to use to encode resampled/resized images. The default is to match the input format, but you can choose an alternative format' -r -f -a "{png ,jpeg ,input }"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l resample-filter -d 'Specify the filtering technique used when resizing/resampling images. The default is a reasonable middle ground of speed and quality' -r -f -a "{nearest ,triangle ,catmull-rom ,gaussian ,lanczos3 }"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l resample-format -d 'Specify the image format to use to encode resampled/resized images. The default is to match the input format, but you can choose an alternative format' -r -f -a "{png '',jpeg '',input ''}"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l resample-filter -d 'Specify the filtering technique used when resizing/resampling images. The default is a reasonable middle ground of speed and quality' -r -f -a "{nearest '',triangle '',catmull-rom '',gaussian '',lanczos3 ''}"
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l resize -d 'Pre-process the image to resize it to the specified dimensions, expressed as eg: 800x600 (width x height). The resize is independent of other parameters that control the image placement and dimensions in the terminal; this is provided as a convenience preprocessing step' -r
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l no-preserve-aspect-ratio -d 'Do not respect the aspect ratio. The default is to respect the aspect ratio'
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l no-move-cursor -d 'Do not move the cursor after displaying the image. Note that when used like this from the shell, there is a very high chance that shell prompt will overwrite the image; you may wish to also use `--hold` in that case'
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l hold -d 'Wait for enter to be pressed after displaying the image'
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l no-resample -d 'Do not resample images whose frames are larger than the max-pixels value. Note that this will typically result in the image refusing to display in wezterm'
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -l show-resample-timing -d 'When resampling or resizing, display some diagnostics around the timing/performance of that operation'
complete -c wezterm -n "__fish_seen_subcommand_from imgcat" -s h -l help -d 'Print help (see more with \'--help\')'
complete -c wezterm -n "__fish_seen_subcommand_from set-working-directory" -l tmux-passthru -d 'How to manage passing the escape through to tmux' -r -f -a "{disable ,enable ,detect }"
complete -c wezterm -n "__fish_seen_subcommand_from set-working-directory" -l tmux-passthru -d 'How to manage passing the escape through to tmux' -r -f -a "{disable '',enable '',detect ''}"
complete -c wezterm -n "__fish_seen_subcommand_from set-working-directory" -s h -l help -d 'Print help'
complete -c wezterm -n "__fish_seen_subcommand_from record" -l cwd -d 'Start in the specified directory, instead of the default_cwd defined by your wezterm configuration' -r -F
complete -c wezterm -n "__fish_seen_subcommand_from record" -s h -l help -d 'Print help'
complete -c wezterm -n "__fish_seen_subcommand_from replay" -l explain -d 'Explain what is being sent/received'
complete -c wezterm -n "__fish_seen_subcommand_from replay" -l explain-only -d 'Don\'t replay, just show the explanation'
complete -c wezterm -n "__fish_seen_subcommand_from replay" -l cat -d 'Just emit raw escape sequences all at once, with no timing information'
complete -c wezterm -n "__fish_seen_subcommand_from replay" -s h -l help -d 'Print help'
complete -c wezterm -n "__fish_seen_subcommand_from shell-completion" -l shell -d 'Which shell to generate for' -r -f -a "{bash ,elvish ,fish ,power-shell ,zsh ,fig }"
complete -c wezterm -n "__fish_seen_subcommand_from shell-completion" -l shell -d 'Which shell to generate for' -r -f -a "{bash '',elvish '',fish '',power-shell '',zsh '',fig ''}"
complete -c wezterm -n "__fish_seen_subcommand_from shell-completion" -s h -l help -d 'Print help'
complete -c wezterm -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from start; and not __fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from serial; and not __fish_seen_subcommand_from connect; and not __fish_seen_subcommand_from ls-fonts; and not __fish_seen_subcommand_from show-keys; and not __fish_seen_subcommand_from cli; and not __fish_seen_subcommand_from imgcat; and not __fish_seen_subcommand_from set-working-directory; and not __fish_seen_subcommand_from record; and not __fish_seen_subcommand_from replay; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "start" -d 'Start the GUI, optionally running an alternative program'
complete -c wezterm -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from start; and not __fish_seen_subcommand_from ssh; and not __fish_seen_subcommand_from serial; and not __fish_seen_subcommand_from connect; and not __fish_seen_subcommand_from ls-fonts; and not __fish_seen_subcommand_from show-keys; and not __fish_seen_subcommand_from cli; and not __fish_seen_subcommand_from imgcat; and not __fish_seen_subcommand_from set-working-directory; and not __fish_seen_subcommand_from record; and not __fish_seen_subcommand_from replay; and not __fish_seen_subcommand_from shell-completion; and not __fish_seen_subcommand_from help" -f -a "ssh" -d 'Establish an ssh session'
Expand Down
3 changes: 2 additions & 1 deletion assets/shell-completion/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,10 @@ _arguments "${_arguments_options[@]}" \
;;
(record)
_arguments "${_arguments_options[@]}" \
'--cwd=[Start in the specified directory, instead of the default_cwd defined by your wezterm configuration]:CWD:_files' \
'-h[Print help]' \
'--help[Print help]' \
'*::prog:' \
'*::prog -- Start prog instead of the default_prog defined by your wezterm configuration:' \
&& ret=0
;;
(replay)
Expand Down
9 changes: 6 additions & 3 deletions docs/examples/cmd-synopsis-wezterm-record--help.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Record a terminal session as an asciicast

Usage: wezterm record [PROG]...
Usage: wezterm record [OPTIONS] [PROG]...

Arguments:
[PROG]...
[PROG]... Start prog instead of the default_prog defined by your wezterm
configuration

Options:
-h, --help Print help
--cwd <CWD> Start in the specified directory, instead of the default_cwd
defined by your wezterm configuration
-h, --help Print help
9 changes: 8 additions & 1 deletion wezterm/src/asciicast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,13 @@ enum Message {

#[derive(Debug, Parser, Clone)]
pub struct RecordCommand {
/// Start in the specified directory, instead of
/// the default_cwd defined by your wezterm configuration
#[arg(long)]
cwd: Option<std::path::PathBuf>,

/// Start prog instead of the default_prog defined by your
/// wezterm configuration
#[arg(value_parser)]
prog: Vec<OsString>,
}
Expand Down Expand Up @@ -369,7 +376,7 @@ impl RecordCommand {
Some(prog)
},
config.default_prog.as_ref(),
config.default_cwd.as_ref(),
self.cwd.as_ref().or(config.default_cwd.as_ref()),
)?;

let mut child = pair.slave.spawn_command(cmd)?;
Expand Down

0 comments on commit 5e0fd1a

Please sign in to comment.