godot.bash-completion 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. --quit
  38. --language
  39. --path
  40. --upwards
  41. --main-pack
  42. --render-thread
  43. --remote-fs
  44. --remote-fs-password
  45. --audio-driver
  46. --video-driver
  47. --fullscreen
  48. --maximized
  49. --windowed
  50. --always-on-top
  51. --resolution
  52. --position
  53. --low-dpi
  54. --no-window
  55. --enable-vsync-via-compositor
  56. --disable-vsync-via-compositor
  57. --debug
  58. --breakpoints
  59. --profiling
  60. --remote-debug
  61. --debug-collisions
  62. --debug-navigation
  63. --frame-delay
  64. --time-scale
  65. --disable-render-loop
  66. --disable-crash-handler
  67. --fixed-fps
  68. --print-fps
  69. --script
  70. --check-only
  71. --export
  72. --export-debug
  73. --export-pack
  74. --doctool
  75. --no-docbase
  76. --build-solutions
  77. --gdnative-generate-json-api
  78. --benchmark
  79. --benchmark-file
  80. --test
  81. " -- "$1"))
  82. }
  83. _complete_godot_bash() {
  84. local cur="${COMP_WORDS[$COMP_CWORD]}" prev
  85. # Complete options or the positional argument.
  86. if [[ $cur == -* ]]; then
  87. _complete_godot_options "$cur"
  88. else
  89. local IFS=$'\n\t'
  90. # shellcheck disable=SC2207
  91. COMPREPLY=($(compgen -f -X "!*.@(scn|tscn|escn|godot)" -- "$cur"))
  92. fi
  93. # If the array is accessed out of bounds (which will happen for the first argument),
  94. # `$prev` will be an empty string and won't match any of the conditions below.
  95. prev="${COMP_WORDS[$((COMP_CWORD-1))]}"
  96. # Complete option values.
  97. if [[ $prev == "--render-thread" ]]; then
  98. local IFS=$' \n\t'
  99. # shellcheck disable=SC2207
  100. COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur"))
  101. elif [[ $prev == "--video-driver" ]]; then
  102. local IFS=$' \n\t'
  103. # shellcheck disable=SC2207
  104. COMPREPLY=($(compgen -W "GLES3 GLES2" -- "$cur"))
  105. elif [[ $prev == "--path" || $prev == "--doctool" ]]; then
  106. local IFS=$'\n\t'
  107. # shellcheck disable=SC2207
  108. COMPREPLY=($(compgen -d -- "$cur"))
  109. elif [[ $prev == "--main-pack" ]]; then
  110. local IFS=$'\n\t'
  111. # shellcheck disable=SC2207
  112. COMPREPLY=($(compgen -f -X "!*.@(pck|zip)" -- "$cur"))
  113. elif [[ $prev == "-s" || $prev == "--script" ]]; then
  114. local IFS=$'\n\t'
  115. # shellcheck disable=SC2207
  116. COMPREPLY=($(compgen -f -X "!*.gd" -- "$cur"))
  117. fi
  118. }
  119. complete -o filenames -F _complete_godot_bash godot