dotfiles/install.zsh

63 lines
1.4 KiB
Bash
Raw Normal View History

2018-06-23 10:10:33 -07:00
#!/usr/bin/env zsh
## TODO walk the file tree instead of manually linking files
2018-06-23 19:45:51 -07:00
link="ln -s"
2018-06-23 10:10:33 -07:00
rm="rm -rf"
emacs_dir="$HOME/.emacs.d"
nvim_dir="$HOME/.config/nvim"
function create_directories {
if [[ ! -d "$emacs_dir" ]]; then
mkdir "$emacs_dir"
fi
if [[ ! -d "$nvim_dir" ]]; then
mkdir "$nvim_dir"
fi
}
2018-06-23 10:10:33 -07:00
function uninstall {
eval $rm "$HOME/.zshrc"
eval $rm "$emacs_dir/init.el"
eval $rm "$emacs_dir/themes"
2018-06-23 10:10:33 -07:00
eval $rm "$HOME/.tmux.conf"
eval $rm "$nvim_dir/autoload"
eval $rm "$nvim_dir/init.vim"
2018-06-25 07:11:16 -07:00
eval $rm "$HOME/.Xresources"
2018-11-21 17:51:14 -07:00
eval $rm "$HOME/.ssh-sentinel"
2018-06-23 10:10:33 -07:00
}
function install {
create_directories
eval $link "$PWD/.emacs.d/init.el" "$emacs_dir/init.el"
eval $link "$PWD/.emacs.d/themes/" "$emacs_dir/themes"
2018-06-23 19:45:51 -07:00
eval $link "$PWD/.zshrc" "$HOME/.zshrc"
eval $link "$PWD/.tmux.conf" "$HOME/.tmux.conf"
2018-11-21 17:51:14 -07:00
eval $link "$PWD/.ssh-sentinel" "$HOME/.ssh-sentinel"
eval $link "$PWD/.config/nvim/autoload" "$nvim_dir/autoload"
eval $link "$PWD/.config/nvim/init.vim" "$nvim_dir/init.vim"
2018-06-25 07:11:16 -07:00
which xrdb &> /dev/null
xrdb_exists=$?
if (( !xrdb_exists )); then
eval $link "$PWD/.Xresources" "$HOME/.Xresources"
xrdb "$PWD/.Xresources"
fi
2018-06-23 10:10:33 -07:00
}
if [[ "$1" == "uninstall" ]]; then
echo -n "Uninstalling..."
uninstall
echo "Done"
elif [[ "$1" == "install" || "$1" == "" ]]; then
echo -n "Installing..."
uninstall
install
echo "Done"
else
echo "Unknown command \`$1\`"
fi