Skip to content

Instantly share code, notes, and snippets.

@souhaiebtar
Last active April 30, 2021 18:06
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 souhaiebtar/60f7200d2dbb95b5af931c4dd8d468e2 to your computer and use it in GitHub Desktop.
Save souhaiebtar/60f7200d2dbb95b5af931c4dd8d468e2 to your computer and use it in GitHub Desktop.
[install git, curl, tmux, zsh and zprezto]this file help to install git, curl, tmux, zsh and zprezto on a ubuntu based system #shell #zsh
#!/usr/bin/env bash
USER=$(whoami)
get_distribution() {
lsb_dist=""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ]; then
lsb_dist="$(. /etc/os-release && echo "$ID")"
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo "$lsb_dist"
}
distro=$( get_distribution )
distro="$(echo "$distro" | tr '[:upper:]' '[:lower:]')"
if [ "$distro" != "ubuntu" ] && [ "$distro" != "debian" ] && [ "$distro" != "arch" ]; then
echo 'Sorry, the distro you are using is not supported by this script'
exit 1;
else
case "$distro" in
ubuntu | debian)
sudo apt-get update
;;
arch)
sudo pacman -Syy
;;
esac
fi
install_git() {
case "$distro" in
ubuntu | debian)
sudo apt-get install -y git
;;
arch)
sudo pacman -S --noconfirm git
;;
esac
}
install_curl() {
case "$distro" in
ubuntu | debian)
sudo apt-get install -y curl
;;
arch)
sudo pacman -S --noconfirm curl
;;
esac
}
install_tmux() {
case "$distro" in
ubuntu | debian)
sudo apt-get install -y tmux
;;
arch)
sudo pacman -S --noconfirm tmux
;;
esac
}
install_zsh() {
case "$distro" in
ubuntu | debian)
sudo apt-get install -y zsh
;;
arch)
sudo pacman -S --noconfirm zsh
;;
esac
}
zsh_config() {
git clone --recursive https://github.com/sorin-ionescu/prezto.git ~/.zprezto
if [ -f ~/.zshrc ]; then
mv ~/.zshrc ~/.zshrc.backup
fi
# Create links to zsh config files
ln -s ~/.zprezto/runcoms/zlogin ~/.zlogin
ln -s ~/.zprezto/runcoms/zlogout ~/.zlogout
ln -s ~/.zprezto/runcoms/zpreztorc ~/.zpreztorc
ln -s ~/.zprezto/runcoms/zprofile ~/.zprofile
ln -s ~/.zprezto/runcoms/zshenv ~/.zshenv
ln -s ~/.zprezto/runcoms/zshrc ~/.zshrc
curl https://gist.githubusercontent.com/souhaiebtar/738c13454c547bc22629fcb80fed747f/raw/1664b93216f78fad2289aa75549ac8d16cde44cc/zpreztorc > ~/.zprezto/runcoms/zpreztorc
curl -fLo ~/.zprezto/modules/completion/external/src/_docker \
https://raw.github.com/felixr/docker-zsh-completion/master/_docker
sudo sed -i "/$USER/s/bash/zsh/g" /etc/passwd
rm -f ~/.zshrc
curl -L https://gist.githubusercontent.com/souhaiebtar/9ad3f5f9387b72ac1f005567bde6c91e/raw/ed53b1b742ed8235f2ac4524207809145d2fbcdf/.zshrc > ~/.zshrc
}
install_vim() {
case "$distro" in
ubuntu | debian)
sudo apt-get install -y vim
;;
arch)
sudo pacman -S --noconfirm vim
;;
esac
}
vim_config() {
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
curl -L https://gist.githubusercontent.com/souhaiebtar/d6d246b3e038abf26e72be5f113ace75/raw/d2c7868bdf73e71649710464af26c90eb5217acc/.vimrc > ~/.vimrc
yes | vim +PlugInstall +qall
}
if ! [ -x "$(command -v git)" ]; then
read -p "Do you want to install git? type Y(yes) or N(NO):" yn
case $yn in
[Yy]* ) install_git;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
else
echo "git is already installed"
fi
if ! [ -x "$(command -v curl)" ]; then
read -p "Do you want to install curl? type Y(yes) or N(NO):" yn
case $yn in
[Yy]* ) install_curl;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
else
echo "curl is already installed"
fi
if ! [ -x "$(command -v tmux)" ]; then
read -p "Do you want to install tmux? type Y(yes) or N(NO):" yn
case $yn in
[Yy]* ) install_tmux;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
else
echo "tmux is already installed"
fi
if ! [ -x "$(command -v zsh)" ]; then
read -p "Do you want to install zsh? type Y(yes) or N(NO):" yn
case $yn in
[Yy]* ) install_zsh;zsh_config;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
else
echo "zsh is already installed"
fi
if ! [ -x "$(command -v vim)" ]; then
read -p "Do you want to install vim? type Y(yes) or N(NO):" yn
case $yn in
[Yy]* ) install_vim;vim_config;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
else
echo "vim is already installed"
fi
# install fasd
sudo apt -get install -y fasd
echo 'eval "$(fasd --init auto)"' >> .zshrc
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
yes | ~/.fzf/install
sudo apt-get install -y xclip
git clone https://github.com/gpakosz/.tmux.git && ln -s -f .tmux/.tmux.conf && cp .tmux/.tmux.conf.local .
rm -rf temp && echo '[[ -z $(pgrep tmux) ]] && tmux' | cat - .zshrc > temp && mv -f temp .zshrc
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
sudo apt-get update; sudo apt-get install --no-install-recommends -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> .zshrc
echo 'eval "$(pyenv init -)"' >> .zshenv
exec zsh
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
echo 'eval "$(pyenv virtualenv-init -)"' >> .zshenv
# echo "please don't forget to install:"
# echo -e "1. fzf\n2. fasd"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment