update
This commit is contained in:
parent
5d4f6daef9
commit
98e1ee645a
16
bashrc
16
bashrc
|
@ -7,6 +7,15 @@ export SHELL_CONFIG="$SHELL_CONFIG:.bashrc"
|
|||
#
|
||||
|
||||
function show_date() {
|
||||
# Define the dot file to store the selected adjective
|
||||
dotfile="$HOME/.adjective_of_the_day"
|
||||
|
||||
# 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"
|
||||
|
@ -46,6 +55,10 @@ function show_date() {
|
|||
# Select a random adjective from the array
|
||||
selected_adjective="${adjectives[$RANDOM % ${#adjectives[@]}]}"
|
||||
|
||||
# Store the selected adjective in the dot file
|
||||
echo "$selected_adjective" > "$dotfile"
|
||||
fi
|
||||
|
||||
# Split the selected adjective into the adjective and classification parts
|
||||
IFS=':' read -r adjective classification <<< "$selected_adjective"
|
||||
|
||||
|
@ -76,13 +89,14 @@ function show_date() {
|
|||
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, ${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}!"
|
||||
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