godot.bash-completion 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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) 2014-present Godot Engine contributors (see AUTHORS.md).
  7. # Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.
  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. --audio-output-latency
  48. --display-driver
  49. --rendering-method
  50. --rendering-driver
  51. --gpu-index
  52. --text-driver
  53. --tablet-driver
  54. --headless
  55. --log-file
  56. --write-movie
  57. --fullscreen
  58. --maximized
  59. --windowed
  60. --always-on-top
  61. --resolution
  62. --position
  63. --single-window
  64. --xr-mode
  65. --debug
  66. --breakpoints
  67. --profiling
  68. --gpu-profile
  69. --gpu-validation
  70. --gpu-abort
  71. --remote-debug
  72. --debug-collisions
  73. --debug-navigation
  74. --debug-stringnames
  75. --max-fps
  76. --frame-delay
  77. --time-scale
  78. --disable-vsync
  79. --disable-render-loop
  80. --disable-crash-handler
  81. --fixed-fps
  82. --print-fps
  83. --script
  84. --check-only
  85. --export-release
  86. --export-debug
  87. --export-pack
  88. --convert-3to4
  89. --validate-conversion-3to4
  90. --doctool
  91. --no-docbase
  92. --build-solutions
  93. --dump-gdextension-interface
  94. --dump-extension-api
  95. --benchmark
  96. --benchmark-file
  97. --test
  98. " -- "$1"))
  99. }
  100. _complete_godot_bash() {
  101. local cur="${COMP_WORDS[$COMP_CWORD]}" prev
  102. # Complete options or the positional argument.
  103. if [[ $cur == -* ]]; then
  104. _complete_godot_options "$cur"
  105. else
  106. local IFS=$'\n\t'
  107. # shellcheck disable=SC2207
  108. COMPREPLY=($(compgen -f -X "!*.@(scn|tscn|escn|godot)" -- "$cur"))
  109. fi
  110. # If the array is accessed out of bounds (which will happen for the first argument),
  111. # `$prev` will be an empty string and won't match any of the conditions below.
  112. prev="${COMP_WORDS[$((COMP_CWORD-1))]}"
  113. # Complete option values.
  114. if [[ $prev == "--render-thread" ]]; then
  115. local IFS=$' \n\t'
  116. # shellcheck disable=SC2207
  117. COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur"))
  118. elif [[ $prev == "--rendering-method" ]]; then
  119. local IFS=$' \n\t'
  120. # shellcheck disable=SC2207
  121. COMPREPLY=($(compgen -W "forward_plus mobile gl_compatibility" -- "$cur"))
  122. elif [[ $prev == "--rendering-driver" ]]; then
  123. local IFS=$' \n\t'
  124. # shellcheck disable=SC2207
  125. COMPREPLY=($(compgen -W "vulkan opengl3 dummy" -- "$cur"))
  126. elif [[ $prev == "--xr-mode" ]]; then
  127. local IFS=$' \n\t'
  128. # shellcheck disable=SC2207
  129. COMPREPLY=($(compgen -W "default off on" -- "$cur"))
  130. elif [[ $prev == "--path" || $prev == "--doctool" ]]; then
  131. local IFS=$'\n\t'
  132. # shellcheck disable=SC2207
  133. COMPREPLY=($(compgen -d -- "$cur"))
  134. elif [[ $prev == "--main-pack" ]]; then
  135. local IFS=$'\n\t'
  136. # shellcheck disable=SC2207
  137. COMPREPLY=($(compgen -f -X "!*.@(pck|zip)" -- "$cur"))
  138. elif [[ $prev == "-s" || $prev == "--script" ]]; then
  139. local IFS=$'\n\t'
  140. # shellcheck disable=SC2207
  141. COMPREPLY=($(compgen -f -X "!*.gd" -- "$cur"))
  142. fi
  143. }
  144. complete -o filenames -F _complete_godot_bash godot