Merge pull request #1182 from zsh-users/tsx

Add tsx completion
This commit is contained in:
Shohei YOSHIDA 2025-12-11 15:22:32 +09:00 committed by GitHub
commit 737bce8e4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 242 additions and 176 deletions

View File

@ -69,7 +69,10 @@ _node_scripts() {
_describe 'scripts' scripts _describe 'scripts' scripts
} }
_arguments \ _node() {
local ret=1
_arguments \
'-[script read from stdin (default; interactive mode if a tty)]' \ '-[script read from stdin (default; interactive mode if a tty)]' \
'--[indicate the end of node options]' \ '--[indicate the end of node options]' \
'--abort-on-uncaught-exception[aborting instead of exiting causes a core file to be generated for analysis]' \ '--abort-on-uncaught-exception[aborting instead of exiting causes a core file to be generated for analysis]' \
@ -244,7 +247,12 @@ _arguments \
'--zero-fill-buffers[automatically zero-fill all newly allocated Buffer and SlowBuffer instances]' \ '--zero-fill-buffers[automatically zero-fill all newly allocated Buffer and SlowBuffer instances]' \
'(- 1 *)'{-h,--help}'[print node command line options]' \ '(- 1 *)'{-h,--help}'[print node command line options]' \
'(- 1 *)'{-v,--version}'[print Node.js version]' \ '(- 1 *)'{-v,--version}'[print Node.js version]' \
'*: :_node_args' '*: :_node_args' && ret=0
return ret
}
_node "$@"
# Local Variables: # Local Variables:
# mode: Shell-Script # mode: Shell-Script

58
src/_tsx Normal file
View File

@ -0,0 +1,58 @@
#compdef tsx
# ------------------------------------------------------------------------------
# Copyright (c) 2025 Github zsh-users - https://github.com/zsh-users
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for tsx v4.21.0. (https://github.com/privatenumber/tsx)
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
#
# ------------------------------------------------------------------------------
_tsx_completion() {
_arguments \
'(- *)'{-h,--help}'[show help]' \
'(- *)'{-v,--version}'[show version]' \
'--no-cache[disable caching]' \
'--tsconfig[custom tsconfig.json path]:path:_files -g "*.json"' \
'1: :(watch)'
}
_tsx() {
_alternative 'tsx: :_tsx_completion' 'node: :_node'
}
_tsx "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et