blob: 3be49b15bd287fa1ed980e7d6f0e414aace9038a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# papirus-folders completion
#
# @author: Sergei Eremenko (https://github.com/SmartFinn)
# @license: MIT license (MIT)
# @link: https://github.com/PapirusDevelopmentTeam/papirus-folders
__get_colors() {
if ! command -v papirus-folders >/dev/null; then
return 1
fi
papirus-folders -l | tr -d '>\n'
}
__get_themes() {
local data_dir icons_dir icon_theme
local -a data_dirs=()
local -a icons_dirs=(
"$HOME/.icons"
"${XDG_DATA_HOME:-$HOME/.local/share}/icons"
)
# Get data directories from XDG_DATA_DIRS variable and
# convert colon-separated list into bash array
IFS=: read -ra data_dirs <<< "${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
for data_dir in "${data_dirs[@]}"; do
[ -d "$data_dir/icons" ] || continue
icons_dirs=( "${icons_dirs[@]}" "${data_dir%/}/icons" )
done
for icons_dir in "${icons_dirs[@]}"; do
for icon_theme in "$icons_dir"/*; do
[ -f "$icon_theme/48x48/places/folder-blue.svg" ] || continue
printf '%s\n' "${icon_theme##*/}"
done
done
return
}
_papirus_folders() {
local cur prev
local -a colors=( $(__get_colors) )
local -a opts=(
-h --help
-V --version
-v --verbose
-C --color
-D --default
-R --restore
-l --list
-o --once
-t --theme
-u --update-caches
)
_get_comp_words_by_ref cur prev
case "$prev" in
-C|--color)
COMPREPLY=( $(compgen -W "${colors[*]}" -- "${cur}") )
return
;;
-t|--theme)
COMPREPLY=( $(compgen -W "$(__get_themes)" -- "${cur}") )
;;
*)
COMPREPLY=( $(compgen -W "${opts[*]}" -- "${cur}") )
;;
esac
}
complete -F _papirus_folders papirus-folders
# ex: ts=4 sw=4 filetype=sh
|