@ -1,6 +1,6 @@
#!/bin/zsh
# .files/installer
# (c) 2014 MORI Taeyeon
# .files/install
# (c) 2014-2017 MORI Taeyeon
# Paths & Utils
DOT="$(realpath "$(dirname "$0")")"
@ -9,7 +9,9 @@ cd "$DOT"
setopt EXTENDED_GLOB
source "$DOT/lib/libzsh-utils.zsh"
# Parse commandline
# =============================
OVERWRITE=false
ASK=true
@ -41,7 +43,9 @@ for arg in "$@"; do
done
[[ -n "$STATE" ]] && err "Option $STATE is missing it's parameter!" && exit 1
# Helper functions
# =============================
function generate() {
[[ -e "$1" ]] && ! $OVERWRITE && ! grep -q "Generated by .files/install" "$1" && \
err "Custom version of $1 detected. Please delete it before running .files/install" && exit 1
@ -58,6 +62,9 @@ function relink() {
color 31 ln -s "$(relpath "$1" "$(dirname "$2")")" "$2"
}
# Prepare
# =============================
# Update git modules
msg "Updating git submodules..."
git submodule update --init --recursive
@ -77,12 +84,16 @@ else
color 36 echo " default EMAIL=\"$EMAIL\""
fi
# Write down answers
color 32 echo " Writing etc/user-info"
generate "$DOT/etc/user-info" <<EOF
REALNAME="$REALNAME"
EMAIL="$EMAIL"
EOF
# Write files to $HOME
# =============================
# Setup dotfiles
msg "Linking dotfiles..."
for file in "$DOT/dotfiles"/*; do
@ -113,7 +124,9 @@ msg "Linking .config files... ($XDG_CONFIG_HOME)"
done
)
# Setup git
# =============================
msg "Setting up Git configuration..."
GIT="$DOT/git"
@ -138,7 +151,9 @@ generate "$GIT/user-info" <<EOF
email = $EMAIL
EOF
# Setup ZSH/Prezto
# =============================
msg "Setting up ZSH configuration..."
ZSH="$DOT/zsh"
@ -154,7 +169,10 @@ for file in zshrc zpreztorc zlogin zlogout zprofile; do
relink "$ZSH/$file" "$ZSH/.$file"
done
relink "$ZSH/prezto" "$ZSH/.zprezto"
# Do misc setup
# =============================
test -f "$DOTFILES/install.extra" && "$DOTFILES/install.extra"
# Check login shell
if getent passwd $(id -un) | grep -q 'zsh$'; then
@ -164,7 +182,7 @@ else
chsh -s "$(which zsh)"
fi
# Done.
warn "You may need to relog for all changes to take effect."
warn "If you're currently running zsh, you definitely need to at least restart the shell to apply changes."