Automating the process of creating daily memo files with shell scripts

Automate with shell scripts

Hello. I'm Kamiyama, who joined the development department just recently.
I fire up my text editor to jot down things I've researched that day or things that have been on my mind, but the manual routine process has become tedious.
In this article, I'd like to use a shell script to solve this problem.

Click here for table of contents

  • 1. What I want to do
  • 2. Create a shell script
  • 3. Execute the shell script
  • 4. Summary

What I want to do.

▼ Currently, the following tasks are being done manually.

1. Open the directory where the memo is saved with VSCode.
2. Create a memo file for today in the format yyyy-MM-dd.md (e.g. 2021-01-20.md)
3. Copy and paste the template into the file you created.

Hmm, this is troublesome. Let's automate tasks 1-3 with a shell script ASAP!

Create a shell script

This time, we'll work in the directory /home/kouyama/memo-script.
Let's create a shell script named memo.sh.

If a file named template exists in the same directory as the shell script, it will be used to create a new memo file.
Now, let's also create a template file.

Preparation is complete. Now it's time to run the shell script!

Run a shell script

First, give the shell script execute permission.

$ chmod +x memo.sh

Next, pass through or alias the directory where the shell script resides.
This time we will set an alias.

alias memo=/home/kouyama/memo-script/memo.sh

Now let's run it.

$ memo

 

VSCode is up and running, and it's opening a file with today's date!

summary

Small routine tasks of daily life were automated with shell scripts.
There are a lot of routine tasks in our daily lives, so let's automate them to the extent it's worth the cost!

en_USEnglish