flameshot.fish 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. set -l SUBCOMMANDS gui screen full launcher config
  2. ####################
  3. # HELPER FUNCTIONS #
  4. ####################
  5. # Complete the subcommand provided as the first argument.
  6. # The rest of the arguments are the same as fish's `complete`. The option
  7. # '-c flameshot' is implicit.
  8. function __flameshot_complete --argument-names cmd
  9. set -l conditions "__fish_seen_subcommand_from $cmd"
  10. argparse -i "n/condition=" -- $argv[2..]
  11. [ -n "$_flag_n" ] && set -l conditions "$conditions && $_flag_n"
  12. complete -c flameshot $argv -n "$conditions"
  13. end
  14. # Return success if the command line contains no positional arguments
  15. function __flameshot_no_positional_args
  16. set -l -- args (commandline -po) # cmdline broken up into list
  17. set -l -- cmdline (commandline -p) # single string
  18. set -l -- n (count $args) # number of cmdline tokens
  19. for i in (seq 2 $n)
  20. set -l arg $args[$i]
  21. [ -z "$arg" ] && continue # can be caused by '--' argument
  22. # If the the last token is a positional argument and there is no
  23. # trailing space, we ignore it
  24. [ "$i" = "$n" ] && [ (string sub -s -1 "$cmdline") != ' ' ] && break
  25. if string match -rvq '^-' -- "$arg" # doesn't start with -
  26. return 1
  27. end
  28. end
  29. # contains a '--' argument
  30. string match -r -- '\s--\s' "$cmdline" && return 1
  31. return 0
  32. end
  33. # Complete paths matching $argv
  34. function __flameshot_complete_paths
  35. complete -C"nOnExIsTeNtCoMmAndZIOAGA2329jdbfaFkahDf21234h8z43 $argv"
  36. end
  37. # Complete the region option
  38. function __flameshot_complete_region --argument subcommand
  39. if [ "$subcommand" = "screen" ]
  40. echo all\tCapture entire screen
  41. else
  42. echo all\tCapture all screens
  43. echo screen0\tCapture screen 0
  44. echo screen1\tCapture screen 1
  45. echo screen2\tCapture screen 2
  46. echo screen3\tCapture screen 3
  47. end
  48. echo WxH+X+Y\tCustom region in pixels
  49. end
  50. # Complete screen numbers
  51. function __flameshot_complete_screen_number
  52. echo 0\tScreen 0
  53. echo 1\tScreen 1
  54. echo 2\tScreen 2
  55. echo 3\tScreen 3
  56. end
  57. ###############
  58. # COMPLETIONS #
  59. ###############
  60. # No subcommand
  61. complete -c flameshot -n __flameshot_no_positional_args -f -a "$SUBCOMMANDS"
  62. complete -c flameshot -l "help" -s "h" -f -d "Display help message"
  63. complete -c flameshot -l "version" -s "v" -f -d "Display version information" -n __flameshot_no_positional_args
  64. # GUI subcommand
  65. __flameshot_complete gui -f
  66. __flameshot_complete gui -l "path" -s "p" -rk -d "Output file or directory"
  67. __flameshot_complete gui -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard"
  68. __flameshot_complete gui -l "delay" -s "d" -frk -d "Delay time in milliseconds"
  69. __flameshot_complete gui -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region gui)"
  70. __flameshot_complete gui -l "raw" -s "r" -f -d "Print raw PNG capture"
  71. __flameshot_complete gui -l "print-geometry" -s "g" -f -d "Print geometry of the selection"
  72. __flameshot_complete gui -l "upload" -s "u" -f -d "Upload the screenshot"
  73. __flameshot_complete gui -l "pin" -f -d "Pin the screenshot to the screen"
  74. __flameshot_complete gui -l "accept-on-select" -s "s" -f -d "Accept capture as soon as a selection is made"
  75. # SCREEN subcommand
  76. __flameshot_complete screen -f
  77. __flameshot_complete screen -l "number" -s "n" -frk -d "Screen number (starting from 0)" -a "(__flameshot_complete_screen_number)"
  78. __flameshot_complete screen -l "path" -s "p" -rk -d "Output file or directory"
  79. __flameshot_complete screen -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard"
  80. __flameshot_complete screen -l "delay" -s "d" -frk -d "Delay time in milliseconds"
  81. __flameshot_complete screen -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region screen)"
  82. __flameshot_complete screen -l "raw" -s "r" -f -d "Print raw PNG capture"
  83. __flameshot_complete screen -l "upload" -s "u" -f -d "Upload the screenshot"
  84. __flameshot_complete screen -l "pin" -f -d "Pin the screenshot to the screen"
  85. # FULL command
  86. __flameshot_complete full -f
  87. __flameshot_complete full -l "path" -s "p" -rk -d "Output file or directory"
  88. __flameshot_complete full -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard"
  89. __flameshot_complete full -l "delay" -s "d" -frk -d "Delay time in milliseconds"
  90. __flameshot_complete full -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region full)"
  91. __flameshot_complete full -l "raw" -s "r" -f -d "Print raw PNG capture"
  92. __flameshot_complete full -l "upload" -s "u" -f -d "Upload the screenshot"
  93. # LAUNCHER command doesn't have any completions specific to itself
  94. # CONFIG command -- TODO will be completed in a future version
  95. __flameshot_complete config -f
  96. __flameshot_complete config -l "check" -f -d "Check the configuration for errors"