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
() → None. Remove all items from D.¶
-
eval_alias
(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
(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
(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
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
pop
(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised.
-
popitem
() → (k, v), remove and return some (key, value) pair¶ as a 2-tuple; but raise KeyError if D is empty.
-
setdefault
(k[, d]) → D.get(k,d), also set D[k]=d if k not in D¶
-
values
() → an object providing a view on D's values¶
-
-
xonsh.aliases.
bang_bang
(args, stdin=None)[source]¶ Re-runs the last command. Just a wrapper around bang_n.
-
xonsh.aliases.
bang_n
(args, stdin=None)[source]¶ Re-runs the nth command as specified in the argument.
-
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)[source]¶ Sources a file written in a foreign shell language.
-
xonsh.aliases.
which
(args, stdin=None, stdout=None, stderr=None)[source]¶ Checks if each arguments is a xonsh aliases, then if it’s an executable, then finally return an error code equal to the number of misses. If ‘-a’ flag is passed, run both to return both xonsh match and which match.