~/.zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# .zshrc | |
# | |
# Access custom aliases in the shell | |
[ -e "${HOME}/.zsh_aliases" ] && source "${HOME}/.zsh_aliases" | |
# Fix command not found after installation | |
# https://bbs.archlinux.org/viewtopic.php?id=175388 | |
zstyle ':completion:*' rehash true | |
# Update shell aliases immediately | |
ALIAS_FILE="${HOME}/.zsh_aliases" | |
reload_aliases () { | |
# do nothing if there is no $ALIAS_FILE | |
[[ -e $ALIAS_FILE ]] || return 1 | |
# check if $ALIAS_FILE has been modified since last reload | |
if [[ $LAST_ALIAS_RELOAD < $(stat -c %Y $ALIAS_FILE) ]]; then | |
# remove all aliases; optional! | |
# only do this if all of your aliases are defined in $ALIAS_FILE | |
# also affects aliases defined on the command line | |
unalias -m '*' | |
# load aliases | |
source $ALIAS_FILE | |
# update date of last reload | |
LAST_ALIAS_RELOAD=$(date +%s) | |
fi | |
} | |
# make reload_aliases to be run before each prompt | |
autoload -Uz add-zsh-hook | |
add-zsh-hook precmd reload_aliases |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment