Basically, the flow is like opening touch-> file with an editor in Python, but at that time, at the beginning of each line
python
# -*- coding:utf-8 -*-
It's extremely troublesome to write, and in most cases I write this, so I wrote a shell script for it.
python
#!/bin/bash
#Argument check
if [ $# -ne 1 ]; then
echo "usage: pytouch TOUCHFILE.py"
exit 1
fi
#Exit if the file exists (because it will not be overwritten)
if [ -e $1 ]; then
exit 0
fi
touch $1
#to echo-You can use line breaks by passing the e option
echo -e "# -*- coding:utf-8 -*-\n" > $1
exit 0
After that, save it with a name like pytouch
in the place where the path passes, and complete it with chmod + x
.
Depending on the type
python
if __name__ == "__main__":
main()
It seems convenient to make a version that includes.
Recommended Posts