Even though, I think terminals are kind of ancient tool, it is unquestionably useful when you are accessing to a remote server and etc. Despite the fact that I know how to add aliases for my ssh connections(thanks to Murat Kırtay), I really hated to go through to my .zshrc configuration to edit it to add an alias.
First I wrote a very basic alias adder script and placed it to the /Users/tdgunes/Utils folder. (I am sorry that I didn’t find the time to make it completely modular and clean for other people.)
ZSH_PATH = "/Users/tdgunes/.zshrc"
def add_alias(keyword, alias):
with open(ZSH_PATH, "a") as zsh_file:
zsh_file.write("alias "+keyword +"=\""+alias+"\"\n")
os.system("tail " + ZSH_PATH)
print "write this if you want to apply the config now":
print ". "+ZSH_PATH
if __name__ == '__main__':
keyword = raw_input("keyword(get): ")
alias = raw_input("alias(curl ..): ")
After putting this into Utils folder named as new_alias.py, go to your .zshrc file. And add this at the end of the file:
alias new_alias="python /Users/tdgunes/Utils/new_alias.py"
Now it will become so easy to add other python files. Go to my terminal utils gist, you can download the other scripts. For instance, you can automate your ssh logins by just adding the script (named as add_ssh.py) to your aliases and then when your alias is called, by filling user name and the host name, your password twice and it will put to your keychain, so you don’t need to write your password every time when you login to a remote server.