use different zsh startup files

This commit is contained in:
Dmytro Meleshko 2018-11-09 21:28:28 +02:00
parent 5eaae4bcd2
commit a507119ab0
4 changed files with 27 additions and 14 deletions

View file

@ -1,16 +1,18 @@
#!/usr/bin/env bash
ZSHRC=~/.zshrc
ZSHRC_BACKUP=~/.zshrc.pre-dmitmel-dotfiles
for zsh_file_name in z{shenv,shrc,login}; do
zsh_file="${HOME}/.${zsh_file_name}"
if [[ -f $ZSHRC ]]; then
echo "Backing up $ZSHRC to $ZSHRC_BACKUP"
mv $ZSHRC $ZSHRC_BACKUP
fi
if [[ -f "$zsh_file" ]]; then
zsh_file_backup="${zsh_file}.dmitmel-dotfiles-backup"
echo "Backing up $zsh_file to $zsh_file_backup"
mv -vi "$zsh_file" "$zsh_file_backup"
fi
cat > $ZSHRC <<EOF
cat > "$zsh_file" <<EOF
#!/usr/bin/env zsh
export DOTFILES_PATH="\$HOME/.dotfiles"
source "\$DOTFILES_PATH/zshrc"
export DOTFILES_PATH="$PWD"
source "\$DOTFILES_PATH/$zsh_file_name"
EOF
done

5
zlogin Normal file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env zsh
if [[ -n "$DOTFILES_PATH" ]]; then
python "$DOTFILES_PATH/welcome/main.py"
fi

10
zshenv Normal file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env zsh
if [[ -n "$DOTFILES_PATH" ]]; then
for script in functions path exports; do
source "$DOTFILES_PATH/lib/$script.zsh"
source_if_exists "$DOTFILES_PATH/custom/$script.zsh"
done
else
echo "please, set DOTFILES_PATH to the path to your dotfiles directory" >&2
fi

6
zshrc
View file

@ -1,15 +1,11 @@
#!/usr/bin/env zsh
if [[ -n "$DOTFILES_PATH" ]]; then
for script in functions path exports oh-my-zsh aliases widgets theme; do
for script in oh-my-zsh aliases widgets theme; do
source "$DOTFILES_PATH/lib/$script.zsh"
source_if_exists "$DOTFILES_PATH/custom/$script.zsh"
done
run_before rbenv 'eval "$(rbenv init -)"'
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
python "$DOTFILES_PATH/welcome/main.py"
else
echo "please, set DOTFILES_PATH to the path to your dotfiles directory" >&2
fi