| ... | ... | | @@ -242,3 +245,279 @@ const nu_completions = |
| 242 | 245 | | \\ |
| 243 | 246 | | \\export extern "zmx help" [] |
| 244 | 247 | | ; |
| 248 | + |
|
| 249 | + | const yash_completions = |
| 250 | + | \\function completion/zmx { |
| 251 | + | \\ typeset OPTIONS ARGOPT PREFIX |
| 252 | + | \\ OPTIONS=( #># |
| 253 | + | \\ "v --version; show version" |
| 254 | + | \\ "h; show help" |
| 255 | + | \\ ) #<# |
| 256 | + | \\ |
| 257 | + | \\ command -f completion//parseoptions -e |
| 258 | + | \\ case $ARGOPT in |
| 259 | + | \\ (-) |
| 260 | + | \\ command -f completion//completeoptions |
| 261 | + | \\ ;; |
| 262 | + | \\ ("") |
| 263 | + | \\ if [ ${WORDS[#]} -le 1 ]; then |
| 264 | + | \\ command -f completion/zmx::completecmd |
| 265 | + | \\ else |
| 266 | + | \\ typeset zmxcmd="${WORDS[2]}" |
| 267 | + | \\ case $zmxcmd in |
| 268 | + | \\ (a|attach) |
| 269 | + | \\ command -f completion/zmx::attach:arg |
| 270 | + | \\ ;; |
| 271 | + | \\ (r|run) |
| 272 | + | \\ command -f completion/zmx::run:arg |
| 273 | + | \\ ;; |
| 274 | + | \\ (s|send) |
| 275 | + | \\ command -f completion/zmx::send:arg |
| 276 | + | \\ ;; |
| 277 | + | \\ (p|print) |
| 278 | + | \\ command -f completion/zmx::print:arg |
| 279 | + | \\ ;; |
| 280 | + | \\ (wr|write) |
| 281 | + | \\ command -f completion/zmx::write:arg |
| 282 | + | \\ ;; |
| 283 | + | \\ (d|detach) |
| 284 | + | \\ ;; |
| 285 | + | \\ (l|ls|list) |
| 286 | + | \\ command -f completion/zmx::list:arg |
| 287 | + | \\ ;; |
| 288 | + | \\ (g|get) |
| 289 | + | \\ command -f completion/zmx::get:arg |
| 290 | + | \\ ;; |
| 291 | + | \\ (set) |
| 292 | + | \\ command -f completion/zmx::set:arg |
| 293 | + | \\ ;; |
| 294 | + | \\ (cl|clear) |
| 295 | + | \\ command -f completion/zmx::clear:arg |
| 296 | + | \\ ;; |
| 297 | + | \\ (print-env) |
| 298 | + | \\ command -f completion/zmx::print-env:arg |
| 299 | + | \\ ;; |
| 300 | + | \\ (k|kill) |
| 301 | + | \\ command -f completion/zmx::kill:arg |
| 302 | + | \\ ;; |
| 303 | + | \\ (hi|history) |
| 304 | + | \\ command -f completion/zmx::history:arg |
| 305 | + | \\ ;; |
| 306 | + | \\ (w|wait) |
| 307 | + | \\ command -f completion/zmx::wait:arg |
| 308 | + | \\ ;; |
| 309 | + | \\ (t|tail) |
| 310 | + | \\ command -f completion/zmx::tail:arg |
| 311 | + | \\ ;; |
| 312 | + | \\ (c|completions) |
| 313 | + | \\ command -f completion/zmx::completions:arg |
| 314 | + | \\ ;; |
| 315 | + | \\ esac |
| 316 | + | \\ fi |
| 317 | + | \\ ;; |
| 318 | + | \\ esac |
| 319 | + | \\} |
| 320 | + | \\ |
| 321 | + | \\function completion/zmx::completecmd { |
| 322 | + | \\ complete -P "$PREFIX" -D "Attach to session, creating if needed" attach a |
| 323 | + | \\ complete -P "$PREFIX" -D "Send command without attaching" run r |
| 324 | + | \\ complete -P "$PREFIX" -D "Send raw input to session PTY" send s |
| 325 | + | \\ complete -P "$PREFIX" -D "Inject text into session display" print p |
| 326 | + | \\ complete -P "$PREFIX" -D "Write stdin to file_path through the session" write wr |
| 327 | + | \\ complete -P "$PREFIX" -D "Detach all clients from current session" detach d |
| 328 | + | \\ complete -P "$PREFIX" -D "List active sessions" list ls l |
| 329 | + | \\ complete -P "$PREFIX" -D "Get session labels" get g |
| 330 | + | \\ complete -P "$PREFIX" -D "Set session labels" set |
| 331 | + | \\ complete -P "$PREFIX" -D "Clear all session labels" clear cl |
| 332 | + | \\ complete -P "$PREFIX" -D "Print tracked environment variables" print-env |
| 333 | + | \\ complete -P "$PREFIX" -D "Kill session and all attached clients" kill k |
| 334 | + | \\ complete -P "$PREFIX" -D "Output session scrollback" history hi |
| 335 | + | \\ complete -P "$PREFIX" -D "Wait for session tasks to complete" wait w |
| 336 | + | \\ complete -P "$PREFIX" -D "Follow session output" tail t |
| 337 | + | \\ complete -P "$PREFIX" -D "Shell completion scripts" completions c |
| 338 | + | \\ complete -P "$PREFIX" -D "Show version" version v |
| 339 | + | \\ complete -P "$PREFIX" -D "Show help message" help h |
| 340 | + | \\} |
| 341 | + | \\ |
| 342 | + | \\function completion/zmx::sessions { |
| 343 | + | \\ typeset sessions |
| 344 | + | \\ typeset IFS=' |
| 345 | + | \\' |
| 346 | + | \\ sessions=($(zmx list --short 2>/dev/null)) |
| 347 | + | \\ if [ ${sessions[#]} -gt 0 ]; then |
| 348 | + | \\ complete -P "$PREFIX" -- "$sessions" |
| 349 | + | \\ fi |
| 350 | + | \\} |
| 351 | + | \\ |
| 352 | + | \\function completion/zmx::attach:arg { |
| 353 | + | \\ OPTIONS=( #># |
| 354 | + | \\ "--labels:; apply labels as session is created" |
| 355 | + | \\ ) #<# |
| 356 | + | \\ command -f completion//parseoptions -en |
| 357 | + | \\ case $ARGOPT in |
| 358 | + | \\ (-) |
| 359 | + | \\ command -f completion//completeoptions |
| 360 | + | \\ ;; |
| 361 | + | \\ (--labels) |
| 362 | + | \\ ;; |
| 363 | + | \\ (*) |
| 364 | + | \\ command -f completion//getoperands |
| 365 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 366 | + | \\ command -f completion/zmx::sessions |
| 367 | + | \\ else |
| 368 | + | \\ complete -P "$PREFIX" -c |
| 369 | + | \\ fi |
| 370 | + | \\ ;; |
| 371 | + | \\ esac |
| 372 | + | \\} |
| 373 | + | \\ |
| 374 | + | \\function completion/zmx::run:arg { |
| 375 | + | \\ OPTIONS=( #># |
| 376 | + | \\ "d; detach from calling terminal" |
| 377 | + | \\ "--fish; session runs fish shell" |
| 378 | + | \\ ) #<# |
| 379 | + | \\ command -f completion//parseoptions -en |
| 380 | + | \\ case $ARGOPT in |
| 381 | + | \\ (-) |
| 382 | + | \\ command -f completion//completeoptions |
| 383 | + | \\ ;; |
| 384 | + | \\ (*) |
| 385 | + | \\ command -f completion//getoperands |
| 386 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 387 | + | \\ command -f completion/zmx::sessions |
| 388 | + | \\ else |
| 389 | + | \\ complete -P "$PREFIX" -c |
| 390 | + | \\ fi |
| 391 | + | \\ ;; |
| 392 | + | \\ esac |
| 393 | + | \\} |
| 394 | + | \\ |
| 395 | + | \\function completion/zmx::send:arg { |
| 396 | + | \\ command -f completion//getoperands |
| 397 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 398 | + | \\ command -f completion/zmx::sessions |
| 399 | + | \\ fi |
| 400 | + | \\} |
| 401 | + | \\ |
| 402 | + | \\function completion/zmx::print:arg { |
| 403 | + | \\ command -f completion//getoperands |
| 404 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 405 | + | \\ command -f completion/zmx::sessions |
| 406 | + | \\ fi |
| 407 | + | \\} |
| 408 | + | \\ |
| 409 | + | \\function completion/zmx::write:arg { |
| 410 | + | \\ command -f completion//getoperands |
| 411 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 412 | + | \\ command -f completion/zmx::sessions |
| 413 | + | \\ elif [ ${WORDS[#]} -eq 2 ]; then |
| 414 | + | \\ complete -P "$PREFIX" -f |
| 415 | + | \\ fi |
| 416 | + | \\} |
| 417 | + | \\ |
| 418 | + | \\function completion/zmx::list:arg { |
| 419 | + | \\ OPTIONS=( #># |
| 420 | + | \\ "--short; short output" |
| 421 | + | \\ ) #<# |
| 422 | + | \\ command -f completion//parseoptions -en |
| 423 | + | \\ case $ARGOPT in |
| 424 | + | \\ (-) |
| 425 | + | \\ command -f completion//completeoptions |
| 426 | + | \\ ;; |
| 427 | + | \\ esac |
| 428 | + | \\} |
| 429 | + | \\ |
| 430 | + | \\function completion/zmx::get:arg { |
| 431 | + | \\ command -f completion//getoperands |
| 432 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 433 | + | \\ complete -P "$PREFIX" -D "Current session" . |
| 434 | + | \\ command -f completion/zmx::sessions |
| 435 | + | \\ fi |
| 436 | + | \\} |
| 437 | + | \\ |
| 438 | + | \\function completion/zmx::set:arg { |
| 439 | + | \\ command -f completion//getoperands |
| 440 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 441 | + | \\ complete -P "$PREFIX" -D "Current session" . |
| 442 | + | \\ command -f completion/zmx::sessions |
| 443 | + | \\ fi |
| 444 | + | \\} |
| 445 | + | \\ |
| 446 | + | \\function completion/zmx::clear:arg { |
| 447 | + | \\ command -f completion//getoperands |
| 448 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 449 | + | \\ complete -P "$PREFIX" -D "Current session" . |
| 450 | + | \\ command -f completion/zmx::sessions |
| 451 | + | \\ fi |
| 452 | + | \\} |
| 453 | + | \\ |
| 454 | + | \\function completion/zmx::print-env:arg { |
| 455 | + | \\ OPTIONS=( #># |
| 456 | + | \\ "s --shell; output POSIX export/unset commands for eval" |
| 457 | + | \\ ) #<# |
| 458 | + | \\ command -f completion//parseoptions -en |
| 459 | + | \\ case $ARGOPT in |
| 460 | + | \\ (-) |
| 461 | + | \\ command -f completion//completeoptions |
| 462 | + | \\ ;; |
| 463 | + | \\ (*) |
| 464 | + | \\ command -f completion//getoperands |
| 465 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 466 | + | \\ complete -P "$PREFIX" -D "Current session" . |
| 467 | + | \\ command -f completion/zmx::sessions |
| 468 | + | \\ fi |
| 469 | + | \\ ;; |
| 470 | + | \\ esac |
| 471 | + | \\} |
| 472 | + | \\ |
| 473 | + | \\function completion/zmx::kill:arg { |
| 474 | + | \\ OPTIONS=( #># |
| 475 | + | \\ "--force; force kill" |
| 476 | + | \\ ) #<# |
| 477 | + | \\ command -f completion//parseoptions -en |
| 478 | + | \\ case $ARGOPT in |
| 479 | + | \\ (-) |
| 480 | + | \\ command -f completion//completeoptions |
| 481 | + | \\ ;; |
| 482 | + | \\ (*) |
| 483 | + | \\ command -f completion/zmx::sessions |
| 484 | + | \\ ;; |
| 485 | + | \\ esac |
| 486 | + | \\} |
| 487 | + | \\ |
| 488 | + | \\function completion/zmx::history:arg { |
| 489 | + | \\ OPTIONS=( #># |
| 490 | + | \\ "--vt; history format with escape sequences" |
| 491 | + | \\ "--html; history format in HTML" |
| 492 | + | \\ ) #<# |
| 493 | + | \\ command -f completion//parseoptions -en |
| 494 | + | \\ case $ARGOPT in |
| 495 | + | \\ (-) |
| 496 | + | \\ command -f completion//completeoptions |
| 497 | + | \\ ;; |
| 498 | + | \\ (*) |
| 499 | + | \\ command -f completion//getoperands |
| 500 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 501 | + | \\ command -f completion/zmx::sessions |
| 502 | + | \\ fi |
| 503 | + | \\ ;; |
| 504 | + | \\ esac |
| 505 | + | \\} |
| 506 | + | \\ |
| 507 | + | \\function completion/zmx::wait:arg { |
| 508 | + | \\ command -f completion//getoperands |
| 509 | + | \\ command -f completion/zmx::sessions |
| 510 | + | \\} |
| 511 | + | \\ |
| 512 | + | \\function completion/zmx::tail:arg { |
| 513 | + | \\ command -f completion//getoperands |
| 514 | + | \\ command -f completion/zmx::sessions |
| 515 | + | \\} |
| 516 | + | \\ |
| 517 | + | \\function completion/zmx::completions:arg { |
| 518 | + | \\ command -f completion//getoperands |
| 519 | + | \\ if [ ${WORDS[#]} -eq 1 ]; then |
| 520 | + | \\ complete -P "$PREFIX" -- bash zsh fish nu yash |
| 521 | + | \\ fi |
| 522 | + | \\} |
| 523 | + | ; |