File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 22
33_xdg_mime_mimetype ()
44{
5- COMPREPLY+=($( compgen -S / -W ' application audio font image message model
6- multipart text video' -- " $cur " ) )
7- [[ ${COMPREPLY-} == * / ]] && compopt -o nospace
5+ local d i
6+ local -a arr
7+ for d in /usr/share/mime /usr/local/share/mime; do
8+ arr=($(
9+ command cd " $d " 2> /dev/null || exit 1
10+ compgen -f -o plusdirs -X " !*.xml" -- " $cur "
11+ ) ) || continue
12+ for i in " ${! arr[*]} " ; do
13+ case ${arr[i]} in
14+ packages* ) unset -v " arr[i]" ;; # not a MIME type dir
15+ * .xml) arr[i]=${arr[i]% .xml} ;;
16+ * /* ) ;;
17+ * ) arr[i]+=/ ;;
18+ esac
19+ done
20+ (( ${# arr[@]} )) &&
21+ COMPREPLY+=(" ${arr[@]} " )
22+ done
23+ [[ ${COMPREPLY-} != * / ]] || compopt -o nospace
824}
925
1026_xdg_mime ()
@@ -31,7 +47,8 @@ _xdg_mime()
3147 COMPREPLY=($( compgen -W ' filetype default' -- " $cur " ) )
3248 return
3349 fi
34- case ${words[2]} in # TODO and args == 3 (takes only one arg!)
50+ (( args == 3 )) || return
51+ case ${words[2]} in
3552 filetype) _filedir ;;
3653 default) _xdg_mime_mimetype ;;
3754 esac
Original file line number Diff line number Diff line change @@ -19,10 +19,14 @@ def test_3(self, completion):
1919 def test_4 (self , completion ):
2020 assert completion
2121
22- @pytest .mark .complete ("xdg-mime default foo.desktop " )
22+ @pytest .mark .complete ("xdg-mime default foo.desktop " , require_cmd = True )
2323 def test_5 (self , completion ):
2424 assert completion
2525
2626 @pytest .mark .complete ("xdg-mime install --mode " )
2727 def test_6 (self , completion ):
2828 assert completion
29+
30+ @pytest .mark .complete ("xdg-mime query filetype foo " )
31+ def test_filetype_one_arg (self , completion ):
32+ assert not completion
Original file line number Diff line number Diff line change 429429wsimport
430430wtf
431431wvdial
432+ xdg-mime
432433xdg-settings
433434xev
434435xfreerdp
You can’t perform that action at this time.
0 commit comments