# zshrc/90_profiles # # set up directory specific variables and options # # http://michael-prokop.at/blog/2009/05/30/directory-specific-shell-configuration-with-zsh # # chpwd_profiles taken from grml zshrc # # Copyright © 2010-2017 Tobias Klauser # Released under the terms of the Artistic Licence 2.0 # # Source repository: git://git.distanz.ch/dotfiles/zsh.git CHPWD_PROFILE='default' zstyle ':chpwd:profiles:/home/tklauser/go/src/github.com/isovalent(|/|/*)' profile isovalent zstyle ':chpwd:profiles:/home/tklauser/go/src/github.com/covalentio(|/|/*)' profile isovalent zstyle ':chpwd:profiles:/home/tklauser/src/isovalent(|/|/*)' profile isovalent zstyle ':chpwd:profiles:/home/tklauser/src/cilium/cilium.io(|/|/*)' profile cilium zstyle ':chpwd:profiles:/home/tklauser/src/cilium/ebpf.io(|/|/*)' profile cilium zstyle ':chpwd:profiles:/home/tklauser/go(|/|/*)' profile distanz zstyle ':chpwd:profiles:/home/tklauser/src(|/|/*)' profile distanz chpwd_profile_distanz() { [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1 print "chpwd(): Switching to profile: $profile" export GIT_AUTHOR_EMAIL="tklauser@distanz.ch" export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" } chpwd_profile_cilium() { [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1 print "chpwd(): Switching to profile: $profile" export GIT_AUTHOR_EMAIL="tobias@cilium.io" export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" } chpwd_profile_isovalent() { [[ ${profile} == ${CHPWD_PROFILE} ]] && return 1 print "chpwd(): Switching to profile: $profile" export GIT_AUTHOR_EMAIL="tobias@isovalent.com" export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL" } function chpwd_profiles() { local profile context local -i reexecute context=":chpwd:profiles:$PWD" zstyle -s "$context" profile profile || profile='default' zstyle -T "$context" re-execute && reexecute=1 || reexecute=0 if (( ${+parameters[CHPWD_PROFILE]} == 0 )); then typeset -g CHPWD_PROFILE local CHPWD_PROFILES_INIT=1 (( ${+functions[chpwd_profiles_init]} )) && chpwd_profiles_init elif [[ $profile != $CHPWD_PROFILE ]]; then (( ${+functions[chpwd_leave_profile_$CHPWD_PROFILE]} )) \ && chpwd_leave_profile_${CHPWD_PROFILE} fi if (( reexecute )) || [[ $profile != $CHPWD_PROFILE ]]; then (( ${+functions[chpwd_profile_$profile]} )) && chpwd_profile_${profile} fi CHPWD_PROFILE="${profile}" return 0 } chpwd_functions=( ${chpwd_functions} chpwd_profiles ) # vim:ft=zsh