Skip to content

Commit b552d3d

Browse files
committed
Update setup.sh
fix some expansion bugs and making the main function cleaner
1 parent bdb492c commit b552d3d

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

binfiles/setup.sh

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

3-
dir=./lazy_bash
3+
dir="$HOME/lazy_bash"
44

55
function fetchrepo() {
66
# Clone git repo
7-
git clone https://github.com/tim0n3/lazy-bash.git && cd lazy-bash
7+
echo -e "Preparing environment\n"
88
sleep 2
9+
echo -e "Fetching repo and installing shell overhaul.\n"
10+
git clone https://github.com/tim0n3/lazy-bash.git && cd lazy-bash
11+
}
12+
13+
function installdeps() {
914
# copy libraries to the user's home folder
1015
cp -R bash_aliases ~/
11-
sleep 2
16+
1217
# overwrite the current .bashrc and load the new shell features
1318
cat bashrc > ~/.bashrc && cd ~/
14-
sleep 2
19+
}
20+
21+
function reloadshell() {
1522
# Go $Home and reload the shell
16-
source ./.bashrc
23+
source ~/.bashrc
1724
reloadbash
1825
}
1926

27+
2028
function cleanup() {
2129
# Remove detected folders with same name as git repo
2230
echo -e "Cleaning up left overs\n"
2331
rm -rf ~/lazy-bash
2432
}
2533

26-
#
27-
if [ -d ! ./bash_aliases ]; then
28-
# Directory exists
29-
fetchrepo;
34+
# Main function
35+
# Check ~/bash_aliases dir exists and cleaup else proceed \
36+
# with a normal installation:
37+
if [ -d ! "$HOME/bash_aliases" ]; then
38+
# Directory exists == redownload
39+
cleaup
40+
fetchrepo
41+
installdeps
42+
reloadshell
3043
sleep 2
3144
else
32-
# Directory doesn't exist
33-
echo -e "Preparing environment\n"
34-
cleanup;
35-
sleep 2
36-
echo -e "Fetching repo and installing shell overhaul.\n"
45+
# Directory doesn't exist == business as usual
3746
fetchrepo
47+
cleanup
3848
fi

0 commit comments

Comments
 (0)