dotfiles/install.sh

133 lines
4.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# This ensures that the entire script is downloaded before execution
{
# Change this url to point to your repo if you made customizations
repourl="git://github.com/alopexc0de/dotfiles.git"
# Exit the script if any errors are encountered
2018-05-17 03:46:31 +00:00
#set -e
basedir=$HOME/dotfiles
bindir=$HOME/bin
postinst=$HOME/.dotfiles.postinst
# Attempts to safely install the configs as symlinks (backing up existing ones)
function symlink() {
src=$1
dest=$2
if [ -e $dest ]; then
if [ -L $dest ]; then
# Already symlinked -- I'll assume correctly.
return
else
# Rename files with a ".old" extension.
echo "$dest already exists, renaming to $dest.old"
backup=$dest.old
if [ -e $backup ]; then
echo "Error: $backup already exists. Please delete or rename it."
exit 1
fi
mv -v $dest $backup
fi
fi
echo "Linking $(basename $src)..."
ln -sf $src $dest
}
2017-06-22 17:21:58 +00:00
2018-10-18 18:12:15 +00:00
read -p "Press enter to install my dotfiles " WAIT_FOR_INPUT
2018-05-16 22:37:00 +00:00
2018-10-23 05:26:46 +00:00
read -p "[Dotfiles] Would you like to detect distro and auto-install dependencies? [Y/n]: " line
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
2020-03-25 19:26:51 +00:00
distrourl="https://raw.githubusercontent.com/alopexc0de/dotfiles/master/internal_bin"
if [ -f /etc/arch-release ]; then
bash <(curl -sL $distrourl/install.arch)
2018-10-23 05:26:46 +00:00
elif [ -f /etc/debian_version ]; then
bash <(curl -sL $distrourl/install.deb)
else
2019-03-14 03:20:39 +00:00
echo "This system does not have an auto-install file. Please install the dependencies manually"
fi
fi
if ! which git >>/dev/null ; then
echo "Error: git is not installed"
exit 1
fi
# If the update script exists, try to do a normal update
2020-03-25 19:26:51 +00:00
if [ -x "$basedir/internal_bin/check_for_upgrade.sh" ]; then
source "$basedir/shell/env"
2020-03-25 19:26:51 +00:00
env _DOTFILES=$basedir DISABLE_UPDATE_PROMPT='FALSE' zsh -f $basedir/internal_bin/check_for_upgrade.sh
else
echo "Cloning dotfiles to $basedir"
rm -rf $basedir
2018-05-17 03:59:56 +00:00
git clone --depth=1 $repourl $basedir
fi
# Start installing config
echo "Creating Symlinks..."
2020-03-25 19:26:51 +00:00
# Environment
2019-12-13 20:28:24 +00:00
symlink $basedir/home/.local $HOME/.local
2020-03-25 19:26:51 +00:00
symlink $basedir/home/.config $HOME/.config
symlink $basedir/home/Xresources $HOME/.Xresources
symlink $basedir/home/gitconfig $HOME/.gitconfig
symlink $basedir/home/shell/tmux.conf $HOME/.tmux.conf
symlink $basedir/home/shell/bashrc $HOME/.bashrc
symlink $basedir/home/shell/zshrc $HOME/.zshrc
symlink $basedir/home/shell/vimrc $HOME/.vimrc
2017-06-22 17:21:58 +00:00
echo "Installing VIM Pathogen..."
mkdir -p $HOME/.vim/autoload $HOME/.vim/bundle
curl -LSso $HOME/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
2017-06-22 17:21:58 +00:00
echo "Installing VIM Sensible..."
cd $HOME/.vim/bundle
2017-06-22 17:21:58 +00:00
git clone git://github.com/tpope/vim-sensible.git
echo "Adding user bin..."
2020-03-25 18:54:55 +00:00
mkdir -p $bindir
for file_path in $basedir/bin/*; do
symlink $file_path $bindir/$(basename $file_path)
done
echo "Changing default shell to ZSH..."
2017-06-22 17:21:58 +00:00
chsh -s /usr/bin/zsh
# Install i3 config
echo "Installing i3 configuration"
mkdir -p $HOME/.config/i3
mkdir -p $HOME/.i3
symlink $basedir/i3/config $HOME/.config/i3/config
symlink $basedir/i3/i3blocks.conf $HOME/.i3/i3blocks.conf
symlink $basedir/i3/wallpaper.sh $HOME/.i3/wallpaper.sh
symlink $basedir/i3/screenshotter.sh $HOME/.i3/screenshotter.sh
2018-10-18 18:12:15 +00:00
symlink $basedir/i3/compton.conf $HOME/.compton.conf
2019-03-14 03:20:39 +00:00
symlink $basedir/i3/i3blocks $bindir/i3blocks
2020-03-25 19:26:51 +00:00
symlink $basedir/i3/stalonetrayrc $HOME/.stalonetrayrc
2019-12-13 15:33:00 +00:00
echo "Installing shell-history"
2020-03-25 18:54:55 +00:00
python3 -m pip install shellhistory
echo "Installing Oh-My-ZSH"
echo "When the install is done, type `exit` to continue installing dotfiles"
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
2019-12-13 15:33:00 +00:00
if [ -e "$postinst" ]; then
echo "Running post install..."
source "$postinst"
else
echo "No post install script found. Optionally create one at $postinst and reinstall your dotfies"
fi
2017-06-22 17:21:58 +00:00
echo "Install done."
echo "Check tmux, vim, and your shell to verify everything is correct"
2017-06-22 17:22:53 +00:00
echo "you may need to launch a new instance of your shell"
} # Ensures that the whole script is downloaded before execution