-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·67 lines (57 loc) · 1.8 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
#!/usr/bin/env bash
# Check the OS version
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=Linux ;;
Darwin*) machine=Mac ;;
CYGWIN*) machine=Cygwin ;;
MINGW*) machine=MinGw ;;
*) machine="UNKNOWN:${unameOut}" ;;
esac
# check if the zsh command is valid
if ! [ -x "$(command -v zsh)" ]; then
echo 'Error: zsh is not installed.'
return 1
fi
# check if the zsh command is valid
if ! [ -x "$(command -v git)" ]; then
echo 'Error: git is not installed.'
return 1
fi
printf "Would you like to install the zsh config? This will wipe your current .zsh directory (y/n) "
read -r installZshConfig
if [ $installZshConfig = "y" ]; then
echo "Installing zsh config..."
else
echo "Exiting install..."
return 1
fi
# If a previous .zsh folder exists, copy it to the new .zsh.backup folder
if [ -d $HOME/.zsh ]; then
echo "Backing up previous zsh config..."
cp -R $HOME/.zsh $HOME/.zsh.backup
fi
# If a zsh_history file exists, copy it to the home directory as a backup
if [ -f $HOME/.zsh/.zsh_history ]; then
echo "Copying zsh history..."
cp $HOME/.zsh/.zsh_history $HOME/.zsh_history.bak
else
echo "No zsh history found... Continuing..."
fi
if [ $machine = "Linux" ]; then
echo "Running installation for Linux...."
elif [ $machine = "Mac" ]; then
echo "Running installation for Mac...."
fi
touch $HOME/.zsh && touch $HOME/.zcompdump
rm -rf $HOME/.zsh* && rm -rf $HOME/.zcompdump*
git clone https://github.com/realshaunoneill/dotfiles.git $HOME/.zsh
echo "export ZDOTDIR=\$HOME/.zsh" >$HOME/.zshenv
echo "source \$ZDOTDIR/.zshenv" >>$HOME/.zshenv
# If a previous zsh_history file exists, copy it to the new .zsh folder
if [ -f $HOME/.zsh_history.bak ]; then
echo "Restoring zsh history..."
cp $HOME/.zsh_history.bak $HOME/.zsh/.zsh_history
fi
chsh -s $(which zsh)
zsh