Skip to content

Commit d91bf65

Browse files
committed
uninstall: cleanup
1 parent c9bc905 commit d91bf65

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

clean_files.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ bash_it.sh
2727
clean_files.txt
2828
install.sh
2929
lint_clean_files.sh
30+
uninstall.sh
3031

3132
# aliases
3233
#

uninstall.sh

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
11
#!/usr/bin/env bash
2-
if [ -z "$BASH_IT" ];
3-
then
4-
BASH_IT="$HOME/.bash_it"
5-
fi
2+
: "${BASH_IT:=${HOME?}/.bash_it}"
63

7-
case $OSTYPE in
8-
darwin*)
9-
CONFIG_FILE=.bash_profile
10-
;;
11-
*)
12-
CONFIG_FILE=.bashrc
13-
;;
14-
esac
4+
CONFIG_FILE=".bashrc"
5+
if [[ ! -e ~/.bashrc && -e ~/.bash_profile ]]; then
6+
# legacy Mac or WSL or just no backup file
7+
CONFIG_FILE=".bash_profile"
8+
fi
159

1610
BACKUP_FILE=$CONFIG_FILE.bak
1711

18-
if [ ! -e "$HOME/$BACKUP_FILE" ]; then
19-
echo -e "\033[0;33mBackup file $HOME/$BACKUP_FILE not found.\033[0m" >&2
12+
if [[ ! -e "${HOME?}/$BACKUP_FILE" ]]; then
13+
echo -e "\033[0;33mBackup file ${HOME?}/$BACKUP_FILE not found.\033[0m" >&2
2014

21-
test -w "$HOME/$CONFIG_FILE" &&
22-
mv "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.uninstall" &&
23-
echo -e "\033[0;32mMoved your $HOME/$CONFIG_FILE to $HOME/$CONFIG_FILE.uninstall.\033[0m"
15+
test -w "${HOME?}/$CONFIG_FILE" \
16+
&& mv "${HOME?}/$CONFIG_FILE" "${HOME?}/$CONFIG_FILE.uninstall" \
17+
&& echo -e "\033[0;32mMoved your ${HOME?}/$CONFIG_FILE to ${HOME?}/$CONFIG_FILE.uninstall.\033[0m"
2418
else
25-
test -w "$HOME/$BACKUP_FILE" &&
26-
cp -a "$HOME/$BACKUP_FILE" "$HOME/$CONFIG_FILE" &&
27-
rm "$HOME/$BACKUP_FILE" &&
28-
echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
19+
test -w "${HOME?}/$BACKUP_FILE" \
20+
&& cp -a "${HOME?}/$BACKUP_FILE" "${HOME?}/$CONFIG_FILE" \
21+
&& rm "${HOME?}/$BACKUP_FILE" \
22+
&& echo -e "\033[0;32mYour original $CONFIG_FILE has been restored.\033[0m"
2923
fi
3024

3125
echo ""

0 commit comments

Comments
 (0)