Set function for easy select

This commit is contained in:
flyingscorpio@arch-desktop 2020-04-09 17:25:39 +02:00
parent 370b2d4a49
commit 55c441ba0c

View file

@ -1,7 +1,11 @@
#!/bin/bash
## Script to automate the setting up of my working environment.
## flyingscorpio
## Script to automate the setting up of my working environment.
## Uncomment the function calls you wish to run.
# Set up {{{
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
@ -13,6 +17,9 @@ export GREEN
export ORANGE
export NC
BASE_DIR="$PWD"
export BASE_DIR
separator() {
exit_status=$?
if [ $exit_status -eq 0 ]; then
@ -24,8 +31,7 @@ separator() {
echo "${NC}"
}
BASE_DIR="$PWD"
export BASE_DIR
# }}}
# Define OS {{{
@ -89,158 +95,155 @@ export UPDATE
# }}}
# Install scripts {{{
install_scripts() { # {{{
echo "Installing scripts..."
echo "Installing scripts..."
if [ "$OS" = 'debian' ]; then
/bin/bash "$BASE_DIR"/installation_scripts/debian_based_installs.sh
elif [ "$OS" = 'arch' ]; then
/bin/bash "$BASE_DIR"/installation_scripts/arch_based_installs.sh
else
echo "${RED} Didn't receive correct OS information, quitting...${NC}"
exit 1
fi
separator
# }}}
# Update vim configuration {{{
echo "Setting up configuration for Vim..."
/bin/bash "$BASE_DIR"/installation_scripts/vim_update.sh
separator
# }}}
# Update i3 configuration {{{
echo "Setting up i3..."
/bin/bash "$BASE_DIR"/installation_scripts/i3_update.sh
separator
# }}}
# Configure ProtonVPN {{{
echo "Configuring ProtonVPN..."
if [ ! -e ~/.pvpn-cli/pvpn-cli.cfg ]; then
sudo protonvpn init && sudo protonvpn c --cc CH
fi
separator
# }}}
# Update .bashrc {{{
echo "Updating .bashrc..."
if [ ! -L ~/.bashrc ]; then
ln -rs "$BASE_DIR"/dotfiles/bash/bashrc ~/.bashrc 2> /dev/null
fi
separator
# }}}
# Update .bash_aliases {{{
echo "Updating .bash_aliases..."
if [ ! -L ~/.bash_aliases ]; then
ln -rs "$BASE_DIR"/dotfiles/bash/bash_aliases ~/.bash_aliases 2> /dev/null
fi
separator
# }}}
# Configure Git {{{
echo "Configuring Git..."
git config --global user.name "$USER@$(uname -n)"
git config --global user.email "tfranken@protonmail.com"
git config --global alias.ci "commit"
git config --global alias.co "checkout"
git config --global alias.st "status"
git config --global alias.br "branch"
separator
# }}}
# Install Rust {{{
echo "Installing Rust..."
if rustc --version; then
echo "${GREEN}Rust is already intalled${NC}"
if [ "$UPDATE" = 'true' ]; then
echo "Updading..."
rustup update
fi
else
if curl https://sh.rustup.rs -sSf | sh; then
echo "${GREEN}Successfully installed Rust${NC}"
if [ "$OS" = 'debian' ]; then
/bin/bash "$BASE_DIR"/installation_scripts/debian_based_installs.sh
elif [ "$OS" = 'arch' ]; then
/bin/bash "$BASE_DIR"/installation_scripts/arch_based_installs.sh
else
echo "${ORANGE}There was a problem while installing Rust${NC}"
echo "${RED} Didn't receive correct OS information, quitting...${NC}"
exit 1
fi
fi
separator
separator
# }}}
} # }}}
# install_scripts
# Clone bash-git-prompt {{{
update_vim() { # {{{
# Update vim configuration
if [ -e ~/.bash-git-prompt ]; then
echo "${GREEN}Found existing bash-git-prompt.${NC}"
if [ "$UPDATE" = 'true' ]; then
echo "Updating..."
cd ~/.bash-git-prompt && git pull
echo "Setting up configuration for Vim..."
/bin/bash "$BASE_DIR"/installation_scripts/vim_update.sh
separator
} # }}}
# update_vim
update_i3() { # {{{
# Update i3 configuration
echo "Setting up i3..."
/bin/bash "$BASE_DIR"/installation_scripts/i3_update.sh
separator
} # }}}
# update_i3
configure_protonvpn() { # {{{
# Configure ProtonVPN
echo "Configuring ProtonVPN..."
sudo protonvpn init && sudo protonvpn c --cc CH
separator
} # }}}
# configure_protonvpn
update_bash_files() { # {{{
# Update .bashrc
echo "Updating .bashrc..."
if [ ! -L ~/.bashrc ]; then
ln -rs "$BASE_DIR"/dotfiles/bash/bashrc ~/.bashrc 2> /dev/null
fi
else
echo "${ORANGE}Cloning bash-git-prompt...${NC}"
git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1
fi
separator
separator
# Update .bash_aliases
# }}}
echo "Updating .bash_aliases..."
if [ ! -L ~/.bash_aliases ]; then
ln -rs "$BASE_DIR"/dotfiles/bash/bash_aliases ~/.bash_aliases 2> /dev/null
fi
separator
# Add MIME type for reading .md files in Firefox (need to add extension too) {{{
} # }}}
# update_bash_files
echo "Adding MIME type for .md files in Firefox..."
echo "${ORANGE}Remember to install the Firefox extension for it to work${NC}"
configure_git() { # {{{
# Configure Git
mkdir -p ~/.local/share/mime/packages
echo "<?xml version=\"1.0\"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type=\"text/plain\">
<glob pattern=\"*.md\"/>
<glob pattern=\"*.mkd\"/>
<glob pattern=\"*.markdown\"/>
</mime-type>
</mime-info>" > ~/.local/share/mime/packages/text-markdown.xml
echo "Configuring Git..."
git config --global user.name "$USER@$(uname -n)"
git config --global user.email "tfranken@protonmail.com"
git config --global alias.ci "commit"
git config --global alias.co "checkout"
git config --global alias.st "status"
git config --global alias.br "branch"
separator
update-mime-database ~/.local/share/mime
} # }}}
# configure_git
separator
install_rust() { # {{{
# Install Rust
# }}}
echo "Installing Rust..."
if rustc --version; then
echo "${GREEN}Rust is already intalled${NC}"
if [ "$UPDATE" = 'true' ]; then
echo "Updading..."
rustup update
fi
else
if curl https://sh.rustup.rs -sSf | sh; then
echo "${GREEN}Successfully installed Rust${NC}"
else
echo "${ORANGE}There was a problem while installing Rust${NC}"
fi
fi
separator
# Clone projects {{{
} # }}}
# install_rust
echo "Cloning projects..."
bash_git_prompt() { # {{{
# Clone bash-git-prompt
/bin/bash "$BASE_DIR"/installation_scripts/clone_projects.sh
if [ -e ~/.bash-git-prompt ]; then
echo "${GREEN}Found existing bash-git-prompt.${NC}"
if [ "$UPDATE" = 'true' ]; then
echo "Updating..."
cd ~/.bash-git-prompt && git pull
fi
else
echo "${ORANGE}Cloning bash-git-prompt...${NC}"
git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1
fi
separator
separator
} # }}}
# bash_git_prompt
# }}}
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..."
echo "${ORANGE}Remember to install the Firefox extension for it to work${NC}"
mkdir -p ~/.local/share/mime/packages
echo "<?xml version=\"1.0\"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type=\"text/plain\">
<glob pattern=\"*.md\"/>
<glob pattern=\"*.mkd\"/>
<glob pattern=\"*.markdown\"/>
</mime-type>
</mime-info>" > ~/.local/share/mime/packages/text-markdown.xml
update-mime-database ~/.local/share/mime
separator
} # }}}
# markdown_mimetype
clone_projects() { # {{{
# Clone projects
echo "Cloning projects..."
/bin/bash "$BASE_DIR"/installation_scripts/clone_projects.sh
separator
} # }}}
# clone_projects