Member-only story
Automating Tasks with Python & MacOS Terminal
Many of us probably have tasks in our computers that we wish to automate — from long ssh commands that we do not wish to type out in full to our very own password generators. The good news is that if we can perform the task using a Python script, we can run this Python script from anywhere in our computer with a zsh alias.
What an alias can do
Imagine you have a python script that does some task for you in this certain directory.
/Users/yourname/Documents/yourcli/run.py
Let’s say we want to run this script from our default Terminal directory, because who wants to keep changing directory right? The default Terminal directory is usually this:
/Users/yourname
To run our script, we need to type our the path to our python script.
python3 Documents/yourcli/run.py
However, with an alias, we can simply type our alias into terminal, and it’ll do the exact same thing. Let’s say we set an alias “myalias” for our Python script. We simply need to type our alias to run our Python script.
myalias
While this does not warrant a Nobel Prize in automation or time-saving technology, it does reduce the cumulative annoyance we could potentially…