forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config-ohmyzsh.sh
executable file
·100 lines (88 loc) · 3.61 KB
/
config-ohmyzsh.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
# if havent install zsh, install it first
###
# @Author: HernandoR [email protected]
# @CreateDate: Do not edit
# @LastEditors: HernandoR [email protected]
# @LastEditTime: 2024-04-04
# @Description:
#
# Copyright (c) 2024 by HernandoR [email protected], All Rights Reserved.
###
# if [ ! command -v zsh ] &> /dev/null
# then
# echo "zsh could not be found"
# echo "installing zsh"
# sudo apt -y install zsh
# echo "zsh installed please run this script again"
# exit 1
# fi
# chsh -s /usr/bin/zsh
if [ ! -d "./sources" ]; then
echo "please excute this script in the dotfiles directory"
exit 1
fi
# check if the hostmachine can curl to github
Github_Reachable=$(curl -Is https://raw.githubusercontent.com | head -n 1 | grep "200")
if [ -z $Github_Reachable ]; then
Github_Reachable=false
else
Github_Reachable=true
fi
if [ $Github_Reachable=true ]; then
echo "github is reachable"
else
echo "github is not reachable"
echo "Using local scripts / gitee ."
fi
# read the script's directory
# DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# DotFilesDir=DIR/../dotfiles
echo "update submodules"
git submodule init
git submodule update
# check if oh-my-zsh is installed
if [ -f ~/.oh-my-zsh/oh-my-zsh.sh ]; then
echo "oh-my-zsh is already installed"
else
if [ -d ~/.oh-my-zsh ]; then
echo "oh-my-zsh was installed"
echo "bakingup omz dir"
rm -rf ~/oh-my-zsh.bkp
mv ~/.oh-my-zsh ~/oh-my-zsh.bkp
else
echo "oh-my-zsh is not installed"
fi
echo "installing oh-my-zsh"
if [ $Github_Reachable=false ]; then
echo "installing oh-my-zsh from gitee"
curl -fsSL https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh -o ./install.sh
else
echo "installing oh-my-zsh from github"
curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -o ./install.sh
fi
alias exit=return
export RUNZSH=no
export CHSH=no
sh ./install.sh
unset RUNZSH
unset CHSH
unalias exit
rm -f ./install.sh
fi
# install powerlevel10k, zsh-autosuggestions, zsh-syntax-highlighting
echo "installing powerlevel10k and zsh-autosuggestions and zsh-syntax-highlighting"
if [ $Github_Reachable=false ]; then
echo "installing powerlevel10k zsh-autosuggestions, zsh-syntax-highlighting from gitee"
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone --depth=1 https://gitee.com/githubClone/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone --depth=1 https://gitee.com/yuxiaoxi/zsh-syntax-highlighting ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
else
echo "installing powerlevel10k zsh-autosuggestions, zsh-syntax-highlighting from github"
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
git clone --depth=1 https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
fi
# copy the config files
echo "copying config"
cp -f ./sources/zsh_plugins/zsh-autosuggestions.plugin.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
cp -f ./sources/zsh_plugins/zsh-syntax-highlighting.plugin.zsh ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh