-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.sh
executable file
·147 lines (130 loc) · 4.33 KB
/
install.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Note: This installation script assumes a macOS or Debian-based system.
EMOJI_NEWLINE=" →"
OS=$(uname -s)
OMZ_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}
OMZ_CUSTOM_PLUGINS="$OMZ_CUSTOM/plugins"
OMZ_CUSTOM_THEMES="$OMZ_CUSTOM/themes"
OMZ_THEME_NAME="honukai_modified.zsh-theme"
GH_DOTFILES_RAW="https://raw.githubusercontent.com/jcmanzo/dotfiles/main/files"
# Check user flag "p" for option to use remote dotfiles
while getopts "r" opt; do
case $opt in
r)
echo "$EMOJI_NEWLINE Using remote dotfiles"
REMOTE_DOTFILES=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
init_pkg_manager () {
echo "$EMOJI_NEWLINE Initializing pkg manager"
if [ "$OS" == "Darwin" ]; then
# If Darwin, install Homebrew
if ! [ -x "$(command -v brew)" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo " $EMOJI_NEWLINE Installed Homebrew"
fi
echo " $EMOJI_NEWLINE Updating Homebrew"
brew update 1> /dev/null
else
sudo apt-get update
fi
}
install_pkgs () {
declare -a StringArray=("zsh" "autojump" "tldr" "fzf" "ripgrep")
echo "$EMOJI_NEWLINE Initializing packages"
for pkg in ${StringArray[@]}; do
if [ "$OS" == "Darwin" ]; then
if ! [ -x "$(command -v $pkg)" ]; then
brew install $pkg 1> /dev/null
echo " $EMOJI_NEWLINE Installed $pkg"
fi
else
if ! [ -x "$(command -v $pkg)" ]; then
sudo apt-get install $pkg -y 1> /dev/null
echo " $EMOJI_NEWLINE Installed $pkg"
fi
fi
done
}
init_oh_my_zsh() {
# Install oh-my-zsh
echo "$EMOJI_NEWLINE Initializing oh-my-zsh"
if [ -d "$HOME/.oh-my-zsh" ]; then
echo " $EMOJI_NEWLINE Detected installed oh-my-zsh framework"
else
/bin/bash -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo " $EMOJI_NEWLINE Installed oh-my-zsh framework"
fi
# Install extra oh-my-zsh plugins
declare -a StringArray=("zsh-autosuggestions" "zsh-syntax-highlighting")
echo " $EMOJI_NEWLINE Installing zsh plugins"
for plugin in ${StringArray[@]}; do
if [ -d $OMZ_CUSTOM_PLUGINS/$plugin ]; then
echo " $EMOJI_NEWLINE Detected installed '$plugin' plugin."
else
git clone --quiet "https://github.com/zsh-users/$plugin" $OMZ_CUSTOM_PLUGINS/$plugin
echo " $EMOJI_NEWLINE Installed $plugin"
fi
done
}
init_dotfiles() {
echo "$EMOJI_NEWLINE Initializing dot files"
declare -a StringArray=(".zshrc" ".vimrc" ".tmux.conf")
for file in ${StringArray[@]}; do
if [ -f $HOME/$file ]; then
echo " $EMOJI_NEWLINE Detected '$file' file. Backing up to $HOME/$file.bak"
cp -n $HOME/$file{,.bak}
rm $HOME/$file
fi
if [ "$REMOTE_DOTFILES" = true ]; then
helper_download_file $file "$HOME/$file"
else
ln -fs $(pwd)/files/$file "$HOME/$file"
fi
echo " $EMOJI_NEWLINE Copied over $file"
done
}
init_custom_omzsh() {
# Install my custom plugins
# Loop over and copy files in files/oh-my-zsh/custom/plugins/jc-git
echo "$EMOJI_NEWLINE Initializing custom oh-my-zsh plugins"
declare -a StringArray=("git")
for plugin in ${StringArray[@]}; do
if [ -d $OMZ_CUSTOM_PLUGINS/$plugin ]; then
echo " $EMOJI_NEWLINE Detected installed '$plugin' plugin."
else
cp -rn $(pwd)/files/oh-my-zsh/custom/plugins/$plugin "$OMZ_CUSTOM_PLUGINS/$plugin"
fi
done
echo "$EMOJI_NEWLINE Installing latest custom Honukai theme"
if [ "$REMOTE_DOTFILES" = true ]; then
helper_download_file "oh-my-zsh/custom/themes/$OMZ_THEME_NAME" "$OMZ_CUSTOM_THEMES/$OMZ_THEME_NAME"
else
cp -rfn $(pwd)/files/oh-my-zsh/custom/themes/$OMZ_THEME_NAME "$OMZ_CUSTOM_THEMES/$OMZ_THEME_NAME"
fi
}
init_vim_plugin_manager() {
# Install Vim plugin manager
if [ -f ~/.vim/autoload/plug.vim ]; then
echo "$EMOJI_NEWLINE Detected installed Vim plugin manager."
else
echo "$EMOJI_NEWLINE Installing Vim plugin manager."
curl -fLo ~/.vim/autoload/plug.vim --create-dirs --silent \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
}
helper_download_file() {
echo " $EMOJI_NEWLINE Downloading file: $1"
curl -sSL $GH_DOTFILES_RAW/$1 > $2
}
init_pkg_manager
install_pkgs
init_oh_my_zsh
init_dotfiles
init_custom_omzsh
init_vim_plugin_manager