Skip to content

Instantly share code, notes, and snippets.

@frizbee
Created July 21, 2020 12:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frizbee/9b536ccfaf1aa6ef23b11e7caff832ee to your computer and use it in GitHub Desktop.
Save frizbee/9b536ccfaf1aa6ef23b11e7caff832ee to your computer and use it in GitHub Desktop.
Ubuntu Desktop 20.04
#!/bin/bash
# This config file is for desktop version of Ubuntu
# Default settings
start=`date +%s`
bold=$(tput bold)
normal=$(tput sgr0)
red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
VIMREPO="https://gist.githubusercontent.com/frizbee/8174f50d6863666efb217615bc1ecfac/raw/42db6ec0527de01e1215ca29689ea7ef10b7d51d/vimrc"
GITNAME="Name"
GITEMAIL="email@email.com"
beginDeploy() {
echo
echo "${bold}$1${normal}"
}
sudo apt-get update
sudo apt-get -y install guake # setup Guake terminal, beter that builtin
beginDeploy "######### ZSH ##########"
# Setup ZSH
if [ ! -x "/usr/bin/zsh" ]; then
sudo apt-get update && sudo apt-get -y install zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
else
echo "${green}ZSH already installed!${reset}"
fi
# source ~/.zshrc
# Use this command if shell not changed: chsh -s /bin/zsh
beginDeploy "######### edit ZSH ##########"
zshrc="$HOME/.zshrc"
echo -n "Do you want to edit zshrc? [y/n] > "
editzshrc=
read editzshrc
if [ "$editzshrc" != "n" ]; then
if [ -f "$zshrc" ]; then
echo "$zshrc found"
sed -i -e 's/(git)/(git ruby git-flow bundler)/g' $zshrc
echo "alias update='sudo apt-get -y update'" >> $zshrc
echo "alias gsweep='git branch --merged master | command grep -vE \"^(\*|\s*staging\s*|\s*develop\s*|\s*master\s*$)\" | command xargs -n 1 git branch -d'" >> $zshrc
echo "alias gb=\"git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) | %(authorname) | (%(color:green)%(committerdate:relative)%(color:reset))| %(contents:subject) ' | column -t -s '|'"\" >> $zshrc
else
echo "$zshrc not found"
echo "${red}Exit program!${reset}"
exit 1
fi
else
echo "${green}Skipping edit ZSHRC...${reset}"
fi
beginDeploy "######### Python ##########"
if ! python3 -c 'import sys; print(sys.version_info[:])'; then
sudo apt-get install -y python3
python3 --version
else
echo "${green}Python already installed!${reset}"
fi
beginDeploy "######### Golang #########"
# https://github.com/golang/go/wiki/Ubuntu
if [ -f "/bin/go" ]; then
echo "${green}Go installed!${reset}"
else
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
# sudo apt install golang-go
# 20.04
sudo apt install golang-1.14-go
mkdir ~/go
which go
fi
beginDeploy "########## Intall RipGrep ############"
# https://snapcraft.io/install/ripgrep/ubuntu
if [ ! -x "/usr/bin/rg" ]; then
# sudo apt update sudo apt install snapd # if ubuntu > 19.04
sudo snap install ripgrep --classic
else
echo "${green}RipGrep already installed${reset}"
fi
beginDeploy "########### Install Plug and clone .vimrc ############"
if [ -f "$HOME/.vim/autoload/plug.vim" ]; then
echo "${green}Plug already installed${reset}"
else
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
if [ ! -d "$HOME/.vim" ]; then
echo "${red}Installing VIM${reset}"
sudo apt install vim
else
echo "${green}VIM already there${reset}"
fi
if [ -f ~/.vimrc ] || [ -h ~/.vimrc ]; then
echo "${green}.vimrc already exists${reset}"
echo -n "Do you want to rewreite it? [y/n] > "
vimrc=
read vimrc
if [ "$vimrc" != "n" ]; then
echo "${green}Removing old .vimrc${reset}"
rm -f "$HOME/.vimrc"
echo "${green}Cloning .vimrc${reset}"
sh -c "curl -s $VIMREPO >> ~/.vimrc"
else
echo "${green}Skipping cloning .vimrc${reset}"
fi
else
echo "${green}Cloning .vimrc${reset}"
if [ -d "$HOME/.vim" ]; then
sh -c "curl -s $VIMREPO >> ~/.vimrc"
else
echo "${red}Please install VIM first${reset}"
echo "${red}Exit program{$reset}"
exit 1
fi
fi
beginDeploy "############# Setup Ruby with libraries ##############"
sudo apt-get install -y git-core \
curl \
zlib1g-dev \
build-essential \
libssl-dev \
libreadline-dev \
libyaml-dev \
libsqlite3-dev \
sqlite3 \
libxml2-dev \
libxslt1-dev \
libcurl4-openssl-dev \
software-properties-common \
libffi-dev \
dirmngr \
gnupg \
apt-transport-https \
ca-certificates \
redis-server \
redis-tools \
nodejs \
yarn \
imagemagick
cd ~
if [ ! -d "$HOME/.rbenv" ]; then
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
else
echo "${green}Upgrading rbenv${reset}"
git -C "$(rbenv root)" pull
fi
#exec $SHELL
if [ ! -d "$HOME/.rbenv/plugins/ruby-build" ]; then
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.zshrc
#exec $SHELL
else
echo "${green}Upgrading ruby-build${reset}"
git -C "$(rbenv root)"/plugins/ruby-build pull
fi
if [ ! -d "$HOME/.rbenv/versions/2.7.1" ]; then
rbenv install 2.7.1
rbenv global 2.7.1
fi
echo -n "${green}Current ruby: ${reset}"
ruby -v
echo "gem: --no-document" > ~/.gemrc
gem install bundler
gem install rails
rbenv rehash
beginDeploy "############# Setup GIT ##############"
git config --global color.ui true
git config --global user.name "$GITNAME"
git config --global user.email "$GITEMAIL"
# ssh-keygen -t rsa -b 4096 -C "$GITEMAIL"
if [ ! -d "$HOME/tig" ]; then
echo "${green}Setup Tig${reset}"
git clone https://github.com/jonas/tig.git ~/tig
cd ~/tig
make
make install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment