godot.bash-completion 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/env bash
  2. # Bash completion for the Godot editor
  3. # To use it, install this file in `/etc/bash_completion.d` then restart your shell.
  4. # You can also `source` this file directly in your shell startup file.
  5. #
  6. # Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur.
  7. # Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md).
  8. #
  9. # Permission is hereby granted, free of charge, to any person obtaining a copy
  10. # of this software and associated documentation files (the "Software"), to deal
  11. # in the Software without restriction, including without limitation the rights
  12. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. # copies of the Software, and to permit persons to whom the Software is
  14. # furnished to do so, subject to the following conditions:
  15. #
  16. # The above copyright notice and this permission notice shall be included in all
  17. # copies or substantial portions of the Software.
  18. #
  19. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  25. # SOFTWARE.
  26. _complete_godot_options() {
  27. # Since Bash doesn't support option descriptions in autocompletion,
  28. # only display long options to be more descriptive.
  29. # shellcheck disable=SC2207
  30. COMPREPLY=($(compgen -W " \
  31. --help
  32. --version
  33. --verbose
  34. --quiet
  35. --editor
  36. --project-manager
  37. --debug-server
  38. --quit
  39. --language
  40. --path
  41. --upwards
  42. --main-pack
  43. --render-thread
  44. --remote-fs
  45. --remote-fs-password
  46. --audio-driver
  47. --display-driver
  48. --rendering-method
  49. --rendering-driver
  50. --gpu-index
  51. --text-driver
  52. --tablet-driver
  53. --headless
  54. --fullscreen
  55. --maximized
  56. --windowed
  57. --always-on-top
  58. --resolution
  59. --position
  60. --single-window
  61. --debug
  62. --breakpoints
  63. --profiling
  64. --gpu-profile
  65. --gpu-validation
  66. --gpu-abort
  67. --remote-debug
  68. --debug-collisions
  69. --debug-navigation
  70. --debug-stringnames
  71. --frame-delay
  72. --time-scale
  73. --disable-render-loop
  74. --disable-crash-handler
  75. --fixed-fps
  76. --print-fps
  77. --script
  78. --check-only
  79. --export
  80. --export-debug
  81. --export-pack
  82. --convert-3to4
  83. --validate-conversion-3to4
  84. --doctool
  85. --no-docbase
  86. --build-solutions
  87. --dump-extension-api
  88. --test
  89. " -- "$1"))
  90. }
  91. _complete_godot_bash() {
  92. local cur="${COMP_WORDS[$COMP_CWORD]}" prev
  93. # Complete options or the positional argument.
  94. if [[ $cur == -* ]]; then
  95. _complete_godot_options "$cur"
  96. else
  97. local IFS=$'\n\t'
  98. # shellcheck disable=SC2207
  99. COMPREPLY=($(compgen -f -X "!*.@(scn|tscn|escn|godot)" -- "$cur"))
  100. fi
  101. # If the array is accessed out of bounds (which will happen for the first argument),
  102. # `$prev` will be an empty string and won't match any of the conditions below.
  103. prev="${COMP_WORDS[$((COMP_CWORD-1))]}"
  104. # Complete option values.
  105. if [[ $prev == "--render-thread" ]]; then
  106. local IFS=$' \n\t'
  107. # shellcheck disable=SC2207
  108. COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur"))
  109. elif [[ $prev == "--rendering-method" ]]; then
  110. local IFS=$' \n\t'
  111. # shellcheck disable=SC2207
  112. COMPREPLY=($(compgen -W "forward_plus mobile gl_compatibility" -- "$cur"))
  113. elif [[ $prev == "--rendering-driver" ]]; then
  114. local IFS=$' \n\t'
  115. # shellcheck disable=SC2207
  116. COMPREPLY=($(compgen -W "vulkan opengl3 dummy" -- "$cur"))
  117. elif [[ $prev == "--path" || $prev == "--doctool" ]]; then
  118. local IFS=$'\n\t'
  119. # shellcheck disable=SC2207
  120. COMPREPLY=($(compgen -d -- "$cur"))
  121. elif [[ $prev == "--main-pack" ]]; then
  122. local IFS=$'\n\t'
  123. # shellcheck disable=SC2207
  124. COMPREPLY=($(compgen -f -X "!*.@(pck|zip)" -- "$cur"))
  125. elif [[ $prev == "-s" || $prev == "--script" ]]; then
  126. local IFS=$'\n\t'
  127. # shellcheck disable=SC2207
  128. COMPREPLY=($(compgen -f -X "!*.gd" -- "$cur"))
  129. fi
  130. }
  131. complete -o filenames -F _complete_godot_bash godot