commit
a7c3157345
496 files changed
+171644
No files matched your search
@@ -0,0 +1,78 @@
|
||||
#compdef flameshot
|
||||
|
||||
# Shell completion for flameshot command
|
||||
# To be installed in "/usr/share/bash-completion/completions/flameshot"
|
||||
# and "/usr/share/zsh/site-functions/"
|
||||
|
||||
|
||||
_flameshot() {
|
||||
local prev cur cmd gui_opts full_opts config_opts
|
||||
COMPREPLY=()
|
||||
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
cmd="gui full config launcher screen"
|
||||
screen_opts="--number -n --path -p --clipboard -c --delay -d --region --raw -r --upload -u --pin --help"
|
||||
gui_opts="--path -p --clipboard -c --delay -d --region --last-region --raw -r --print-geometry -g --upload -u --pin --accept-on-select -s --help"
|
||||
full_opts="--path -p --clipboard -c --delay -d --region --raw -r --upload -u --help"
|
||||
config_opts="--autostart -a --filename -f --notifications -n --trayicon -t --showhelp -s --maincolor -m --contrastcolor -k --check"
|
||||
|
||||
case "${prev}" in
|
||||
launcher)
|
||||
return 0
|
||||
;;
|
||||
screen)
|
||||
COMPREPLY=( $(compgen -W "$screen_opts --help -h" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
gui)
|
||||
COMPREPLY=( $(compgen -W "$gui_opts --help -h" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
full)
|
||||
COMPREPLY=( $(compgen -W "$full_opts --help -h" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
config)
|
||||
COMPREPLY=( $(compgen -W "$config_opts --help -h" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
-f|--filename|-p|--path)
|
||||
_filedir -d
|
||||
return 0
|
||||
;;
|
||||
# TODO: We should see how we can add the -n (for `config --notifications`) here that does not conflict with -n (for `screen --number`)
|
||||
-a|--autostart|-s|--showhelp|-t|--trayicon|--notifications)
|
||||
COMPREPLY=( $(compgen -W "true false" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
-d|--delay|-h|--help|-c|--clipboard|--version|-v|--number|-n)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Options
|
||||
case "${cur}" in
|
||||
-*)
|
||||
COMPREPLY=( $( compgen -W "--version --help -v -h" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
--*)
|
||||
COMPREPLY=( $( compgen -W "--version --help" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $( compgen -W "${cmd}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [[ -n ${ZSH_VERSION} ]]; then
|
||||
autoload -U bashcompinit
|
||||
bashcompinit
|
||||
fi
|
||||
|
||||
complete -F _flameshot flameshot
|
||||
@@ -0,0 +1,126 @@
|
||||
|
||||
####################
|
||||
# HELPER FUNCTIONS #
|
||||
####################
|
||||
|
||||
# Complete the subcommand provided as the first argument.
|
||||
# The rest of the arguments are the same as fish's `complete`. The option
|
||||
# '-c flameshot' is implicit.
|
||||
function __flameshot_complete --argument-names cmd
|
||||
set -l conditions "__fish_seen_subcommand_from $cmd"
|
||||
argparse -i "n/condition=" -- $argv[2..]
|
||||
[ -n "$_flag_n" ] && set -l conditions "$conditions && $_flag_n"
|
||||
complete -c flameshot $argv -n "$conditions"
|
||||
end
|
||||
|
||||
# Return success if the command line contains no positional arguments
|
||||
function __flameshot_no_positional_args
|
||||
set -l -- args (commandline -po) # cmdline broken up into list
|
||||
set -l -- cmdline (commandline -p) # single string
|
||||
set -l -- n (count $args) # number of cmdline tokens
|
||||
for i in (seq 2 $n)
|
||||
set -l arg $args[$i]
|
||||
[ -z "$arg" ] && continue # can be caused by '--' argument
|
||||
|
||||
# If the the last token is a positional argument and there is no
|
||||
# trailing space, we ignore it
|
||||
[ "$i" = "$n" ] && [ (string sub -s -1 "$cmdline") != ' ' ] && break
|
||||
|
||||
if string match -rvq '^-' -- "$arg" # doesn't start with -
|
||||
return 1
|
||||
end
|
||||
end
|
||||
# contains a '--' argument
|
||||
string match -r -- '\s--\s' "$cmdline" && return 1
|
||||
return 0
|
||||
end
|
||||
|
||||
# Complete paths matching $argv
|
||||
function __flameshot_complete_paths
|
||||
complete -C"nOnExIsTeNtCoMmAndZIOAGA2329jdbfaFkahDf21234h8z43 $argv"
|
||||
end
|
||||
|
||||
# Complete the region option
|
||||
function __flameshot_complete_region --argument subcommand
|
||||
if [ "$subcommand" = "screen" ]
|
||||
echo all\tCapture entire screen
|
||||
else
|
||||
echo all\tCapture all screens
|
||||
echo screen0\tCapture screen 0
|
||||
echo screen1\tCapture screen 1
|
||||
echo screen2\tCapture screen 2
|
||||
echo screen3\tCapture screen 3
|
||||
end
|
||||
echo WxH+X+Y\tCustom region in pixels
|
||||
end
|
||||
|
||||
# Complete screen numbers
|
||||
function __flameshot_complete_screen_number
|
||||
echo 0\tScreen 0
|
||||
echo 1\tScreen 1
|
||||
echo 2\tScreen 2
|
||||
echo 3\tScreen 3
|
||||
end
|
||||
|
||||
###############
|
||||
# COMPLETIONS #
|
||||
###############
|
||||
|
||||
# define the subcommands
|
||||
set -l SUBCOMMANDS gui screen full launcher config
|
||||
|
||||
# No subcommand
|
||||
complete -c flameshot --no-files --arguments "$SUBCOMMANDS" --condition __flameshot_no_positional_args
|
||||
complete -c flameshot --long-option "help" --short-option "h" --description "Display help message" --no-files
|
||||
complete -c flameshot --long-option "version" --short-option "v" --description "Display version information" --no-files --condition __flameshot_no_positional_args
|
||||
|
||||
# GUI subcommand
|
||||
__flameshot_complete gui --no-files
|
||||
__flameshot_complete gui --long-option "path" --short-option "p" --description "Output file or directory" --require-parameter
|
||||
__flameshot_complete gui --long-option "clipboard" --short-option "c" --description "Copy screenshot to the clipboard" --no-files
|
||||
__flameshot_complete gui --long-option "delay" --short-option "d" --description "Delay time in milliseconds" --require-parameter --no-files
|
||||
__flameshot_complete gui --long-option "region" --description "Screenshot region to select (WxH+X+Y)" --require-parameter --arguments "(__flameshot_complete_region gui)"
|
||||
__flameshot_complete gui --long-option "last-region" --description "Repeat screenshot with previously selected region" --no-files
|
||||
__flameshot_complete gui --long-option "raw" --short-option "r" --description "Print raw PNG capture" --no-files
|
||||
__flameshot_complete gui --long-option "print-geometry" --short-option "g" --description "Print geometry of the selection" --no-files
|
||||
__flameshot_complete gui --long-option "upload" --short-option "u" --description "Upload the screenshot" --no-files
|
||||
__flameshot_complete gui --long-option "pin" --description "Pin the screenshot to the screen" --no-files
|
||||
__flameshot_complete gui --long-option "accept-on-select" --short-option "s" --description "Accept capture as soon as a selection is made" --no-files
|
||||
__flameshot_complete gui --long-option "help" --short-option "h" --description "Show the available arguments" --no-files
|
||||
|
||||
# SCREEN subcommand
|
||||
__flameshot_complete screen --no-files
|
||||
__flameshot_complete screen --long-option "number" --short-option "n" --description "Screen number (starting from 0)" --require-parameter --no-files --arguments "(__flameshot_complete_screen_number)"
|
||||
__flameshot_complete screen --long-option "path" --short-option "p" --description "Output file or directory" --require-parameter
|
||||
__flameshot_complete screen --long-option "clipboard" --short-option "c" --description "Copy screenshot to the clipboard" --no-files
|
||||
__flameshot_complete screen --long-option "delay" --short-option "d" --description "Delay time in milliseconds" --require-parameter --no-files
|
||||
__flameshot_complete screen --long-option "region" --description "Screenshot region to select (WxH+X+Y)" --require-parameter --no-files --arguments "(__flameshot_complete_region screen)"
|
||||
__flameshot_complete screen --long-option "raw" --short-option "r" --description "Print raw PNG capture" --no-files
|
||||
__flameshot_complete screen --long-option "upload" --short-option "u" --description "Upload the screenshot" --no-files
|
||||
__flameshot_complete screen --long-option "pin" --description "Pin the screenshot to the screen" --no-files
|
||||
__flameshot_complete screen --long-option "help" --short-option "h" --description "Show the available arguments" --no-files
|
||||
|
||||
# FULL command
|
||||
__flameshot_complete full --no-files
|
||||
__flameshot_complete full --long-option "path" --short-option "p" --description "Output file or directory" --require-parameter
|
||||
__flameshot_complete full --long-option "clipboard" --short-option "c" --description "Copy screenshot to the clipboard" --no-files
|
||||
__flameshot_complete full --long-option "delay" --short-option "d" --description "Delay time in milliseconds" --require-parameter --no-files
|
||||
__flameshot_complete full --long-option "region" --description "Screenshot region to select (WxH+X+Y)" --require-parameter --no-files --arguments "(__flameshot_complete_region full)" --keep-order
|
||||
__flameshot_complete full --long-option "raw" --short-option "r" --description "Print raw PNG capture" --no-files
|
||||
__flameshot_complete full --long-option "upload" --short-option "u" --description "Upload the screenshot" --no-files
|
||||
__flameshot_complete full --long-option "help" --short-option "h" --description "Show the available arguments" --no-files
|
||||
|
||||
# LAUNCHER command
|
||||
__flameshot_complete launcher --no-files
|
||||
|
||||
# CONFIG command
|
||||
__flameshot_complete config --no-files
|
||||
__flameshot_complete config --long-option "autostart" --short-option "a" --description "Enable or disable run at startup" --require-parameter --no-files --arguments "true false"
|
||||
__flameshot_complete config --long-option "filename" --short-option "f" --description "Set the filename pattern" --require-parameter --no-files
|
||||
__flameshot_complete config --long-option "notification" --short-option "n" --description "Enable or disable the notification" --require-parameter --no-files --arguments "true false"
|
||||
__flameshot_complete config --long-option "trayicon" --short-option "t" --description "Enable or disable the tray icon" --require-parameter --no-files --arguments "true false"
|
||||
__flameshot_complete config --long-option "showhelp" --short-option "s" --description "Show the help message in the capture mode" --require-parameter --no-files --arguments "true false"
|
||||
__flameshot_complete config --long-option "maincolor" --short-option "m" --description "Define the main UI color (hexadecimal)" --require-parameter --no-files
|
||||
__flameshot_complete config --long-option "contrastcolor" --short-option "k" --description "Define the contrast UI color (hexadecimal)" --require-parameter --no-files
|
||||
__flameshot_complete config --long-option "check" --description "Check the configuration for errors" --no-files
|
||||
__flameshot_complete config --long-option "help" --short-option "h" --description "Show the available arguments" --no-files
|
||||
@@ -0,0 +1,162 @@
|
||||
#compdef flameshot
|
||||
# ------------------------------------------------------------------------------
|
||||
# Description
|
||||
# -----------
|
||||
#
|
||||
# Completion script for the flameshot command line interface
|
||||
# (https://github.com/flameshot-org/flameshot).
|
||||
#
|
||||
# ------------------------------------------------------------------------------
|
||||
# How to use
|
||||
# -------
|
||||
#
|
||||
# Copy this file to /usr/share/zsh/site-functions/_flameshot
|
||||
#
|
||||
|
||||
|
||||
# gui
|
||||
|
||||
_flameshot_gui_opts=(
|
||||
{-p,--path}'[Existing directory or new file to save to]':dir:_files
|
||||
{-c,--clipboard}'[Save the capture to the clipboard]'
|
||||
{-d,--delay}'[Delay time in milliseconds]'
|
||||
"--region[Screenshot region to select <WxH+X+Y or string>]"
|
||||
"--last-region[Repeat screenshot with previously selected region]"
|
||||
{-r,--raw}'[Print raw PNG capture]'
|
||||
{-g,--print-geometry}'[Print geometry of the selection in the format WxH+X+Y. Does nothing if raw is specified]'
|
||||
{-u,--upload}'[Upload screenshot]'
|
||||
"--pin[Pin the capture to the screen]"
|
||||
{-s,--accept-on-select}'[Accept capture as soon as a selection is made]'
|
||||
{-h,--help}'[Show the available arguments]'
|
||||
)
|
||||
|
||||
_flameshot_gui() {
|
||||
_arguments -s : \
|
||||
"$_flameshot_gui_opts[@]"
|
||||
}
|
||||
|
||||
|
||||
# screen
|
||||
|
||||
_flameshot_screen_opts=(
|
||||
{-n,--number}'[Define the screen to capture (starting from 0). Default: screen containing the cursor]'
|
||||
{-p,--path}'[Existing directory or new file to save to]':dir:_files
|
||||
{-c,--clipboard}'[Save the capture to the clipboard]'
|
||||
{-d,--delay}'[Delay time in milliseconds]'
|
||||
"--region[Screenshot region to select <WxH+X+Y or string>]"
|
||||
{-r,--raw}'[Print raw PNG capture]'
|
||||
{-u,--upload}'[Upload screenshot]'
|
||||
"--pin[Pin the capture to the screen]"
|
||||
{-h,--help}'[Show the available arguments]'
|
||||
)
|
||||
|
||||
_flameshot_screen() {
|
||||
_arguments -s : \
|
||||
"$_flameshot_screen_opts[@]"
|
||||
}
|
||||
|
||||
|
||||
# full
|
||||
|
||||
_flameshot_full_opts=(
|
||||
{-p,--path}'[Existing directory or new file to save to]':dir:_files
|
||||
{-c,--clipboard}'[Save the capture to the clipboard]'
|
||||
{-d,--delay}'[Delay time in milliseconds]'
|
||||
"--region[Screenshot region to select <WxH+X+Y or string>]"
|
||||
{-r,--raw}'[Print raw PNG capture]'
|
||||
{-u,--upload}'[Upload screenshot]'
|
||||
{-h,--help}'[Show the available arguments]'
|
||||
)
|
||||
|
||||
_flameshot_full() {
|
||||
_arguments -s : \
|
||||
"$_flameshot_full_opts[@]"
|
||||
}
|
||||
|
||||
|
||||
# config
|
||||
|
||||
_flameshot_config_opts=(
|
||||
{-a,--autostart}'[Enable or disable run at startup (true/false)]'
|
||||
{-f,--filename}'[Set the filename pattern]'
|
||||
{-n,--notification}'[Enable or disable the notification (true/false)]'
|
||||
{-t,--trayicon}'[Enable or disable the tray icon (true/false)]'
|
||||
{-s,--showhelp}'[Show the help message in the capture mode (true/false)]'
|
||||
{-m,--maincolor}'[Define the main UI color (hexadecimal)]'
|
||||
{-k,--contrastcolor}'[Define the contrast UI color (hexadecimal)]'
|
||||
"--check[Check the configuration for errors]"
|
||||
{-h,--help}'[Show the available arguments]'
|
||||
)
|
||||
|
||||
_flameshot_config() {
|
||||
_arguments -s : \
|
||||
"$_flameshot_config_opts[@]"
|
||||
}
|
||||
|
||||
|
||||
# Main handle
|
||||
_flameshot() {
|
||||
local curcontext="$curcontext" ret=1
|
||||
local -a state line commands
|
||||
|
||||
commands=(
|
||||
"gui:Start the manual capture in GUI mode"
|
||||
"screen:Capture a single screen (one monitor)"
|
||||
"full:Capture the entire desktop (all monitors)"
|
||||
"launcher:Open the capture launcher"
|
||||
"config:Configure Flameshot"
|
||||
)
|
||||
|
||||
_arguments -C -s -S -n \
|
||||
'(- 1 *)'{-v,--version}"[display version information]: :->full" \
|
||||
'(- 1 *)'{-h,--help}'[[display usage information]: :->full' \
|
||||
'1:cmd:->cmds' \
|
||||
'*:: :->args' && ret=0
|
||||
|
||||
case "$state" in
|
||||
(cmds)
|
||||
_describe -t commands 'commands' commands
|
||||
;;
|
||||
(args)
|
||||
local cmd
|
||||
cmd=$words[1]
|
||||
case "$cmd" in
|
||||
(gui)
|
||||
_flameshot_gui && ret=0
|
||||
;;
|
||||
(screen)
|
||||
_flameshot_screen && ret=0
|
||||
;;
|
||||
(full)
|
||||
_flameshot_full && ret=0
|
||||
;;
|
||||
(config)
|
||||
_flameshot_config && ret=0
|
||||
;;
|
||||
(*)
|
||||
_default && ret=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
(*)
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
_flameshot
|
||||
|
||||
#
|
||||
# Editor modelines - https://www.wireshark.org/tools/modelines.html
|
||||
#
|
||||
# Local variables:
|
||||
# mode: sh
|
||||
# c-basic-offset: 4
|
||||
# tab-width: 4
|
||||
# indent-tabs-mode: nil
|
||||
# End:
|
||||
#
|
||||
# vi: set filetype=zsh shiftwidth=4 tabstop=4 expandtab:
|
||||
# :indentSize=4:tabSize=4:noTabs=true:
|
||||
#
|
||||
Reference in new issue
Block a user