sync/scripts/sync.sh

112 lines
4.9 KiB
Bash
Executable File

ABSPATH=$(cd "$(dirname "$0")/.."; pwd)
while getopts ":hbsdclw" VALUE "$@"; do
if [ "$VALUE" = "h" ] ; then
echo "sync.sh syncs configuration files, applications, and Vim bundles between computers"
echo " -h Shows this help"
echo " -b Syncs Vim bundles"
echo " -s Syncs computer with server applications in server.txt"
echo " -d Syncs computer with desktop applications in desktop.txt"
echo " -c Syncs other configuration files"
echo " -l Links standard ~ directories to lowercase"
echo " -w Installs wemux [requires vim]"
fi
if [ "$VALUE" = "b" ] ; then
mkdir -p ~/.vim/plugin/
mkdir -p ~/.vim/backup/
mkdir -p ~/.vim/undo/
mkdir -p ~/.vim/tmp/
mkdir -p ~/.vim/bundle/
mkdir -p ~/.vim/bundle/
echo "Installing vim bundles"
if [ ! -d ~/.vim/bundle/vundle/ ] ; then
echo "Installing vundle"
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
fi
vim +BundleClean +BundleInstall +qa
fi
if [ "$VALUE" = "s" ] ; then
if [ "$(uname)" != "Darwin" ]; then
echo "Installing server applications:"
echo $(grep -vE "^\s*#" $ABSPATH/scripts/server.txt | tr "\n" " ")
sudo apt-get install $(grep -vE "^\s*#" $ABSPATH/scripts/server.txt | tr "\n" " ")
else
if [ -d "/usr/local/Library/Taps/phinze/homebrew-cask" ] ; then
brew tap phinze/cask
brew install brew-cask
brew cask
fi
brew cask install gimp inkscape adium vlc iterm2 steam adobe-reader
fi
fi
if [ "$VALUE" = "d" ] ; then
echo "Installing desktop applications"
if [ "$(uname)" != "Darwin" ]; then
echo $(grep -vE "^\s*#" $ABSPATH/scripts/server.txt | tr "\n" " ") $(grep -vE "^\s*#" $ABSPATH/scripts/desktop.txt | tr "\n" " ")
sudo apt-get install $(grep -vE "^\s*#" $ABSPATH/scripts/server.txt | tr "\n" " ") $(grep -vE "^\s*#" $ABSPATH/scripts/desktop.txt | tr "\n" " ")
else
brew install autojump ncdu htop vim youtube-dl tree sshfs ircii imagemagick node ffmpeg wget lua libconfig readline meld
fi
fi
if [ "$VALUE" = "c" ] ; then
echo "Syncing config files"
if which trash >/dev/null; then
trash ~/.gitconfig ~/.vimrc ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp ~/.vimperator/info/sync/quickmarks ~/.bashrc ~/.pylintrc ~/.zshrc ~/.i3/config ~/.i3/sleep.sh ~/.i3/wall.sh ~/.Xmodmap ~/.xsession ~/.oh-my-zsh/themes/af-magic.zsh-theme ~/.screenrc ~/.Xresources ~/.tmux.conf
else
rm ~/.gitconfig ~/.vimrc ~/.vimperatorrc ~/.vimperator/colors/vimPgray.vimp ~/.vimperator/info/sync/quickmarks ~/.bashrc ~/.pylintrc ~/.zshrc ~/.i3/config ~/.i3/sleep.sh ~/.i3/wall.sh ~/.Xmodmap ~/.xsession ~/.oh-my-zsh/themes/af-magic.zsh-theme ~/.screenrc ~/.Xresources ~/.tmux.conf
fi
ln -s $ABSPATH/tmux/tmux.conf ~/.tmux.conf
ln -s $ABSPATH/python/pylintrc ~/.pylintrc
ln -s $ABSPATH/vim/vimrc ~/.vimrc
ln -s $ABSPATH/vimperator/vimperatorrc ~/.vimperatorrc
mkdir -p ~/.vimperator/colors
ln -s $ABSPATH/vimperator/vimPgray.vimp ~/.vimperator/colors/vimPgray.vimp
mkdir -p ~/.vimperator/info/sync/quickmarks
ln -s $ABSPATH/vimperator/quickmarks ~/.vimperator/info/sync/quickmarks
ln -s $ABSPATH/git/gitconfig ~/.gitconfig
ln -s $ABSPATH/shells/bashrc ~/.bashrc
if [ ! -f ~/.oh-my-zsh/oh-my-zsh.sh ] ; then
curl -L http://install.ohmyz.sh | sh
fi
if [ ! -d ~/.fzf ] ; then
git clone https://github.com/junegunn/fzf.git ~/.fzf
fi
if [ ! -d ~/.antigen ] ; then
git clone https://github.com/zsh-users/antigen ~/.antigen
fi
ln -s $ABSPATH/shells/zshrc ~/.zshrc
ln -s $ABSPATH/shells/screenrc ~/.screenrc
ln -s $ABSPATH/shells/Xresources ~/.Xresources
xrdb -merge ~/.Xresources
ln -s $ABSPATH/shells/af-magic.zsh-theme ~/.oh-my-zsh/themes/af-magic.zsh-theme
mkdir -p ~/.i3
ln -s $ABSPATH/i3/config ~/.i3/config
ln -s $ABSPATH/i3/wall.sh ~/.i3/wall.sh
ln -s $ABSPATH/i3/sleep.sh ~/.i3/sleep.sh
ln -s $ABSPATH/i3/Xmodmap ~/.Xmodmap
ln -s $ABSPATH/i3/xsession ~/.xsession
fi
if [ "$VALUE" = "l" ] ; then
echo "Linking standard directories..."
mkdir -p ~/Applications
ln -s ~/Applications ~/applications
ln -s ~/Desktop ~/desktop
ln -s ~/Documents ~/documents
ln -s ~/Downloads ~/downloads
ln -s ~/Music ~/music
ln -s ~/Pictures ~/pictures
ln -s ~/Videos ~/videos
echo "Done"
fi
if [ "$VALUE" = "w" ] ; then
echo "Installing wemux..."
sudo git clone git://github.com/zolrath/wemux.git /usr/local/share/wemux
sudo rm -r /usr/local/bin/wemux
sudo rm -r /usr/local/etc/wemux.conf
sudo ln -s /usr/local/share/wemux/wemux /usr/local/bin/wemux
sudo cp /usr/local/share/wemux/wemux.conf.example /usr/local/etc/wemux.conf
sudo vim `which wemux` +"execute \"normal gg/tmux\<CR>nnnea -2\<Esc>nea -2\<Esc>ggZZ\""
sudo vim /usr/local/etc/wemux.conf +":execute \"normal gg/host_list\<CR>nnww\""
fi
done
echo "Done syncing"