137 lines
4.1 KiB
Bash
Executable File
137 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
ABSPATH="$(\pushd >/dev/null "$(\dirname "$0")/..";\pwd;\popd >/dev/null)"
|
|
SYNC_CONFIG=0
|
|
SHOW_HELP=0
|
|
SYNC_CUSTOM=0
|
|
SYNC_VIM=0
|
|
VALID_CMD=0
|
|
RECLONE=0
|
|
YCM=0
|
|
TMP_PATH="/tmp/$(uuidgen)"
|
|
mkdir -p "$TMP_PATH"
|
|
sync_config() {
|
|
# Remove old config files
|
|
remove ~/.gitconfig ~/.bashrc ~/.pylintrc ~/.zsh ~/.zshrc ~/.tmux.conf ~/.config/liquidpromptrc ~/.config/dunstrc
|
|
# Silently remove vimperator files since we are not reinstalling
|
|
remove -s ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp
|
|
if [[ $RECLONE = 1 ]]; then
|
|
remove ~/.fzf ~/.zsh-git
|
|
fi
|
|
# Install on all systems
|
|
# Vimperator has perished. Don't install vimperator files anymore
|
|
#ln -s "$ABSPATH/vimperator/vimperatorrc" ~/.vimperatorrc
|
|
#mkdir -p ~/.vimperator/colors
|
|
#ln -s "$ABSPATH/vimperator/vimPgray.vimp" ~/.vimperator/colors/vimPgray.vimp
|
|
if command -v git 2>&1 >/dev/null; then
|
|
if command -v zsh 2>&1 >/dev/null; then
|
|
for i in lpr oh-my-git-themes omg zsh-syntax-highlighting; do
|
|
if [ ! -d ~/.zsh-git/"$i" ]; then
|
|
git clone "https://gitea.austenwares.com/stonewareslord/$i.git" ~/.zsh-git/"$i"
|
|
fi
|
|
done
|
|
fi
|
|
if [ ! -d ~/.fzf ] ; then
|
|
git clone "https://gitea.austenwares.com/stonewareslord/fzf.git" ~/.fzf
|
|
~/.fzf/install --bin
|
|
fi
|
|
else
|
|
echo "No git! Not installing fzf or zsh packages"
|
|
fi
|
|
mkdir -p ~/.config
|
|
ln -s "$ABSPATH/dunst/dunstrc" ~/.config/dunstrc
|
|
ln -s "$ABSPATH/tmux/tmux.conf" ~/.tmux.conf
|
|
ln -s "$ABSPATH/python/pylintrc" ~/.pylintrc
|
|
ln -s "$ABSPATH/git/gitconfig" ~/.gitconfig
|
|
ln -s "$ABSPATH/shells/bashrc" ~/.bashrc
|
|
ln -s "$ABSPATH/shells/zshrc" ~/.zshrc
|
|
ln -s "$ABSPATH/zsh" ~/.zsh
|
|
ln -s "$ABSPATH/shells/liquidpromptrc" ~/.config/liquidpromptrc
|
|
if [ "$(uname)" != "Darwin" ]; then
|
|
# Don't install these on Mac
|
|
remove ~/.i3/{config,i3status.conf,run.sh} ~/.Xmodmap ~/.xsession ~/.config/synapse/gtkrc ~/.Xresources
|
|
mkdir -p ~/.i3 ~/.config/synapse
|
|
ln -s "$ABSPATH/i3/config" ~/.i3/config
|
|
ln -s "$ABSPATH/i3/$(hostname)-status.conf" ~/.i3/i3status.conf 2>/dev/null
|
|
ln -s "$ABSPATH/i3/run.sh" ~/.i3/run.sh
|
|
ln -s "$ABSPATH/i3/Xmodmap" ~/.Xmodmap
|
|
ln -s "$ABSPATH/i3/xsession" ~/.xsession
|
|
ln -s "$ABSPATH/i3/gtkrc" ~/.config/synapse/gtkrc
|
|
ln -s "$ABSPATH/shells/Xresources" ~/.Xresources
|
|
if command -v xrdb 2>&1 >/dev/null; then
|
|
xrdb ~/.Xresources
|
|
fi
|
|
fi
|
|
}
|
|
sync_custom() {
|
|
if ! command -v git 2>&1 >/dev/null; then
|
|
echo "Error! No git -- can't sync custom files"
|
|
exit
|
|
fi
|
|
if [[ ! -d ~/.zsh-git/custom-config ]]; then
|
|
#TODO: Figure out if I should use ssh or https cloning
|
|
#git clone https://gitea.austenwares.com/stonewareslord/custom-config
|
|
git clone git@austenwares.com:stonewareslord/custom-config ~/.zsh-git/custom-config
|
|
fi
|
|
remove ~/.gitconfig
|
|
ln -s ~/.zsh-git/custom-config/gitconfig ~/.gitconfig
|
|
# Custom zsh is sourced from zshrc
|
|
}
|
|
sync_vim() {
|
|
remove ~/.vimrc
|
|
ln -s "$ABSPATH/vim/vimrc" ~/.vimrc
|
|
vim +"silent! call Initialize()" +q
|
|
}
|
|
show_help() {
|
|
echo "sync.sh syncs configuration files and Vim plugins on computers"
|
|
echo " -h Shows this help"
|
|
echo " -b Syncs Vim bundles"
|
|
echo " -s Use this if you want custom stonewareslord settings"
|
|
echo " -c Sync configuration files"
|
|
echo " -r Reclone all git repositories"
|
|
echo " -y Run youcompleteme.sh"
|
|
exit
|
|
}
|
|
run_ycm() {
|
|
"$ABSPATH/applications/youcompleteme.sh"
|
|
}
|
|
remove() {
|
|
local SILENT=0
|
|
if [[ "$1" = "-s" ]]; then
|
|
# Be quiet!
|
|
SILENT=1
|
|
shift
|
|
fi
|
|
if [[ $SILENT = 1 ]]; then
|
|
\mv -t "$TMP_PATH" $* 2>/dev/null
|
|
else
|
|
\mv -t "$TMP_PATH" $*
|
|
fi
|
|
}
|
|
while getopts ":shbcyr" OPT "$@"; do
|
|
case $OPT in
|
|
b) SYNC_VIM=1;VALID_CMD=1;;
|
|
s) SYNC_CUSTOM=1;;
|
|
c) SYNC_CONFIG=1;VALID_CMD=1;;
|
|
r) RECLONE=1;;
|
|
y) YCM=1;VALID_CMD=1;;
|
|
*) echo "Invalid option: $OPT";SHOW_HELP=1;;
|
|
esac
|
|
done
|
|
if [[ $SHOW_HELP = 1 ]] || [[ ! $VALID_CMD = 1 ]]; then
|
|
show_help
|
|
fi
|
|
echo "Syncing config files. Placing old files in $TMP_PATH"
|
|
if [[ $SYNC_CONFIG = 1 ]]; then
|
|
sync_config
|
|
if [[ $SYNC_CUSTOM = 1 ]]; then
|
|
sync_custom
|
|
fi
|
|
fi
|
|
if [[ $SYNC_VIM = 1 ]]; then
|
|
sync_vim
|
|
fi
|
|
if [[ $YCM = 1 ]]; then
|
|
run_ycm
|
|
fi
|
|
echo "Done syncing"
|