#compdef id3 # ------------------------------------------------------------------------------ # Description # ----------- # # Completion script for id3, based on v0.15 # # Last updated: 03.04.2013 # # ------------------------------------------------------------------------------ # Authors # ------- # # * Valodim ( https://github.com/Valodim ) # # ------------------------------------------------------------------------------ _id3_genre () { setopt localoptions extendedglob local -A _id3_genres # got them cached? if _cache_invalid id3-genres || ! _retrieve_cache id3-genres ; then # generate from id3 -L otherwise local tmp for line in ${${${(f)"$(_call_program id3genre id3 -L)"}## #}}; do tmp=( ${(s,: ,)line} ) _id3_genres[${tmp[1]}]=$tmp[2] # alternate display string, which I decided against in the end # to preserve reasonable alphabetic sorting # "${(l:3:: :)${tmp[1]}}: ${tmp[2]}" done # store if we got any (( $#_id3_genres > 0 )) && _store_cache id3-genres _id3_genres fi # bail if we don't (( $#_id3_genres > 0 )) || { _message "could not fetch genres"; return } _wanted id3genres expl 'Genres' \ compadd -d _id3_genres -k _id3_genres && return 0 } _arguments \ '-t[Modifies a Title tag]:title' \ '-T[Modifies a Track tag]:track' \ '-a[Modifies an Artist tag]:artist' \ '-A[Modifies an Album tag]:album' \ '-y[Modifies a Year tag]:year' \ '-c[Modifies a Comment tag]:comment' \ '-g[Modifies a Genre tag]:genre:_id3_genre' \ '(-)-l[Lists an ID3 tag]' \ '-R[Uses an rfc822-style format for output]' \ '(-)-d[Deletes an ID3 tag]' \ '(- *)-L[Lists all genres]' \ '(- *)-h[Displays this help info]' \ '(- *)-v[Prints version info]' \ '*:mp3 file:_files -g \*.mp3' && return 0