How to shell alias commands to be reusable in Python code?

43 views
Skip to first unread message

Tom Schwaller

unread,
Mar 7, 2018, 12:48:15 PM3/7/18
to xonsh
Hi all,
I recently started to heavily use and promote xonsh. It allowed me to reduce the length of Bash code to a fraction of it! Nice!

The only problem I faced so far is probably a FAQ but I could not find a solution.

I use shell commands like the following

om -k -t @(self.target) -u @(self.user) -p @(self.password) configure-bosh \
--networks-configuration @(self.networks_configuration) \
--network-assignment @(self.network_assignment)

many times in my Python classes and would just do something like:

omcli configure-bosh \ --networks-configuration @(self.networks_configuration) \
--network-assignment @(self.network_assignment)

where omcli is an abbreviation for

om -k -t @(self.target) -u @(self.user) -p @(self.password)

I tried several things, but all did not work. Can somebody tell me how to do that?

thanks for the help and the good work!

Tom Schwaller

Tom Schwaller

unread,
Mar 7, 2018, 4:49:05 PM3/7/18
to xonsh
I found the hint in the 0.6 release notes and then in the docs how to define aliases:

aliases['omcli'] = 'om -k -t ' + self.target + ' -u ' + self.user + \
' -p ' + self.password

works perfectly! ;-)
Reply all
Reply to author
Forward
0 new messages