commit 37934c5872782bc7e9ba1cfd5abd6abda26cbdfd
parent dd6822300855bcdde3cd9b2980ab5d79ae496879
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Tue, 23 Oct 2018 12:43:35 +0200
Made install script back up
Diffstat:
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/install.sh b/install.sh
@@ -1,9 +1,12 @@
#!/bin/bash
+
+# Check if this directory was cloned properly
if [ $(pwd) != "$HOME/.dotfiles" ]; then
echo "Please clone this directory as $HOME/.dotfiles."
exit 1
fi
+# Check if the OS is supported
if [[ $(uname -s) == "Darwin" ]]; then
echo "Setting up your Mac..."
if ! command -v brew &> /dev/null; then
@@ -15,13 +18,23 @@ if [[ $(uname -s) == "Darwin" ]]; then
elif [[ $(uname -s) == "Linux" ]]; then
echo "Setting up your Linux environment..."
else
- echo "Does not work on this OS, sorry."
+ echo "This OS isn't supported yet."
exit 1
fi
lncommand() { ln -snfv $(pwd)/"$1" "$2"; }
+# Back up previous files
+if [ -d "$HOME/.vim" ]; then
+ mv "$HOME/.vim" "$HOME/.vim.orig"
+fi
+if [ -f "$HOME/.vimrc" ]; then
+ mv "$HOME/.vimrc" "$HOME/.vimrc.orig"
+fi
+
+
+# Link stuff conditionally in case of a sparse checkout
if [ -d ".bin" ]; then
lncommand "bin" "$HOME/.bin"
fi
@@ -30,9 +43,6 @@ if [ -d "oh-my-zsh" ]; then
lncommand "oh-my-zsh" "$HOME/.oh-my-zsh"
fi
-if [ -f "other-scripts/gdbinit" ]; then
- lncommand "other-scripts/gdbinit" "$HOME/.gdbinit"
-fi
if [ -d "shell" ]; then
for i in $(ls shell); do
@@ -46,14 +56,20 @@ if [ -d "git" ]; then
done
fi
+if [ -f "other-scripts/gdbinit" ]; then
+ lncommand "other-scripts/gdbinit" "$HOME/.gdbinit"
+fi
+
if [ -f "other-scripts/radio-config" ]; then
lncommand "other-scripts/radio-config" "$HOME/.radio-config"
fi
if [ -d "vim" ]; then
+ # Link vimrc (which points directly to other vim configs)
lncommand vim/init.vimrc $HOME/.vimrc
+
+ # Link ideavimrc, has to be separate
lncommand vim/idea.vimrc $HOME/.ideavimrc
fi
-unset -f lncommand
export CONFDIR="$HOME/.dotfiles"