-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·98 lines (88 loc) · 3.04 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
WHITE='\033[1;37m'
NC='\033[0m'
function bye {
h=`date +%H`
if [ $h -lt 12 ]; then
t='morning'
elif [ $h -lt 18 ]; then
t='afternoon'
else
t='evening'
fi
printf "\n${GREEN}You're all set. Have a nice ${t}!${NC}\n"
}
function yes_or_no {
while true; do
printf "${YELLOW}$* [y/n]${NC}"
read -p " " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
esac
done
}
function install {
if [ -n "$(uname -a | grep Darwin)" ]; then
brew install $1
elif [ -n "$(cat /etc/os-release 2> /dev/null | grep debian)" ]; then
if ! command -v sudo &> /dev/null; then
apt install $1
else
sudo apt install $1
fi
else
printf "${RED}This script only runs on Debian / macOS.${NC}\n\n"
exit
fi
}
function check_and_install {
if ! command -v $1 &> /dev/null; then
yes_or_no "Install $1 ($2)?" && install $1
fi
}
function setup_zsh {
check_and_install curl "https://curl.se/"
check_and_install git "https://git-scm.com/"
check_and_install zsh "Z shell"
yes_or_no "Install Oh My Zsh (https://ohmyz.sh/)? ${NC}${GREEN}Please type \"exit\" and press enter after installation${NC}${YELLOW}" && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
check_and_install autojump "https://github.com/wting/autojump"
yes_or_no "Install zsh-syntax-highlighting (https://github.com/zsh-users/zsh-syntax-highlighting)?" && /bin/zsh -c 'source ~/.zshrc && git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting'
yes_or_no "Install zsh-autosuggestions (https://github.com/zsh-users/zsh-autosuggestions)?" && /bin/zsh -c 'source ~/.zshrc && git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions'
yes_or_no "Replace .zshrc ?" && cp rc/zshrc ~/.zshrc
}
function setup_screen {
check_and_install screen "https://formulae.brew.sh/formula/screen"
yes_or_no "Replace .screenrc ?" && cp rc/screenrc ~/.screenrc
}
function setup_vim {
check_and_install vim "https://www.vim.org/"
yes_or_no "Setup vim folders?" && mkdir -p ~/.vim/colors && mkdir -p ~/.vim/undo
yes_or_no "Download vim color theme?" && curl -L "https://raw.github.com/altercation/vim-colors-solarized/master/colors/solarized.vim" -o ~/.vim/colors/solarized.vim
yes_or_no "Replace .vimrc ?" && cp rc/vimrc ~/.vimrc
}
if [ -n "$(uname -a | grep Darwin)" ]; then
printf "${GREEN}Hi! macOS user,${NC}\n\n"
# brew
if ! command -v brew &> /dev/null; then
yes_or_no "Install Homebrew (https://brew.sh)?" && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
elif [ -n "$(cat /etc/os-release 2> /dev/null | grep debian)" ]; then
printf "${GREEN}Hi! Debian user,${NC}\n\n"
# apt
if ! command -v sudo &> /dev/null; then
yes_or_no "Update package list?" && apt update
else
yes_or_no "Update package list?" && sudo apt update
fi
else
printf "${RED}This script only runs on Debian / macOS.${NC}\n\n"
exit
fi
setup_zsh
setup_screen
setup_vim
bye