I use three files to configure my bash shell:
.bash_alias. I occasionally change these files but rarely remember to record the changes in my backup gist. So I decided to make a cronjob that would automatically back up these three files.
First, the backup script
The following script does three things:
- Copies the actual
.bash_aliasfiles to a GitHub gist repo
- Commits and pushes the changes to GitHub
- Displays a native Apple notification that the process was run
Second, the cronfile
The script must be executed automatically. Ideally I would run the script on boot, but I didn’t want to make the effort for the script to wait until an internet connection was formed. My solution was to push changes to GitHub three times a day. When I worked more consistent hours, I only pushed changes once a week when I knew I would be coding at work.