From cb962a4a1fff1f11e1f3f56493b1c34ddd07c18e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 22 Dec 2014 00:49:22 +0100 Subject: shell: read from .zsh/* in the home directory we used to read every file located in .zsh/ directory. however, if the cwd is not $HOME/, then the shell will try to source different files. fixed by replacing .zsh/* by $ZDOTDIR/.zsh/* or $HOME/.zsh/* Signed-off-by: Olivier Gayot --- user/.zshrc | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/user/.zshrc b/user/.zshrc index 6b9a95c..c3548b8 100644 --- a/user/.zshrc +++ b/user/.zshrc @@ -1,15 +1,25 @@ function __source_startup_files() { # source the global configution file - local file="/etc/zshrc" + local __source_file="/etc/zshrc" - if [ -r "$file" ]; then - source "$file" + if [ -r "$__source_file" ]; then + source "$__source_file" + fi + + local __source_dir + + if [ -n "$ZDOTDIR" ]; then + __source_dir="$ZDOTDIR/.zsh" + elif [ -n "$HOME" ]; then + __source_dir="$HOME/.zsh" + else + return fi # source every file readable in .zsh - for file in $(find ".zsh" -type f -readable); do - source "$file" + for __source_file in $(find "$__source_dir" -type f -readable); do + source "$__source_file" done } -- cgit v1.2.3