Skip to content

Instantly share code, notes, and snippets.

@realyukii
Created August 28, 2024 00:23
Show Gist options
  • Save realyukii/d29fc029fc0882a5e33cf452f09285ef to your computer and use it in GitHub Desktop.
Save realyukii/d29fc029fc0882a5e33cf452f09285ef to your computer and use it in GitHub Desktop.
expand day name on cal unix command
#!/usr/bin/sh
cal | python3 -c "
import sys
lines = sys.stdin.read().splitlines()
# Replace weekday abbreviations with full names, ensuring consistent spacing
header = lines[1]
header = header.replace('Su', 'Sunday ').replace('Mo', 'Monday ').replace('Tu', 'Tuesday ').replace('We', 'Wednesday').replace('Th', 'Thursday ').replace('Fr', 'Friday ').replace('Sa', 'Saturday ')
# Print the month/year and the modified header
print(lines[0])
print(header)
# Format and print each line of the calendar
for line in lines[2:]:
formatted_line = ' '.join(day.ljust(9) if day.isdigit() else day for day in line.split())
print(formatted_line)
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment