Set symlink creation into separate function

This commit is contained in:
flyingscorpio@pinebook-pro 2020-04-14 10:03:41 +02:00
parent 5ebc4fd6c4
commit 2bbc21ba38

View file

@ -71,6 +71,8 @@ esac
export OS
separator
# }}}
# 3. Handle args {{{
@ -117,11 +119,14 @@ fi
export OVERWRITE
export UPDATE
separator
# }}}
# FUNCTIONS:
clone_projects() { # {{{
# Clone projects
echo "Cloning projects..."
@ -131,6 +136,7 @@ clone_projects() { # {{{
} # }}}
configure_git() { # {{{
# Configure Git
echo "Configuring Git..."
@ -145,6 +151,7 @@ configure_git() { # {{{
} # }}}
configure_protonvpn() { # {{{
# Configure ProtonVPN
echo "Configuring ProtonVPN..."
@ -154,6 +161,7 @@ configure_protonvpn() { # {{{
} # }}}
install_rust() { # {{{
# Install Rust
echo "Installing Rust..."
@ -191,7 +199,27 @@ install_scripts() { # {{{
} # }}}
make_symlink() { # {{{
link=$1
target=$2
if [ "$link" -ef "$target" ]; then
echo "${GREEN}$link points to the right location."
echo "Nothing changed.${NC}"
else
if [ "$OVERWRITE" = 'true' ]; then
rm "$link" 2> /dev/null
fi
if ln -rs "$target" "$link"; then
echo "${ORANGE}$link symlink created${NC}"
fi
fi
} # }}}
markdown_mimetype() { # {{{
# Add MIME type for reading .md files in Firefox (need to add extension too)
echo "Adding MIME type for .md files in Firefox..."
@ -211,41 +239,25 @@ markdown_mimetype() { # {{{
} # }}}
setup_bash_files() { # {{{
# Set up .bashrc
echo "Updating .bashrc..."
if [ ~/.bashrc -ef "$BASE_DIR"/dotfiles/bash/bashrc ]; then
echo "${GREEN}.bashrc points to the right location."
echo "Nothing changed.${NC}"
else
if [ "$OVERWRITE" = 'true' ]; then
rm ~/.bashrc 2> /dev/null
fi
if ln -rs "$BASE_DIR"/dotfiles/bash/bashrc ~/.bashrc; then
echo "${ORANGE}.bashrc symlink created${NC}"
fi
fi
make_symlink ~/.bashrc "$BASE_DIR"/dotfiles/bash/bashrc
separator
# Set up .bash_aliases
echo "Updating .bash_aliases..."
if [ ~/.bash_aliases -ef "$BASE_DIR"/dotfiles/bash/bash_aliases ]; then
echo "${GREEN}.bash_aliases points to the right location."
echo "Nothing changed.${NC}"
else
if [ "$OVERWRITE" = 'true' ]; then
rm ~/.bash_aliases 2> /dev/null
fi
if ln -rs "$BASE_DIR"/dotfiles/bash/bash_aliases ~/.bash_aliases; then
echo "${ORANGE}.bash_aliases symlink created${NC}"
fi
fi
make_symlink ~/.bash_aliases "$BASE_DIR"/dotfiles/bash/bash_aliases
separator
} # }}}
setup_bash_git_prompt() { # {{{
# Clone bash-git-prompt
if [ -e ~/.bash-git-prompt ]; then
@ -263,6 +275,7 @@ setup_bash_git_prompt() { # {{{
} # }}}
setup_i3() { # {{{
j
# Update i3 configuration
echo "Setting up i3..."
@ -272,6 +285,7 @@ setup_i3() { # {{{
} # }}}
setup_sddm() { # {{{
# Update sddm
echo "Setting up SDDM..."
@ -281,6 +295,7 @@ setup_sddm() { # {{{
} # }}}
setup_vim() { # {{{
# Update vim configuration
echo "Setting up configuration for Vim..."