มันเป็นไปได้ที่จะทำเช่นนี้ - นี่เป็นscreencastใช้grml ZSH การกำหนดค่า
ข้อมูลเพิ่มเติม:
แก้ไข: นี่เป็นเรื่องง่ายที่จะทำ นี่คือส่วนที่เกี่ยวข้องของคุณ~/.zshrc
:
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
}
# Add the chpwd_profiles() function to the list called by chpwd()!
chpwd_functions=( ${chpwd_functions} chpwd_profiles )
เปิดใช้งานโปรไฟล์สำหรับแต่ละไดเรกทอรีที่คุณต้องการ:
zstyle ':chpwd:profiles:/path/to/directory(|/|/*)' profile NAME
และอย่าลืมสร้างโปรไฟล์จริงๆ:
chpwd_profile_NAME() {
[[ ${profile} == ${CHPWD_PROFILE} ]] && return 1
print "chpwd(): Switching to profile: $profile"
export VAR=value
}
แก้ไข # 2: จริง ๆ แล้วจะค่อนข้างเรียบร้อยคู่กับไดเรกทอรีชื่อ [Stackoverflow.net]