return 1
}
+is433(){
+ [[ $ZSH_VERSION == 4.3.<3->* || $ZSH_VERSION == <5->* ]] && return 0
+ return 1
+}
+
#f1# Checks whether or not you're running grml
isgrml(){
[[ -f /etc/grml_version ]] && return 0
# this allows us to stay in sync with grml's zshrc and put own
# modifications in ~/.zshrc.local
zrclocal() {
+ xsource "/etc/zsh/zshrc.local"
xsource "${HOME}/.zshrc.local"
return 0
}
# locale setup {{{
xsource "/etc/default/locale"
-export LANG=${LANG:-en_US.iso885915}
-for var in LC_ALL LC_MESSAGES ; do
+for var in LANG LC_ALL LC_MESSAGES ; do
[[ -n ${(P)var} ]] && export $var
done
# }}}
+# directory based profiles {{{
+
+if is433 ; then
+
+CHPWD_PROFILE='default'
+function chpwd_profiles() {
+ # Say you want certain settings to be active in certain directories.
+ # This is what you want.
+ #
+ # zstyle ':chpwd:profiles:/usr/src/grml(|/|/*)' profile grml
+ # zstyle ':chpwd:profiles:/usr/src/debian(|/|/*)' profile debian
+ #
+ # When that's done and you enter a directory that matches the pattern
+ # in the third part of the context, a function called chpwd_profile_grml,
+ # for example, is called (if it exists).
+ #
+ # If no pattern patches (read: no profile is detected) the profile is
+ # set to 'default', which means chpwd_profile_default is attempted to
+ # be called.
+ #
+ # The name of the detected profile will be available in a variable called
+ # 'profile' in your functions. You don't need to do anything, it'll just
+ # be there.
+ #
+ # Then there is the parameter $CHPWD_PROFILE is set to the profile, that
+ # was is currently active. That way you can avoid running code for a
+ # profile that is already active, by running code such as the following
+ # at the start of your function:
+ #
+ # function chpwd_profile_grml() {
+ # [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
+ # ...
+ # }
+ #
+ # The initial value for $CHPWD_PROFILE is 'default'.
+ #
+ # Version requirement:
+ # This feature requires zsh 4.3.3 or newer.
+ # If you use this feature and need to know whether it is active in your
+ # current shell, there are several ways to do that. Here are two simple
+ # ways:
+ #
+ # a) If knowing if the profiles feature is active when zsh starts is
+ # good enough for you, you can put the following snippet into your
+ # .zshrc.local:
+ #
+ # (( ${+functions[chpwd_profiles]} )) && print "directory profiles active"
+ #
+ # b) If that is not good enough, and you would prefer to be notified
+ # whenever a profile changes, you can solve that by making sure you
+ # start *every* profile function you create like this:
+ #
+ # function chpwd_profile_myprofilename() {
+ # [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
+ # print "chpwd(): Switching to profile: $profile"
+ # ...
+ # }
+ #
+ # That makes sure you only get notified if a profile is *changed*,
+ # not everytime you change directory, which would probably piss
+ # you off fairly quickly. :-)
+ #
+ # There you go. Now have fun with that.
+ local -x profile
+
+ zstyle -s ":chpwd:profiles:${PWD}" profile profile || profile='default'
+ if (( ${+functions[chpwd_profile_$profile]} )) ; then
+ chpwd_profile_${profile}
+ fi
+
+ CHPWD_PROFILE="${profile}"
+ return 0
+}
+chpwd_functions=( ${chpwd_functions} chpwd_profiles )
+
+fi # is433
+
+# }}}
+
# {{{ display battery status on right side of prompt via running 'BATTERY=1 zsh'
if [[ $BATTERY -gt 0 ]] ; then
if ! check_com -c acpi ; then
# adjust title of xterm
[[ ${NOTITLE} -gt 0 ]] && return 0
case $TERM in
- (xterm*|rxvt)
+ (xterm*|rxvt*)
print -Pn "\e]0;%n@%m: $1\a"
;;
esac
for color in BLUE RED GREEN CYAN YELLOW MAGENTA WHITE ; unset $color
# }}}
-# source another config file if present {{{
-xsource "/etc/zsh/zshrc.local"
-# }}}
-
# "persistent history" {{{
# just write important commands you always need to ~/.important_commands
if [[ -r ~/.important_commands ]] ; then