Library of decorator aliases (daliases) for the xonsh shell.
If you like the idea click ⭐ on the repo and tweet.
To install use pip:
xpip install xontrib-dalias
# or
xpip install 'xontrib-dalias[dict,yaml]' # With extra decorators.Load:
xontrib load daliasDecorators:
- Default:
@lines- return list of lines.@json- json to Pythondict.@path- string topathlib.Path.@parts- split by whitespaces using xonsh lexer. It's the same as builtin@$()operator.
- Extra (
xpip install 'xontrib-dalias[dict,yaml]'):@dict- dict-like object (json, JavaScript object, Python dict) to Pythondict.@yaml- YAML to Pythondict.
$(@lines ls /)
# ['/bin', '/etc', '/home']
$(@json echo '{"a":1}') # Try with `curl` ;)
# dict({"a":1})
docker inspect @($(@json docker ps --format json)['ID'])
# Container info
$(@path which -s xonsh)
# Path('/path/to/xonsh')
$(@path which -s xonsh).parent
# Path('/path/to')
aliases['ydig'] = '@yaml dig +yaml' # Update `dig` via `brew install bind` to have `+yaml`.
y = $(ydig google.com)
y[0]['type']
# 'MESSAGE'Piping into decorated alias to get object:
$(echo '{"a":1}' | @json cat)
# dict({"a":1})aliases['@j'] = '@json cat'
$(echo '{"a":1}' | @j)
# dict({"a":1})Default decorators:
@err- set$RAISE_SUBPROC_ERROR=Truefor the command.@noerr- set$RAISE_SUBPROC_ERROR=Falsefor the command.
Examples:
$RAISE_SUBPROC_ERROR = True # General environment.
if ![@noerr ls nononofile]: # Do not raise exception in case of error.
echo file This package was created with xontrib template.