[zsh] Establish a DOTFILES_HOME variable
Look for a config file at ~/.config/dotfiles-home that contains the path to the repo, or check the usual location of ~/.dotfiles. Do this in a shell function in .zshenv so it's repeatable. This needs to be done very early in the init process.
This commit is contained in:
parent
0d3b4a232f
commit
cbebbffee0
2 changed files with 18 additions and 1 deletions
17
zshenv
17
zshenv
|
|
@ -5,6 +5,22 @@ unsetopt GLOBAL_RCS
|
|||
|
||||
export SYS=`uname -s | tr A-Z a-z`
|
||||
|
||||
function init-env-dotfiles-path
|
||||
{
|
||||
local dotfiles_config="$HOME/.config/dotfiles-home"
|
||||
if [[ -f "$dotfiles_config" ]]; then
|
||||
export DOTFILES_HOME=$(cat "$dotfiles_config")
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$HOME/.dotfiles/setup.sh" ]]; then
|
||||
export DOTFILES_HOME="$HOME/.dotfiles"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "WARNING: Couldn't find path to dotfiles" 1>&2
|
||||
}
|
||||
|
||||
function init-env-fpath
|
||||
{
|
||||
local -r fpath_candidates=( \
|
||||
|
|
@ -23,6 +39,7 @@ function init-env-fpath
|
|||
done
|
||||
}
|
||||
|
||||
init-env-dotfiles-path
|
||||
init-env-fpath
|
||||
|
||||
autoload -Uz do_init_functions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue