From: Eric Cook <llua@gmx.com>
To: zsh-workers@zsh.org
Subject: Re: [PATCH v2] zsh locale completion
Date: Wed, 1 Jun 2016 23:32:12 -0400 [thread overview]
Message-ID: <db4c6937-9a98-ae57-1f3f-01a034936f76@gmx.com> (raw)
In-Reply-To: <574C7A09.7010800@redhat.com>
Tweaked it a little and tested it on freebsd, openbsd and netbsd.
I currently lack access to a dragonflybsd and solaris/illumos machine.
---
Completion/Unix/Command/_locale | 84 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
create mode 100644 Completion/Unix/Command/_locale
diff --git a/Completion/Unix/Command/_locale b/Completion/Unix/Command/_locale
new file mode 100644
index 0000000..87775be
--- /dev/null
+++ b/Completion/Unix/Command/_locale
@@ -0,0 +1,84 @@
+#compdef locale
+
+local curcontext="$curcontext" state state_descr line expl ret=1
+typeset -A opt_args; local -a specs aopts
+
+if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then
+
+ local exargs="-? --help --usage -V --version"
+
+ aopts=( -A "-*" -C -S -s )
+ specs=(
+ '(- *)'{-\?,--help}'[display help information]'
+ '(- *)--usage[display a short usage message]'
+ '(- *)'{-V,--version}'[print program version]'
+ - set1
+ "(-a --all-locales $exargs)"{-a,--all-locales}'[list all available locales]'
+ "(-v --verbose $exargs)"{-v,--verbose}'[display additional information]'
+ - set2
+ "(-m --charmaps $exargs)"{-m,--charmaps}'[list all available charmaps]'
+ - set3
+ "(-c --category-name $exargs)"{-c,--category-name}'[print also locale category]'
+ "(-k --keyword-name $exargs)"{-k,--keyword-name}'[print also keyword of each value]'
+ '*:name:->catkey'
+ )
+
+elif [[ $OSTYPE == openbsd* ]]; then
+
+ specs=(
+ '(-m)-a[list all available locales]'
+ '(-a)-m[list all available charmaps]'
+ )
+
+else
+
+ aopts=( -C -A "-*" )
+ specs=(
+ - set1
+ '-a[list all available locales]'
+ - set2
+ '-m[list all available charmaps]'
+ - set3
+ '-c[print also locale category]'
+ '-k[print also keyword of each value]'
+ '*:name:->catkey'
+ )
+fi
+
+_arguments $aopts : $specs && ret=0
+
+if [[ $state == catkey ]]; then
+ typeset -aU cats keys
+
+ case $OSTYPE in
+ *bsd*)
+ # keywords from comparing locale -k list on netbsd and freebsd
+ # the additional keywords freebsd supports will be added via
+ # the reassignment of keys
+ keys+=(
+ charmap decimal_point thousands_sep grouping radixchar thousep int_curr_symbol
+ currency_symbol mon_decimal_point mon_thousands_sep mon_grouping positive_sign
+ negative_sign int_frac_digits frac_digits p_cs_precedes p_sep_by_space n_cs_precedes
+ n_sep_by_space p_sign_posn n_sign_posn int_p_cs_precedes int_p_sep_by_space
+ int_n_cs_precedes int_n_sep_by_space int_p_sign_posn int_n_sign_posn d_t_fmt d_fmt
+ t_fmt am_str pm_str t_fmt_ampm day_1 day_2 day_3 day_4 day_5 day_6 day_7 abday_1
+ abday_2 abday_3 abday_4 abday_5 abday_6 abday_7 mon_1 mon_2 mon_3 mon_4 mon_5 mon_6
+ mon_7 mon_8 mon_9 mon_10 mon_11 mon_12 abmon_1 abmon_2 abmon_3 abmon_4 abmon_5
+ abmon_6 abmon_7 abmon_8 abmon_9 abmon_10 abmon_11 abmon_12 era era_d_fmt era_d_t_fmt
+ era_t_fmt alt_digits yesexpr noexpr yesstr nostr
+ );|
+ (free|net|dragonfly)bsd*) (( words[(I)-k] )) && keys+=(list);;
+ *)
+ cats=( ${${${(f)"$(locale)"}%=*}%(LANG|LANGUAGE|LC_ALL)} )
+ ;;
+ esac
+
+ keys=( $keys ${${(f)"$(locale -k $cats 2>/dev/null)"}%=*} )
+ if [[ $OSTYPE == freebsd* ]] && (( words[(I)list] )); then
+ _message -e values prefix && ret=0
+ else
+ _wanted values expl name compadd "$@" -a - cats keys && ret=0
+ fi
+fi
+
+return ret
--
2.6.6
next prev parent reply other threads:[~2016-06-02 3:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 17:36 Marko Myllynen
2016-06-02 3:32 ` Eric Cook [this message]
2016-06-02 11:51 ` Marko Myllynen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=db4c6937-9a98-ae57-1f3f-01a034936f76@gmx.com \
--to=llua@gmx.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).