# bash completion for geeqie                              -*- shell-script -*-

file_types='@(3fr|ani|arw|avif|bmp|cr2|cr3|crw|cur|dds|djvu|dng|erf|exr|.fits|fit|fts|gif|gqv|heic|heif|ico|jp2|jpe|jpeg|jpg|jps|jxl|kdc|mef|mos|mpo|mrw|nef|npy|nrw|orf|pbm|pdf|pef|pgm|png|pnm|ppm|psd|qif|qtif|raf|raw|rw2|scr|sr2|srf|svg|svgz|tga|tif|tiff|webp|xbm|xpm)'

actions='about add-mark-0 add-mark-1 add-mark-2 add-mark-3 add-mark-4 add-mark-5 add-mark-6 add-mark-7 add-mark-8 add-mark-9 orientation-original animate back clear-marks close-window color-profile-0 color-profile-1 color-profile-2 color-profile-3 color-profile-4 color-profile-5 connect-zoom-1-1 connect-zoom-2-1 connect-zoom-1-4 connect-zoom-3-1 connect-zoom-1-3 connect-zoom-4-1 connect-zoom-1-2 connect-zoom-fill-horizontal connect-zoom-fill-vertical connect-zoom-fit connect-zoom-in connect-zoom-out copy copy-image copy-path copy-path-unquoted crop::4-3 crop-none crop::1-1 crop-rectangle crop::16-9 crop::3-2 cut-path delete delete-window draw-rectangle escape exif-rotate exif-win filter-mark-0 filter-mark-1 filter-mark-2 filter-mark-3 filter-mark-4 filter-mark-5 filter-mark-6 filter-mark-7 filter-mark-8 filter-mark-9 find-duplicates first-image first-page flip float-tools folder-tree forward fullscreen grayscale help-change-log help-contents help-kbd help-notes help-pdf help-search help-shortcuts hide-bars hide-selectable-toolbars hide-tools histogram-channel-blue histogram-channel-cycle histogram-channel-green histogram-channel-red histogram-channel-rgb histogram-channel-v histogram-mode-cycle histogram-mode-linear histogram-mode-log home ignore-alpha image-back image-forward image-histogram image-overlay image-overlay-cycle intersect-mark-0 intersect-mark-1 intersect-mark-2 intersect-mark-3 intersect-mark-4 intersect-mark-5 intersect-mark-6 intersect-mark-7 intersect-mark-8 intersect-mark-9 keyword-autocomplete last-image last-page configure-window	 log-window maintenance mark-0 mark-1 mark-2 mark-3 mark-4 mark-5 mark-6 mark-7 mark-8 mark-9 mirror move new-collection new-folder new-window new-window-default new-window-from-current next-image next-page open-archive open-collection open-file open-recent-file open-with osd-1 osd-2 osd-3 osd-4 over-under-exposed pan-view permanent-delete plugins preferences previous-image previous-page print quit rating-0 rating-1 rating-2 rating-3 rating-4 rating-5 rating-rejected rectangular-selection refresh rename rename-window clear-mark-0 clear-mark-1 clear-mark-2 clear-mark-3 clear-mark-4 clear-mark-5 clear-mark-6 clear-mark-7 clear-mark-8 clear-mark-9 rotate-180 rotate-ccw-90 rotate-cw-90 s-bar s-bar-sort save-metadata search search-and-run-command select-all select-invert select-mark-0 select-mark-1 select-mark-2 select-mark-3 select-mark-4 select-mark-5 select-mark-6 select-mark-7 select-mark-8 select-mark-9 select-none select-osd set-mark-0 set-mark-1 set-mark-2 set-mark-3 set-mark-4 set-mark-5 set-mark-6 set-mark-7 set-mark-8 set-mark-9 show-file-filter show-info-pixel show-marks slide-show slide-show-faster slide-show-pause slide-show-slower split-down-pane split-horizontal split-next-pane split-pane-sync split-previous-pane split-quad split-single split-triple split-up-pane split-vertical stereo-auto stereo-cross stereo-cycle stereo-off stereo-side-by-side thumbnails toggle-mark-0 toggle-mark-1 toggle-mark-2 toggle-mark-3 toggle-mark-4 toggle-mark-5 toggle-mark-6 toggle-mark-7 toggle-mark-8 toggle-mark-9 deselect-mark-0 deselect-mark-1 deselect-mark-2 deselect-mark-3 deselect-mark-4 deselect-mark-5 deselect-mark-6 deselect-mark-7 deselect-mark-8 deselect-mark-9 up use-color-profiles use-image-profile view-icons view-in-new-window view-list write-rotation write-rotation-keep-date zoom-1-1 zoom-2-1 zoom-1-4 zoom-3-1 zoom-1-3 zoom-4-1 zoom-1-2 zoom-fill-horizontal zoom-fill-vertical zoom-fit zoom-in zoom-out zoom-to-rectangle'

options='--action= --action-list --back --cache-metadata --cache-render= --cache-render-recurse= --cache-render-shared= --cache-render-shared-recurse= --cache-shared= --cache-thumbs= --close-window --config-load= --debug= --delay= --dupes= --dupes-export --dupes-recurse= --file= --File= --file-extensions --first --fullscreen --geometry= --get-collection= --get-collection-list --get-destination= --get-file-info --get-filelist= --get-filelist-recurse= --get-rectangle --get-render-intent --get-selection --get-sidecars= --get-window-list --grep= --help --id= --last --log-file= --lua= --new-window --next --pixel-info --print0 --quit --raise --selection-add= --selection-clear --selection-remove= --show-log-window --slideshow --slideshow-recurse= --tell --tools --view= --version'

_geeqie()
{
	local cur prev
	_init_completion -s || return

	case "$prev" in
		--action)
	 		COMPREPLY=($(compgen -W '$actions' -- "$cur"))
			return
			;;

		--cache-shared | --cache-thumbs)
			COMPREPLY=($(compgen -W 'clean clear' -- "$cur"))
			return
			;;

		--config-load)
			_filedir xml
			return
			;;

		--file | --File | --get-destination | --get-sidecars | --list-add | --selection-add | --selection-remove | --view)
			_filedir $file_types
			return
			;;

		--get-collection)
			collection="$(find $HOME/.local/share/geeqie/collections/ -maxdepth 1  -name "*gqv" -exec basename {} \;)"
			COMPREPLY=($(compgen -W '$collection' -- "$cur"))
			return
			;;

		--lua)
			_filedir lua
			return
			;;
	esac

	if [[ $cur == -* ]]
	then
		COMPREPLY=($(compgen -W '$options' -- "$cur"))

		[[ ${COMPREPLY-} == *[=] ]] && compopt -o nospace
		return
	fi

_filedir $file_types

} &&  complete -F _geeqie geeqie

# ex: filetype=sh
