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 export OS
separator
# }}} # }}}
# 3. Handle args {{{ # 3. Handle args {{{
@ -117,11 +119,14 @@ fi
export OVERWRITE export OVERWRITE
export UPDATE export UPDATE
separator
# }}} # }}}
# FUNCTIONS: # FUNCTIONS:
clone_projects() { # {{{ clone_projects() { # {{{
# Clone projects # Clone projects
echo "Cloning projects..." echo "Cloning projects..."
@ -131,6 +136,7 @@ clone_projects() { # {{{
} # }}} } # }}}
configure_git() { # {{{ configure_git() { # {{{
# Configure Git # Configure Git
echo "Configuring Git..." echo "Configuring Git..."
@ -145,6 +151,7 @@ configure_git() { # {{{
} # }}} } # }}}
configure_protonvpn() { # {{{ configure_protonvpn() { # {{{
# Configure ProtonVPN # Configure ProtonVPN
echo "Configuring ProtonVPN..." echo "Configuring ProtonVPN..."
@ -154,6 +161,7 @@ configure_protonvpn() { # {{{
} # }}} } # }}}
install_rust() { # {{{ install_rust() { # {{{
# Install Rust # Install Rust
echo "Installing 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() { # {{{ markdown_mimetype() { # {{{
# Add MIME type for reading .md files in Firefox (need to add extension too) # Add MIME type for reading .md files in Firefox (need to add extension too)
echo "Adding MIME type for .md files in Firefox..." echo "Adding MIME type for .md files in Firefox..."
@ -211,41 +239,25 @@ markdown_mimetype() { # {{{
} # }}} } # }}}
setup_bash_files() { # {{{ setup_bash_files() { # {{{
# Set up .bashrc # Set up .bashrc
echo "Updating .bashrc..." echo "Updating .bashrc..."
if [ ~/.bashrc -ef "$BASE_DIR"/dotfiles/bash/bashrc ]; then make_symlink ~/.bashrc "$BASE_DIR"/dotfiles/bash/bashrc
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
separator separator
# Set up .bash_aliases # Set up .bash_aliases
echo "Updating .bash_aliases..." echo "Updating .bash_aliases..."
if [ ~/.bash_aliases -ef "$BASE_DIR"/dotfiles/bash/bash_aliases ]; then make_symlink ~/.bash_aliases "$BASE_DIR"/dotfiles/bash/bash_aliases
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
separator separator
} # }}} } # }}}
setup_bash_git_prompt() { # {{{ setup_bash_git_prompt() { # {{{
# Clone bash-git-prompt # Clone bash-git-prompt
if [ -e ~/.bash-git-prompt ]; then if [ -e ~/.bash-git-prompt ]; then
@ -263,6 +275,7 @@ setup_bash_git_prompt() { # {{{
} # }}} } # }}}
setup_i3() { # {{{ setup_i3() { # {{{
j
# Update i3 configuration # Update i3 configuration
echo "Setting up i3..." echo "Setting up i3..."
@ -272,6 +285,7 @@ setup_i3() { # {{{
} # }}} } # }}}
setup_sddm() { # {{{ setup_sddm() { # {{{
# Update sddm # Update sddm
echo "Setting up SDDM..." echo "Setting up SDDM..."
@ -281,6 +295,7 @@ setup_sddm() { # {{{
} # }}} } # }}}
setup_vim() { # {{{ setup_vim() { # {{{
# Update vim configuration # Update vim configuration
echo "Setting up configuration for Vim..." echo "Setting up configuration for Vim..."