Skip to content

Commit c902ac6

Browse files
committed
Update setup.sh
lots of fixes and quit on error at certain points.
1 parent b552d3d commit c902ac6

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

binfiles/setup.sh

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,52 @@
11
#!/bin/bash
22

33
dir="$HOME/lazy_bash"
4+
aliasdir="$HOME/bash_aliases"
45

56
function fetchrepo() {
67
# Clone git repo
78
echo -e "Preparing environment\n"
8-
sleep 2
9+
sleep 1
910
echo -e "Fetching repo and installing shell overhaul.\n"
10-
git clone https://github.com/tim0n3/lazy-bash.git && cd lazy-bash
11-
}
11+
sleep 1
12+
git clone https://github.com/tim0n3/lazy-bash.git "$dir" && cd "$dir" || exit 1
13+
}
1214

1315
function installdeps() {
14-
# copy libraries to the user's home folder
15-
cp -R bash_aliases ~/
16+
# Copy libraries to the user's home folder
17+
cp -R "$dir/bash_aliases" "$HOME/"
1618

17-
# overwrite the current .bashrc and load the new shell features
18-
cat bashrc > ~/.bashrc && cd ~/
19+
# Overwrite the current .bashrc and load the new shell features
20+
cat "$dir/bashrc" > "$HOME/.bashrc" && cd "$HOME" || exit 1
1921
}
2022

2123
function reloadshell() {
2224
# Go $Home and reload the shell
23-
source ~/.bashrc
24-
reloadbash
25+
source "$HOME/.bashrc"
2526
}
2627

27-
2828
function cleanup() {
29-
# Remove detected folders with same name as git repo
30-
echo -e "Cleaning up left overs\n"
31-
rm -rf ~/lazy-bash
29+
# Remove detected folders with the same name as git repo
30+
echo -e "Cleaning up leftovers\n"
31+
rm -rf "$dir" "$aliasdir"
3232
}
3333

3434
# Main function
35-
# Check ~/bash_aliases dir exists and cleaup else proceed \
35+
# Check ~/bash_aliases dir exists and cleanup else proceed \
3636
# with a normal installation:
37-
if [ -d ! "$HOME/bash_aliases" ]; then
37+
if [ -d "$HOME/bash_aliases" ]; then
3838
# Directory exists == redownload
39-
cleaup
39+
cleanup
4040
fetchrepo
4141
installdeps
4242
reloadshell
43+
cleanup
4344
sleep 2
4445
else
4546
# Directory doesn't exist == business as usual
4647
fetchrepo
48+
installdeps
49+
reloadshell
4750
cleanup
4851
fi
52+

0 commit comments

Comments
 (0)