Add zsh-lookup sub-system
[grml-etc-core.git] / usr_share_grml / zsh / functions / Lookup / LOOKUP_context
1 ### vim:ft=zsh:foldmethod=marker
2 ## get and set the current context
3 ## Copyright: 2009, Frank Terbeck <ft@bewatermyfriend.org>
4
5 # If called without arguments, it spits out the current context.
6 # If called with -l <string> it sets the <localpart> of the context
7 # to <string>. If called with -d, it sets the <localpart> to its default.
8
9 LOOKUP_guard || return 1
10 local opt
11 local -A opts
12
13 lu_parseopts_args=( d bool l string )
14 LOOKUP_parseopts "$@" || return 1
15 if [[ ${opts[-d]} == 'yes' ]] ; then
16     lookup_lp="-default-"
17 elif [[ -n ${opts[-l]} ]] ; then
18     lookup_lp="${opts[-l]}"
19 else
20     printf ':lookup:%s:%s:%s' ${lookup_ei} ${backend} ${lookup_lp}
21 fi
22 return 0