-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.bash
107 lines (97 loc) · 2.8 KB
/
install.bash
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
#!/bin/bash
# check if .bash already exists, backup
if [ -d "$HOME/.bash" ]; then
while true; do
read -p "Existing bash config found, do you wish to overwrite? Existing config will be stored in '$HOME/.bash.old' (Y/n) " yn
case $yn in
[Yy]* ) mv -f "$HOME/.bash" "$HOME/.bash.old"; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# check if .bashrc already exists, backup
if [ -f "$HOME/.bashrc" ]; then
mv "$HOME/.bashrc" "$HOME/.bashrc.old"
fi
# clone new bash config
git clone https://github.com/jswent/bash "$HOME/.bash"
# link bash config to .bashrc
echo "Creating symlink $HOME/.bash/.bashrc -> $HOME/.bashrc"
ln -s "$HOME/.bash/.bashrc" "$HOME/.bashrc"
OS=""
VER=""
# get os name
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si)
VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$DISTRIB_ID
VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS=Debian
VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
VER=$(uname -r)
fi
install_program () {
if [[ "$OS" == "Arch Linux" ]]; then
sudo pacman -S "$1"
elif [[ "$OS" == "Ubuntu" ]]; then
sudo apt install "$1"
elif [[ "$OS" == "Darwin" ]]; then
sudo brew install "$1"
else
echo "Failed to install $1, please install manually"
fi
}
# check if fzf is installed
if ! command -v fzf &> /dev/null; then
while true; do
read -p "[ERROR] fzf was not found on your system, would you like to install it? (Y/n) " yn
case $yn in
[Yy]* ) install_program "fzf"; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# check if neofetch is installed
if ! command -v neofetch &> /dev/null; then
while true; do
read -p "[ERROR] neofetch was not found on your system, would you like to install it? (Y/n) " yn
case $yn in
[Yy]* ) install_program "neofetch"; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# check if exa is installed
if ! command -v exa &> /dev/null; then
while true; do
read -p "[ERROR] exa was not found on your system, would you like to install it? (Y/n) " yn
case $yn in
[Yy]* ) install_program "exa"; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
fi