-
Notifications
You must be signed in to change notification settings - Fork 5
Alias
The CLI provides a command called alias that allows you to save morpheus commands and re-run them later by a familiar, easy to remember, name.
morpheus> alias my-instances='instances list -c "My Cloud"'
Then you can run the following
morpheus> my-instances
You may also append arguments to your alias.
morpheus> my-instances --json
Aliases can be exported for use in subsequent shells.
Include the -e
option when creating it to export an alias
morpheus> alias my-other-instances='clouds list -c "Other Cloud"' -e
Or use alias export
to export any number of aliases
morpheus> alias export my-instances my-other-instances
To have an alias always available, just define it in your .morpheus_profile or .morpheusrc scripts.
Any aliases you define in .morpheus_profile will be available when morpheus
starts.
Any aliases defined in .morpheusrc will be made available whenever an interactive morpheus shell
starts.
Note: Exported aliases are stored at the bottom of your .morpheus_profile, any modifications below that section will be lost. Put your script above it.
When you are done using an exported alias, you may remove it with the alias remove
command.
morpheus> alias remove my-instances
Your exported aliases are made available inside the Morpheus Shell
morpheus shell
morpheus> my-instances
You can use alias list
to see which aliases you have configured.
morpheus> alias list
Found 3 aliases
aliases='alias list'
c='clouds'
g='groups'
It is also possible for an alias to invoke another alias, like this:
morpheus> alias foo='instances list -s test -m 100'
morpheus> alias bar='foo --json'
morpheus> foo
Morpheus Instances - Search: test
==================
No instances found.
morpheus> bar
{
"instances": [
],
"stats": {
},
"loadBalancers": [
],
"meta": {
"offset": 0,
"max": "100",
"size": 0,
"total": 0
}
}
morpheus>
That's all there is to it!