update
This commit is contained in:
parent
5d4f6daef9
commit
98e1ee645a
142
bashrc
142
bashrc
|
@ -7,82 +7,96 @@ export SHELL_CONFIG="$SHELL_CONFIG:.bashrc"
|
||||||
#
|
#
|
||||||
|
|
||||||
function show_date() {
|
function show_date() {
|
||||||
# Define an array of adjectives with classifications
|
# Define the dot file to store the selected adjective
|
||||||
adjectives=(
|
dotfile="$HOME/.adjective_of_the_day"
|
||||||
"beautiful:positive"
|
|
||||||
"engaging:positive"
|
|
||||||
"majestic:positive"
|
|
||||||
"distinguished:positive"
|
|
||||||
"venerable:positive"
|
|
||||||
"formal:positive"
|
|
||||||
"elegant:positive"
|
|
||||||
"serene:positive"
|
|
||||||
"graceful:positive"
|
|
||||||
"regal:positive"
|
|
||||||
"noble:positive"
|
|
||||||
|
|
||||||
"miserable:negative"
|
# Check if the dot file exists and was modified less than 1 day ago
|
||||||
"worthless:negative"
|
if [[ -f "$dotfile" && $(date -d "$(stat -c %y "$dotfile")" +%s) -ge $(date -d 'yesterday' +%s) ]]; then
|
||||||
"depressing:negative"
|
# If the dot file exists and was modified less than 1 day ago,
|
||||||
"soulless:negative"
|
# read the stored adjective from the file
|
||||||
"desolate:negative"
|
selected_adjective=$(cat "$dotfile")
|
||||||
"archaic:negative"
|
else
|
||||||
"grim:negative"
|
# Define an array of adjectives with classifications
|
||||||
"dreadful:negative"
|
adjectives=(
|
||||||
"forlorn:negative"
|
"beautiful:positive"
|
||||||
"wretched:negative"
|
"engaging:positive"
|
||||||
|
"majestic:positive"
|
||||||
|
"distinguished:positive"
|
||||||
|
"venerable:positive"
|
||||||
|
"formal:positive"
|
||||||
|
"elegant:positive"
|
||||||
|
"serene:positive"
|
||||||
|
"graceful:positive"
|
||||||
|
"regal:positive"
|
||||||
|
"noble:positive"
|
||||||
|
|
||||||
"neutral:neutral"
|
"miserable:negative"
|
||||||
"ordinary:neutral"
|
"worthless:negative"
|
||||||
"common:neutral"
|
"depressing:negative"
|
||||||
"antique:neutral"
|
"soulless:negative"
|
||||||
"ceremonial:neutral"
|
"desolate:negative"
|
||||||
"timeless:neutral"
|
"archaic:negative"
|
||||||
"classic:neutral"
|
"grim:negative"
|
||||||
"historic:neutral"
|
"dreadful:negative"
|
||||||
"ancient:neutral"
|
"forlorn:negative"
|
||||||
)
|
"wretched:negative"
|
||||||
|
|
||||||
# Select a random adjective from the array
|
"neutral:neutral"
|
||||||
selected_adjective="${adjectives[$RANDOM % ${#adjectives[@]}]}"
|
"ordinary:neutral"
|
||||||
|
"common:neutral"
|
||||||
|
"antique:neutral"
|
||||||
|
"ceremonial:neutral"
|
||||||
|
"timeless:neutral"
|
||||||
|
"classic:neutral"
|
||||||
|
"historic:neutral"
|
||||||
|
"ancient:neutral"
|
||||||
|
)
|
||||||
|
|
||||||
# Split the selected adjective into the adjective and classification parts
|
# Select a random adjective from the array
|
||||||
IFS=':' read -r adjective classification <<< "$selected_adjective"
|
selected_adjective="${adjectives[$RANDOM % ${#adjectives[@]}]}"
|
||||||
|
|
||||||
# Determine the color code based on the classification
|
# Store the selected adjective in the dot file
|
||||||
case "$classification" in
|
echo "$selected_adjective" > "$dotfile"
|
||||||
"positive") text_color="\033[1;32m";;
|
fi
|
||||||
"negative") text_color="\033[1;31m";;
|
|
||||||
*) text_color="";; # Default to no colour
|
|
||||||
esac
|
|
||||||
|
|
||||||
# ANSI escape codes for reset
|
# Split the selected adjective into the adjective and classification parts
|
||||||
reset_color='\033[0m'
|
IFS=':' read -r adjective classification <<< "$selected_adjective"
|
||||||
hl_color='\033[1;34m'
|
|
||||||
|
|
||||||
# Get the current day of the week, day of the month, and year
|
# Determine the color code based on the classification
|
||||||
day_of_week=$(date "+%A")
|
case "$classification" in
|
||||||
day_of_month=$(date "+%d")
|
"positive") text_color="\033[1;32m";;
|
||||||
month_name=$(date "+%B")
|
"negative") text_color="\033[1;31m";;
|
||||||
year=$(date "+%Y")
|
*) text_color="";; # Default to no colour
|
||||||
|
esac
|
||||||
|
|
||||||
# Determine the day suffix (th, nd, rd)
|
# ANSI escape codes for reset
|
||||||
case "$day_of_month" in
|
reset_color='\033[0m'
|
||||||
1[0-9]) day_suffix="th";;
|
hl_color='\033[1;34m'
|
||||||
*1) day_suffix="st";;
|
|
||||||
*2) day_suffix="nd";;
|
|
||||||
*3) day_suffix="rd";;
|
|
||||||
*) day_suffix="th";;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Create the full date format with colored parts and the selected adjective
|
# Get the current day of the week, day of the month, and year
|
||||||
full_date="Pray, be informed, on this ${text_color}${adjective}${reset_color} day, ${hl_color}${day_of_week}${reset_color} the ${hl_color}${day_of_month}${day_suffix}${reset_color} day of ${hl_color}${month_name}${reset_color}, in the year of our Lord ${hl_color}${year}${reset_color}!"
|
day_of_week=$(date "+%A")
|
||||||
|
day_of_month=$(date "+%d")
|
||||||
|
month_name=$(date "+%B")
|
||||||
|
year=$(date "+%Y")
|
||||||
|
|
||||||
# Print the full date
|
# Determine the day suffix (th, nd, rd)
|
||||||
echo -e "$full_date"
|
case "$day_of_month" in
|
||||||
echo ""
|
1[0-9]) day_suffix="th";;
|
||||||
|
*1) day_suffix="st";;
|
||||||
|
*2) day_suffix="nd";;
|
||||||
|
*3) day_suffix="rd";;
|
||||||
|
*) day_suffix="th";;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Create the full date format with colored parts and the selected adjective
|
||||||
|
full_date="Pray, be informed, on this ${text_color}${adjective}${reset_color} day,\n${hl_color}${day_of_week}${reset_color} the ${hl_color}${day_of_month}${day_suffix}${reset_color} day of ${hl_color}${month_name}${reset_color}, in the year of our Lord ${hl_color}${year}${reset_color}!"
|
||||||
|
|
||||||
|
# Print the full date
|
||||||
|
echo -e "$full_date"
|
||||||
|
echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue