-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallzsh.sh
executable file
·121 lines (98 loc) · 4.21 KB
/
installzsh.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
SUDO=""
if [[ $EUID -ne 0 ]]; then
SUDO='sudo'
fi
function update_packages() {
declare -A osInfo;
osInfo[/etc/debian_version]="apt-get update"
osInfo[/etc/alpine-release]="apk update"
osInfo[/etc/centos-release]="yum update"
osInfo[/etc/fedora-release]="dnf update"
for f in ${!osInfo[@]}
do
if [[ -f $f ]];then
package_manager=${osInfo[$f]}
fi
done
echo "${package_manager}"
}
function install_packages() {
declare -A osInfo;
osInfo[/etc/debian_version]="apt-get install -y"
osInfo[/etc/alpine-release]="apk add"
osInfo[/etc/centos-release]="yum install -y"
osInfo[/etc/fedora-release]="dnf install -y"
for f in ${!osInfo[@]}
do
if [[ -f $f ]];then
package_manager=${osInfo[$f]}
fi
done
echo "${package_manager}"
}
### Installs oh-my-zsh, powerlevel10k theme, and plugins
function install() {
#sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cd ~ && mkdir .zshinstall && cd .zshinstall
wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
sh install.sh --unattended
cd .. && rm -R .zshinstall
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
sed -i '' 's/ZSH_THEME="robbyrussell"/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc
echo 'alias ll="ls -hal"' >> ~/.zshrc
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
sed -i '' 's/plugins=(git)/plugins=( git zsh-syntax-highlighting zsh-autosuggestions )/' ~/.zshrc
chsh -s $(which zsh)
zsh
echo "typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=same-dir" >> ~/.p10k.zsh
}
function install_fonts() {
cd $1 && curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf && \
curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf &&\
curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf && \
curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
}
### Independent steps depending on platform
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
machine=Linux
echo "Installing on ${unameOut}"
${SUDO} $(update_packages)
${SUDO} $(install_packages) curl wget git zsh -y
FONT_DIR=~/.local/share/fonts
mkdir -p $FONT_DIR && cd $FONT_DIR && install_fonts $FONT_DIR
# cd ~/.local/share/fonts && \
# curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf && \
# curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf &&\
# curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf && \
# curl -L -O https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf
install
source ~/.zshrc
;;
Darwin*)
machine=Mac
echo "Installing on ${unameOut}"
which brewa
if [[ "$?" == 0 ]] ; then
echo 'brew found'
else
echo "brew not found"
echo "Installing brew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew tap homebrew/cask-fonts
brew install --cask font-meslo-lg-nerd-font
brew install romkatv/powerlevel10k/powerlevel10k
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
osascript -e "tell application \"Terminal\" to set the font name of window 1 to \"MesloLGM Nerd Font\""
osascript -e "tell application \"Terminal\" to set the font size of window 1 to 12"
# install
;;
*)
machine="OTHER:${unameOut}"
echo "Platform unsupported. (${unameOut})"
;;
esac