flameshot.zsh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #compdef flameshot
  2. # ------------------------------------------------------------------------------
  3. # Description
  4. # -----------
  5. #
  6. # Completion script for the flameshot command line interface
  7. # (https://github.com/flameshot-org/flameshot).
  8. #
  9. # ------------------------------------------------------------------------------
  10. # How to use
  11. # -------
  12. #
  13. # Copy this file to /usr/share/zsh/site-functions/_flameshot
  14. #
  15. # gui
  16. _flameshot_gui_opts=(
  17. {-p,--path}'[Existing directory or new file to save to]':dir:_files
  18. {-c,--clipboard}'[Save the capture to the clipboard]'
  19. {-d,--delay}'[Delay time in milliseconds]'
  20. "--region[Screenshot region to select <WxH+X+Y or string>]"
  21. {-r,--raw}'[Print raw PNG capture]'
  22. {-g,--print-geometry}'[Print geometry of the selection in the format WxH+X+Y. Does nothing if raw is specified]'
  23. {-u,--upload}'[Upload screenshot]'
  24. "--pin[Pin the capture to the screen]"
  25. {-s,--accept-on-select}'[Accept capture as soon as a selection is made]'
  26. )
  27. _flameshot_gui() {
  28. _arguments -s : \
  29. "$_flameshot_gui_opts[@]"
  30. }
  31. # screen
  32. _flameshot_screen_opts=(
  33. {-n,--number}'[Define the screen to capture (starting from 0). Default: screen containing the cursor]'
  34. {-p,--path}'[Existing directory or new file to save to]':dir:_files
  35. {-c,--clipboard}'[Save the capture to the clipboard]'
  36. {-d,--delay}'[Delay time in milliseconds]'
  37. "--region[Screenshot region to select <WxH+X+Y or string>]"
  38. {-r,--raw}'[Print raw PNG capture]'
  39. {-u,--upload}'[Upload screenshot]'
  40. "--pin[Pin the capture to the screen]"
  41. )
  42. _flameshot_screen() {
  43. _arguments -s : \
  44. "$_flameshot_screen_opts[@]"
  45. }
  46. # full
  47. _flameshot_full_opts=(
  48. {-p,--path}'[Existing directory or new file to save to]':dir:_files
  49. {-c,--clipboard}'[Save the capture to the clipboard]'
  50. {-d,--delay}'[Delay time in milliseconds]'
  51. "--region[Screenshot region to select <WxH+X+Y or string>]"
  52. {-r,--raw}'[Print raw PNG capture]'
  53. {-u,--upload}'[Upload screenshot]'
  54. )
  55. _flameshot_full() {
  56. _arguments -s : \
  57. "$_flameshot_full_opts[@]"
  58. }
  59. # config
  60. _flameshot_config_opts=(
  61. {-a,--autostart}'[Enable or disable run at startup]'
  62. {-f,--filename}'[Set the filename pattern]'
  63. {-t,--trayicon}'[Enable or disable the tray icon]'
  64. {-s,--showhelp}'[Define the main UI color]'
  65. {-m,--maincolor}'[Show the help message in the capture mode]'
  66. {-k,--contrastcolor}'[Define the contrast UI color]'
  67. "--check[Check the configuration for errors]"
  68. )
  69. _flameshot_config() {
  70. _arguments -s : \
  71. "$_flameshot_config_opts[@]"
  72. }
  73. # Main handle
  74. _flameshot() {
  75. local curcontext="$curcontext" ret=1
  76. local -a state line commands
  77. commands=(
  78. "gui:Start a manual capture in GUI mode"
  79. "screen:Capture a single screen (one monitor)"
  80. "full:Capture the entire desktop (all monitors)"
  81. "launcher:Open the capture launcher"
  82. "config:Configure Flameshot"
  83. )
  84. _arguments -C -s -S -n \
  85. '(- 1 *)'{-v,--version}"[display version information]: :->full" \
  86. '(- 1 *)'{-h,--help}'[[display usage information]: :->full' \
  87. '1:cmd:->cmds' \
  88. '*:: :->args' && ret=0
  89. case "$state" in
  90. (cmds)
  91. _describe -t commands 'commands' commands
  92. ;;
  93. (args)
  94. local cmd
  95. cmd=$words[1]
  96. case "$cmd" in
  97. (gui)
  98. _flameshot_gui && ret=0
  99. ;;
  100. (screen)
  101. _flameshot_screen && ret=0
  102. ;;
  103. (full)
  104. _flameshot_full && ret=0
  105. ;;
  106. (config)
  107. _flameshot_config && ret=0
  108. ;;
  109. (*)
  110. _default && ret=0
  111. ;;
  112. esac
  113. ;;
  114. (*)
  115. ;;
  116. esac
  117. return ret
  118. }
  119. _flameshot
  120. #
  121. # Editor modelines - https://www.wireshark.org/tools/modelines.html
  122. #
  123. # Local variables:
  124. # mode: sh
  125. # c-basic-offset: 4
  126. # tab-width: 4
  127. # indent-tabs-mode: nil
  128. # End:
  129. #
  130. # vi: set filetype=zsh shiftwidth=4 tabstop=4 expandtab:
  131. # :indentSize=4:tabSize=4:noTabs=true:
  132. #