Skip to content Skip to sidebar Skip to footer

Use Python To Dynamically Create Bash Aliases

I'm attempting to use python to dynamically create bash aliases (like, for example, aliases to log in to a set of servers). I'd love to be able to do something like this: from sub

Solution 1:

You should write the alias commands to stdout. (eg. just use print). Then the shell that is calling the Python script can run the alias commands itself.

As commented by @that other guy

eval"$(python yourscript.py)"

in your .bashrc should do it

Post a Comment for "Use Python To Dynamically Create Bash Aliases"