change installation method

This commit is contained in:
Dmytro Meleshko 2018-08-23 11:40:09 +02:00
parent 09df7e7e39
commit 0d5c7c6e07
3 changed files with 29 additions and 34 deletions

18
install.sh Normal file → Executable file
View file

@ -1,5 +1,17 @@
#!/usr/bin/env bash
for script in {zhsrc,zlogin}.zsh; do
ln -sv "$script" ".$script"
done
ZSHRC=~/.zshrc
ZSHRC_BACKUP=~/.zshrc.pre-dmitmel-dotfiles
if [[ -f $ZSHRC ]]; then
echo "Backing up $ZSHRC to $ZSHRC_BACKUP"
mv $ZSHRC $ZSHRC_BACKUP
fi
cat > $ZSHRC <<EOF
#!/usr/bin/env zsh
export DOTFILES_PATH="\$HOME/.dotfiles"
export OH_MY_ZSH_PATH="\$HOME/.oh-my-zsh"
source "\$DOTFILES_PATH/zshrc"
EOF

View file

@ -1,16 +1,8 @@
#!/usr/bin/env zsh
find_oh_my_zsh() {
for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do
local zsh_dir="${prefix}oh-my-zsh"
if [[ -d "$zsh_dir" ]]; then
export ZSH="$zsh_dir"
break
fi
done
}
configure_oh_my_zsh() {
export ZSH="$OH_MY_ZSH_PATH"
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
export ZSH_THEME="agnoster"
@ -50,7 +42,6 @@ configure_zsh() {
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
}
find_oh_my_zsh
configure_oh_my_zsh
source "$ZSH/oh-my-zsh.sh"
configure_zsh

32
zshrc
View file

@ -1,26 +1,18 @@
#!/usr/bin/env zsh
find_dotfiles_dir() {
export DOTFILES_DIR
for prefix in "$HOME/." "/usr/share/" "/usr/local/share/"; do
DOTFILES_DIR="${prefix}dotfiles"
[[ -d "$DOTFILES_DIR" ]] && return
if [[ -n "$DOTFILES_PATH" && -n "$OH_MY_ZSH_PATH" ]]; then
for script in functions path exports aliases oh-my-zsh widgets; do
source "$DOTFILES_PATH/lib/$script.zsh"
done
local script_path="$(realpath "${(%):-%x}")"
DOTFILES_DIR="$(dirname "$script_path")"
}
source_if_exists "$ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh"
find_dotfiles_dir
run_before rbenv 'eval "$(rbenv init -)"'
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
run_before yarn 'source_if_exists "$(yarn global dir)/node_modules/tabtab/.completions/yarn.zsh"'
for script in functions path exports aliases oh-my-zsh widgets; do
source "$DOTFILES_DIR/lib/$script.zsh"
done
source_if_exists "$ZSH/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh"
run_before rbenv 'eval "$(rbenv init -)"'
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
run_before yarn 'source_if_exists "$(yarn global dir)/node_modules/tabtab/.completions/yarn.zsh"'
python "$DOTFILES_DIR/welcome/main.py"
python "$DOTFILES_PATH/welcome/main.py"
else
[[ -z "$DOTFILES_PATH" ]] && echo "please, set DOTFILES_PATH to the path to your dotfiles directory" >&2
[[ -z "$OH_MY_ZSH_PATH" ]] && echo "please, set OH_MY_ZSH_PATH to the path to your Oh My Zsh directory" >&2
fi