menu

Create a (Python) Script with a Head Including Information

Problem:

Every time when you create a new script, you alway need to add some information about the script, like create time, author, description, etc. But if you type in by hand every time, it’s time consuming, and also it’s hard to make a uniformed format.

Solution:

  • Write a simple Bash script to auto-generate a new (Python) script is good way to solve the problem above.

The script - kftouchpy:

FILE=$1
echo "\"\"\"
Filename: $FILE
Created on `date`

@author: Kefeng Zhu (john@doe.com)
Description:

\"\"\"
" > $FILE

Usage:

Simply run sh kftouchpy newfile.py, then open the newly created file newfile.py, we have:

"""
Filename: newfile.py
Created on Wed Mar 13 10:37:16 CST 2019

@author: Kefeng Zhu (john@doe.com)

Description:

"""

Make it More Convenient:

Puth the bash script in a directory that is included in your $PATH, and also remember to make it execuable. In this way, you can directly type kftouchpy newfile. Jobs Done!



KF

Comments