generated from delucca/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel De Lucca
authored
Apr 17, 2021
1 parent
fa9a8f8
commit d37f43b
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
function update_su_timestamp { | ||
sudo -k | ||
sudo -v | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Imports | ||
# ------------------------------------------------------------------------------------------------- | ||
|
||
source <(curl -s https://raw.githubusercontent.com/tlatsas/bash-spinner/master/spinner.sh) | ||
|
||
# ------------------------------------------------------------------------------------------------- | ||
|
||
function start_spinner_in_category { | ||
category=$1 | ||
message=$2 | ||
|
||
full_message=" \x1B[36m\r➤\e[1m ${category}:\x1B[0m ${message}" | ||
|
||
start_spinner "${full_message}" | ||
} | ||
|
||
function log_title { | ||
message=$1 | ||
|
||
bold=$(tput bold) | ||
reset=$(tput sgr0) | ||
magenta=$(tput setaf 5) | ||
number_of_columns="$(($(tput cols)-27))" | ||
separator_spaces=$(printf "%${number_of_columns}s") | ||
|
||
echo | ||
echo "${bold}${magenta}${message}${reset}" | ||
echo ${separator_spaces// /-} | ||
} | ||
|
||
function log_error { | ||
message=$1 | ||
|
||
bold=$(tput bold) | ||
reset=$(tput sgr0) | ||
red=$(tput setaf 1) | ||
|
||
echo "${bold}${red}Error:${reset}" | ||
echo "${red} ${message}${reset}" | ||
} | ||
|
||
function throw_error { | ||
message=$1 | ||
|
||
log_error "${message}" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Imports | ||
# ------------------------------------------------------------------------------------------------- | ||
|
||
source <(https://raw.githubusercontent.com/delucca/shell-functions/1.0.0/modules/feedback.sh) | ||
|
||
# Helpers | ||
# ------------------------------------------------------------------------------------------------- | ||
|
||
function validate_bash_dependency { | ||
major_version="$(bash --version | head -1 | cut -d ' ' -f 4 | cut -d '.' -f 1)" | ||
min_major_version="4" | ||
|
||
if [ "${major_version}" -lt "${min_major_version}" ]; then | ||
throw_error "Your bash major version must be ${min_major_version} or greater" | ||
fi | ||
} |