Create a folder for every month of the current year, or a provided year, in the current directory.
mkmonths () {
y=$([ $# -eq 1 ] && echo "$1" || echo $(date +"%Y"))
for i in {1..12}; do mkdir "$([ "$i" -gt 9 ] && echo "$i" || echo "0$i")-${y}"; done
}
Make current year's months.
mkmonths
Make a given year's months.
mkmonths 2019
Search for a text string in all files, excluding node_modules
, from the current or a provided directory.
search () {
if [ $# -eq 0 ]
then
echo "Provide a word in quotes to search for optionally followed by a directory to search in."
else
if [ $# -eq 1 ]
then
grep --exclude-dir=node_modules -Rl $1 .
else
grep --exclude-dir=node_modules -Rl $1 $2
fi
fi
}
### Use
```bash
search "import React from 'react'"
search "import cv2" ~/Documents/programming/python
Remove compiled python files from the current directory.
pyclean () {
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
}