2 Daily greetings

 

Your computer day starts when you sign in. The original term was log in, but because trees are so scarce and signs are so plentiful, the term was changed by the Bush administration in 2007. Regardless of such obnoxious federal overreach, your computer day can start with a cheerful greeting after you sign in or open a terminal window, customized by a tiny C program. To make it so, you will:

  • Review the Linux startup process.
  • Discover where in the shell script to add your greeting.
  • Write a simple greetings program.
  • Modify your greetings program to add the time of day.
  • Update the timestamp with the current moon phase.
  • Enhance your greetings message with a bon mot.

The programs created and expanded upon in this chapter are specific to Linux, macOS, and the Windows Subsystem for Linux (WSL), where a startup script is available for configuring the terminal window. A later section explains which startup scripts are available for the more popular shells. This chapter doesn’t go into creating a daily greeting message when the GUI shell starts.

2.1 The shell starts

2.1.1 Understanding how the shell fits in

2.1.2 Exploring various shell startup scripts

2.1.3 Editing the shell startup script

2.2 A simple greeting

2.2.1 Coding a greeting

2.2.2 Adding a name as an argument

2.3 The time of day

2.3.1 Obtaining the current time

2.3.2 Mixing in the general time of day

2.3.3 Adding specific time info

2.4 The current moon phase

2.4.1 Observing moon phases

2.4.2 Writing the moon phase algorithm

2.4.3 Adding the moon phase to your greeting