Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 40 additions & 50 deletions completions/pty.bash
Original file line number Diff line number Diff line change
@@ -1,93 +1,95 @@
# Bash completion for pty
# Source this file or copy to /etc/bash_completion.d/pty
# (or install via scripts/install-completions.sh).

# bash completion for pty — generated by `pty completions bash`.
# Regenerate with: pty completions bash > completions/pty.bash
_pty() {
local cur prev commands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
commands="run attach a exec peek send events list ls stats restart kill rm remove gc tag tag-multi emit rename up down test version help"
commands="run attach a exec peek send events list ls stats restart kill rm remove gc tag tag-multi emit rename up down test remote-serve"

# Complete subcommand (first positional).
if [[ ${COMP_CWORD} -eq 1 ]]; then
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--root --preselect-new --filter-tag --help -h --version -v" -- "${cur}"))
COMPREPLY=($(compgen -W "--root --preselect-new --filter-tag" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${commands}" -- "${cur}"))
fi
return
fi

# Session-name provider — used by verbs that take a <ref>.
local root="${PTY_ROOT:-${PTY_SESSION_DIR:-${HOME}/.local/state/pty}}"
local names=""
if [[ -d "${root}" ]]; then
names=$(ls "${root}"/*.json 2>/dev/null | xargs -I{} basename {} .json)
fi

case "${COMP_WORDS[1]}" in
run)
COMPREPLY=($(compgen -W "-d --detach -a --attach -e --ephemeral --id --name --no-display-name --tag --cwd --isolate-env --force" -- "${cur}"))
;;
attach|a)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-r --no-resize --force" -- "${cur}"))
COMPREPLY=($(compgen -W "-r --auto-restart --no-resize --force --remote" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
exec)
COMPREPLY=($(compgen -o dirnames -- "${cur}"))
;;
peek)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-f --plain --full --wait -t" -- "${cur}"))
COMPREPLY=($(compgen -W "-f --follow --plain --full --wait -t --timeout --remote" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
send)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--seq --with-delay --paste" -- "${cur}"))
COMPREPLY=($(compgen -W "--seq --with-delay --paste --remote" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
events)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--all --recent --json --wait -t" -- "${cur}"))
COMPREPLY=($(compgen -W "--all --recent --json --wait -t --timeout" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
list|ls)
COMPREPLY=($(compgen -W "--json --tags --filter-tag --remote --status --older-than --newer-than --summary" -- "${cur}"))
;;
stats)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--json" -- "${cur}"))
COMPREPLY=($(compgen -W "--json --all" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
restart)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-y --force" -- "${cur}"))
COMPREPLY=($(compgen -W "-y --yes --force" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
kill|rm|remove)
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
;;
rename)
kill)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--show --clear" -- "${cur}"))
COMPREPLY=($(compgen -W "" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
list|ls)
rm|remove)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "--json --tags --filter-tag --remote" -- "${cur}"))
COMPREPLY=($(compgen -W "" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
gc)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-n --dry-run --idle-days --fast-fail-window --fast-fail-limit --print-launchd-plist --interval" -- "${cur}"))
fi
COMPREPLY=($(compgen -W "-n --dry-run --idle-days --fast-fail-window --fast-fail-limit --print-launchd-plist --interval" -- "${cur}"))
;;
tag)
if [[ "${cur}" == -* ]]; then
Expand All @@ -110,37 +112,25 @@ _pty() {
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
up|down)
# Complete directories (containing pty.toml) or session names from an
# already-loaded toml. Directories are more common; keep it simple.
COMPREPLY=($(compgen -o dirnames -- "${cur}"))
;;
exec)
# After --, fall through to default (command + args) completion.
COMPREPLY=($(compgen -o default -- "${cur}"))
;;
run)
# After --, fall back to default file completion for the command.
local i
for (( i=2; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" == "--" ]]; then
COMPREPLY=($(compgen -o default -- "${cur}"))
return
fi
done
# Before --, complete flags.
rename)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-d -a -e --id --name --no-display-name --tag --cwd --isolate-env" -- "${cur}"))
COMPREPLY=($(compgen -W "--show --clear" -- "${cur}"))
else
COMPREPLY=($(compgen -W "${names}" -- "${cur}"))
fi
;;
up)
COMPREPLY=($(compgen -o dirnames -- "${cur}"))
;;
down)
COMPREPLY=($(compgen -o dirnames -- "${cur}"))
;;
test)
if [[ "${cur}" == -* ]]; then
COMPREPLY=($(compgen -W "-t" -- "${cur}"))
else
COMPREPLY=($(compgen -W "watch" -- "${cur}"))
fi
COMPREPLY=($(compgen -W "--t" -- "${cur}"))
;;
remote-serve)
COMPREPLY=($(compgen -W "--stdio --socket" -- "${cur}"))
;;
esac
}

complete -F _pty pty
Loading
Loading