Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: fix colors, make backup safer #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@
#-----------------------------------------------------------------------------
# Functions
#-----------------------------------------------------------------------------
# The different colours as variables
Y="\033[01;33m" # YELLOW
C="\033[01;36m" # CYAN
W="\033[01;37m" # WHITE
B="\033[01;34m" # BLUE
G="\033[01;32m" # GREEN
D="\033[01;31m" # RED
X="\033[00;37m" # Not sure...
R="\033[0m"


# Notice title
notice() { echo "\033[1;32m=> $1\033[0m"; }
notice() { echo -e "${G}=> $1${R}"; }

# Error title
error() { echo "\033[1;31m=> Error: $1\033[0m"; }
error() { echo -e "${D}=> Error: $1${R}"; }

# List item
c_list() { echo " \033[1;32m✔\033[0m $1"; }
c_list() { echo -e " ${G}+${R} $1"; }

# Error list item
e_list() { echo " \033[1;31m✖\033[0m $1"; }
e_list() { echo -e " ${D}-${R} $1"; }

# Check for dependency
dep() {
Expand All @@ -33,7 +43,10 @@ backup() {

local files=( $(ls -a) )
for file in "${files[@]}"; do
in_array $file "${excluded[@]}" || cp -Rf "$HOME/$file" "$backupdir/$file"
in_array $file "${excluded[@]}"
if [ $? -ne 0 -a -r "$HOME/$file" ]; then
mv -f "$HOME/$file" "$backupdir/" || { error "Cannot backup $HOME/$file"; exit 1; }
fi
done
}

Expand Down