sh 这个文件有助于在基于ubuntu的系统上安装git,curl,tmux,zsh和zprezto,
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 这个文件有助于在基于ubuntu的系统上安装git,curl,tmux,zsh和zprezto,相关的知识,希望对你有一定的参考价值。
#!/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
echo "please don't forget to install:"
echo -e "1. fzf\n2. fasd"
以上是关于sh 这个文件有助于在基于ubuntu的系统上安装git,curl,tmux,zsh和zprezto,的主要内容,如果未能解决你的问题,请参考以下文章
ubuntu14.10上安装coreseek不成功,运行buildconf.sh不能生成configure