Aliases (xonsh.aliases)

Aliases for the xonsh shell.

class xonsh.aliases.AWitchAWitch(option_strings, version=None, dest='==SUPPRESS==', default='==SUPPRESS==', **kwargs)[source]
SUPPRESS = '==SUPPRESS=='
class xonsh.aliases.Aliases(*args, **kwargs)[source]

Represents a location to hold and look up aliases.

clear(self)
eval_alias(self, value, seen_tokens=frozenset(), acc_args=())[source]

“Evaluates” the alias value, by recursively looking up the leftmost token and “expanding” if it’s also an alias.

A value like ["cmd", "arg"] might transform like this: > ["cmd", "arg"] -> ["ls", "-al", "arg"] -> callable() where cmd=ls -al and ls is an alias with its value being a callable. The resulting callable will be “partially applied” with ["-al", "arg"].

expand_alias(self, line)[source]

Expands any aliases present in line if alias does not point to a builtin function and if alias is only a single command.

get(self, key, default=None)[source]

Returns the (possibly modified) value. If the key is not present, then default is returned. If the value is callable, it is returned without modification. If it is an iterable of strings it will be evaluated recursively to expand other aliases, resulting in a new list or a “partially applied” callable.

items(self)
keys(self)
pop(self, key, default=<object object at 0x7f0fb2088050>)

If key is not found, d is returned if given, otherwise KeyError is raised.

popitem(self)

as a 2-tuple; but raise KeyError if D is empty.

setdefault(self, key, default=None)
update(self, *args, **kwargs)[source]

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values(self)
class xonsh.aliases.ExecAlias(src, filename='<exec-alias>')[source]

Provides a callable alias for xonsh source code.

Parameters
srcstr

Source code that will be

class xonsh.aliases.PartialEvalAlias0(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias1(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias2(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias3(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias4(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias5(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAlias6(f, acc_args=())[source]
Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

class xonsh.aliases.PartialEvalAliasBase(f, acc_args=())[source]

Partially evaluated alias.

Parameters
fcallable

A function to dispatch to.

acc_argssequence of strings, optional

Additional arguments to prepent to the argument list passed in when the alias is called.

xonsh.aliases.detect_xpip_alias()[source]

Determines the correct invocation to get xonsh’s pip

xonsh.aliases.make_default_aliases()[source]

Creates a new default aliases dictionary.

xonsh.aliases.partial_eval_alias(f, acc_args=())[source]

Dispatches the appropriate eval alias based on the number of args to the original callable alias and how many arguments to apply.

xonsh.aliases.showcmd(args, stdin=None)[source]

usage: showcmd [-h|–help|cmd args]

Displays the command and arguments as a list of strings that xonsh would run in subprocess mode. This is useful for determining how xonsh evaluates your commands and arguments prior to running these commands.

optional arguments:
-h, --help

show this help message and exit

example:
>>> showcmd echo $USER can't hear "the sea"
['echo', 'I', "can't", 'hear', 'the sea']
xonsh.aliases.source_alias(args, stdin=None)[source]

Executes the contents of the provided files in the current context. If sourced file isn’t found in cwd, search for file along $PATH to source instead.

xonsh.aliases.source_cmd(args, stdin=None)[source]

Simple cmd.exe-specific wrapper around source-foreign.

xonsh.aliases.source_foreign(args, stdin=None, stdout=None, stderr=None)[source]

Sources a file written in a foreign shell language.

xonsh.aliases.trace(args, stdin=None, stdout=None, stderr=None, spec=None)[source]

Runs the xonsh tracer utility.

xonsh.aliases.xexec(args, stdin=None)[source]

exec [-h|–help] command [args…]

exec (also aliased as xexec) uses the os.execvpe() function to replace the xonsh process with the specified program. This provides the functionality of the bash ‘exec’ builtin:

>>> exec bash -l -i
bash $

The ‘-h’ and ‘–help’ options print this message and exit.

Notes

This command is not the same as the Python builtin function exec(). That function is for running Python code. This command, which shares the same name as the sh-lang statement, is for launching a command directly in the same process. In the event of a name conflict, please use the xexec command directly or dive into subprocess mode explicitly with ![exec command]. For more details, please see http://xon.sh/faq.html#exec.

xonsh.aliases.xonfig(args, stdin=None)[source]

Runs the xonsh configuration utility.

xonsh.aliases.xonsh_exit(args, stdin=None)[source]

Sends signal to exit shell.

xonsh.aliases.xonsh_reset(args, stdin=None)[source]

Clears __xonsh__.ctx