Skip to content

Instantly share code, notes, and snippets.

@orschiro
Created January 22, 2015 14:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orschiro/f51b4257be9f632d56d7 to your computer and use it in GitHub Desktop.
Save orschiro/f51b4257be9f632d56d7 to your computer and use it in GitHub Desktop.
~/.zshrc
#
# .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