From 513546f59f9cc24e9ac86ff9d85c6b48f18d4e5a Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 3 Apr 2013 01:27:02 +0200 Subject: [PATCH] _id3: initial commit --- src/_id3 | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/_id3 diff --git a/src/_id3 b/src/_id3 new file mode 100644 index 0000000..9438466 --- /dev/null +++ b/src/_id3 @@ -0,0 +1,64 @@ +#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 +