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