-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·135 lines (111 loc) · 3.79 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
#!/bin/bash
# Author: Gardar Thorsteinsson
USER_GIT_AUTHOR_NAME="Garðar Þorsteinsson"
USER_GIT_AUTHOR_EMAIL="[email protected]"
function setup_bash() {
echo 'Installing oh-my-bash...'
sh -c "$(curl -fsSL https://raw.github.com/ohmybash/oh-my-bash/master/tools/install.sh)"
}
function setup_zsh() {
echo 'Installing oh-my-zsh...'
# sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
OHMYZSH_PATH=$HOME/.oh-my-zsh
ZSH_CUSTOM=$HOME/.oh-my-zsh/custom
mkdir -p $ZSH_CUSTOM/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# Change theme
mkdir -p $ZSH_CUSTOM/themes
curl -fsSL https://raw.githubusercontent.com/gardart/minidot/main/gardar.zsh-theme -o $ZSH_CUSTOM/themes/gardar.zsh-theme
sed -i 's/ZSH_THEME="robbyrussell"/ZSH_THEME="gardar"/g' ~/.zshrc
# Install plugins
sed -i '/^plugins=/s/.*/plugins=\(git vi-mode sudo tmux virtualenv zsh-autosuggestions zsh-syntax-highlighting\)/g' ~/.zshrc
# Fix permissions
chmod -R g-w,o-w $ZSH_CUSTOM || true
mkdir -p $OHMYZSH_PATH/cache/completions || true
chmod -R g-w,o-w $OHMYZSH_PATH/cache/completions || true
}
function determine_shell() {
echo 'Please pick your favorite shell:'
echo '(1) Bash'
echo '(2) Zsh'
read -p 'Enter a number: ' SHELL_CHOICE
if [[ $SHELL_CHOICE == '1' ]] ; then
export LOGIN_SHELL="bash"
elif [[ $SHELL_CHOICE == '2' ]] ; then
export LOGIN_SHELL="zsh"
else
echo 'Could not determine choice.'
exit 1
fi
}
function setup_vim() {
echo "Setting up vim...ignore any vim errors post install"
vim +PlugInstall +qall
}
function setup_git() {
echo 'Setting up git config...'
read -e -p 'Enter Github author name: ' -i "$USER_GIT_AUTHOR_NAME" GIT_USER
git config --global user.name "$GIT_USER"
read -e -p 'Enter Github email: ' -i "$USER_GIT_AUTHOR_EMAIL" GIT_EMAIL
git config --global user.email $GIT_EMAIL
git config --global core.editor vim
git config --global color.ui true
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
}
function symlink_files() {
# Uncomment the following line to delete all symlinks at the root of $HOME - useful for reinstalls
# find "$HOME" -maxdepth 1 -type l -exec rm -f {} \;
SELF_PATH="$( cd "$( dirname "$0" )" && pwd )" # Path to the directory containing this script
# Create symlinks
for file in `find $SELF_PATH -maxdepth 1 -name \*.symlink`; do
src_file=`basename "$file"`
dest_file=`echo "$HOME/.$src_file" | sed "s/\.symlink$//g"`
if [ -e $dest_file ]; then
echo "$dest_file already exists; skipping it..."
else
ln -sv $SELF_PATH/$src_file $dest_file
fi
done
}
set -e
(
determine_shell
symlink_files
setup_vim
while true; do
read -p "Configure Git?" yn
case $yn in
[Yy]* ) setup_git; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Configure bash/zsh and install oh-my-zsh/oh-my-bash?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
if [[ $LOGIN_SHELL == 'bash' ]] ; then
setup_bash
elif [[ $LOGIN_SHELL == 'zsh' ]] ; then
setup_zsh
fi
if [[ $LOGIN_SHELL == 'bash' ]] ; then
echo "Operating System setup complete."
echo "Reloading session"
source ~/.bashrc
elif [[ $LOGIN_SHELL == 'zsh' ]] ; then
echo "Changing shells to ZSH"
chsh -s /bin/zsh
echo "Operating System setup complete."
echo "Reloading session"
exec zsh
fi
)