summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Gayot <duskcoder@gmail.com>2014-12-22 00:49:22 +0100
committerOlivier Gayot <duskcoder@gmail.com>2014-12-22 00:57:53 +0100
commitcb962a4a1fff1f11e1f3f56493b1c34ddd07c18e (patch)
treed4fc4531b02a75505469b4c3638407621b9d75e7
parenta4c290620e32ac7737bbd545c35387b4a3a3461d (diff)
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 <duskcoder@gmail.com>
-rw-r--r--user/.zshrc20
1 files 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
}