Built-in Aliases¶
This page describes the xonsh built-in commands and aliases.
cd
¶
Changes the directory. If no directory is specified (i.e. if there are no arguments) then this changes to the current user’s home directory.
pushd
¶
Adds a directory to the top of the directory stack, or rotates the stack, making the new top of the stack the current working directory.
usage: pushd [-h] [-n] [-q] [dir]
positional arguments:
dir
optional arguments:
-h, --help show this help message and exit
-n Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is manipulated.
-q Do not call dirs, regardless of $PUSHD_SILENT
popd
¶
Removes entries from the directory stack.
usage: pushd [-h] [-n] [-q] [dir]
positional arguments:
dir
optional arguments:
-h, --help show this help message and exit
-n Suppresses the normal change of directory when adding
directories to the stack, so that only the stack is manipulated.
-q Do not call dirs, regardless of $PUSHD_SILENT
dirs
¶
Displays the list of currently remembered directories. Can also be used to clear the directory stack.
usage: dirs [-h] [-c] [-p] [-v] [-l] [N]
positional arguments:
N
optional arguments:
-h, --help show this help message and exit
-c Clears the directory stack by deleting all of the entries.
-p Print the directory stack with one entry per line.
-v Print the directory stack with one entry per line, prefixing
each entry with its index in the stack.
-l Produces a longer listing; the default listing format uses a
tilde to denote the home directory.
jobs
¶
Display a list of all current jobs.
fg
¶
Bring the currently active job to the foreground, or, if a single number is given as an argument, bring that job to the foreground.
bg
¶
Resume execution of the currently active job in the background, or, if a single number is given as an argument, resume that job in the background.
EOF
, exit
, and quit
¶
The commands EOF
, exit
, and quit
all alias the same action, which is to
leave xonsh in a safe manner. Typing Crtl-d
is the same as typing EOF
and
pressing enter.
exec
and xexec
¶
source
¶
Executes the contents of the provided files in the current context. This, of course, only works on xonsh and Python files.
source-bash
¶
Like the source
command but for Bash files. This is a thin wrapper around
the source-foreign
alias where the shell
argument is automatically set
to bash
.
source-foreign
¶
Like the source
command but for files in foreign (non-xonsh) languages.
It will pick up the environment and any aliases.
usage: source-foreign [-h] [-i INTERACTIVE] [-l LOGIN] [--envcmd ENVCMD]
[--aliascmd ALIASCMD] [--extra-args EXTRA_ARGS]
[-s SAFE] [-p PREVCMD] [--postcmd POSTCMD]
[--funcscmd FUNCSCMD] [--sourcer SOURCER]
[--use-tmpfile USE_TMPFILE]
[--seterrprevcmd SETERRPREVCMD]
[--seterrpostcmd SETERRPOSTCMD] [--overwrite-aliases]
[--suppress-skip-message] [--show] [-d]
shell files_or_code [files_or_code ...]
Sources a file written in a foreign shell language.
positional arguments:
shell Name or path to the foreign shell
files_or_code file paths to source or code in the target language.
optional arguments:
-h, --help show this help message and exit
-i INTERACTIVE, --interactive INTERACTIVE
whether the sourced shell should be interactive
-l LOGIN, --login LOGIN
whether the sourced shell should be login
--envcmd ENVCMD command to print environment
--aliascmd ALIASCMD command to print aliases
--extra-args EXTRA_ARGS
extra arguments needed to run the shell
-s SAFE, --safe SAFE whether the source shell should be run safely, and not
raise any errors, even if they occur.
-p PREVCMD, --prevcmd PREVCMD
command(s) to run before any other commands, replaces
traditional source.
--postcmd POSTCMD command(s) to run after all other commands
--funcscmd FUNCSCMD code to find locations of all native functions in the
shell language.
--sourcer SOURCER the source command in the target shell language,
default: source.
--use-tmpfile USE_TMPFILE
whether the commands for source shell should be
written to a temporary file.
--seterrprevcmd SETERRPREVCMD
command(s) to set exit-on-error before anyother
commands.
--seterrpostcmd SETERRPOSTCMD
command(s) to set exit-on-error after allother
commands.
--overwrite-aliases flag for whether or not sourced aliases should replace
the current xonsh aliases.
--suppress-skip-message
flag for whether or not skip messages should be
suppressed.
--show Will show the script output.
-d, --dry-run Will not actually source the file.
history
¶
Tools for dealing with xonsh history. See the history tutorial for more information all the history command and all of its sub-commands.
usage: history [-h] {show,id,file,info,gc} ...
try 'history <command> --help' for more info
optional arguments:
-h, --help show this help message and exit
commands:
{show,id,file,info,gc}
show display history of a session, default command
id display the current session id
file display the current history filename
info display information about the current history
gc launches a new history garbage collector
replay
¶
Replays a xonsh history file. See the replay section of the history tutorial for more information about this command.
usage: replay [-h] [--merge-envs MERGE_ENVS [MERGE_ENVS ...]] [--json]
[-o TARGET]
path
replays a xonsh history file
positional arguments:
path path to replay history file
optional arguments:
-h, --help show this help message and exit
--merge-envs MERGE_ENVS [MERGE_ENVS ...]
Describes how to merge the environments, in order of
increasing precedence. Available strings are 'replay'
and 'native'. The 'replay' env comes from the history
file that we are replaying. The 'native' env comes
from what this instance of xonsh was started up with.
One or more of these options may be passed in.
Defaults to '--merge-envs replay native'.
--json print history info in JSON format
-o TARGET, --target TARGET
path to new history file
timeit
¶
Runs timing study on arguments. Similar to IPython’s %timeit
magic.
scp-resume
¶
Simple alias defined as ['rsync', '--partial', '-h', '--progress', '--rsh=ssh']
.
showcmd
¶
Displays how commands and arguments are evaluated.
ipynb
¶
Simple alias defined as ['ipython', 'notebook', '--no-browser']
.
trace
¶
Provides an interface to printing lines of source code prior to their execution.
usage: trace [-h] {on,start,add,off,stop,del,rm,color} ...
tool for tracing xonsh code as it runs.
optional arguments:
-h, --help show this help message and exit
action:
{on,start,add,off,stop,del,rm,color}
on (start, add) begins tracing selected files.
off (stop, del, rm)
removes selected files fom tracing.
color output color management for tracer.
xpip
¶
Runs the pip
package manager for xonsh itself. Useful for installations where xonsh is in an
isolated environment (eg conda, homebrew).
In general, use xpip
if you’re configuring or adding features to xonsh, and use pip
if
you’re doing Python development.
xonfig
¶
Manages xonsh configuration information.
usage: xonfig [-h] {info,wizard,styles,colors,tutorial} ...
Manages xonsh configuration.
optional arguments:
-h, --help show this help message and exit
action:
{info,wizard,styles,colors,tutorial}
info displays configuration information, default action
wizard displays configuration information
styles prints available xonsh color styles
colors preview color style
tutorial Launch tutorial in browser.
Windows cmd Aliases¶
The following aliases on Windows are expanded to ['cmd', '/c', alias]
:
{'cls': ['cmd', '/c', 'cls'],
'copy': ['cmd', '/c', 'copy'],
'del': ['cmd', '/c', 'del'],
'dir': ['cmd', '/c', 'dir'],
'erase': ['cmd', '/c', 'erase'],
'md': ['cmd', '/c', 'md'],
'mkdir': ['cmd', '/c', 'mkdir'],
'mklink': ['cmd', '/c', 'mklink'],
'move': ['cmd', '/c', 'move'],
'rd': ['cmd', '/c', 'rd'],
'ren': ['cmd', '/c', 'ren'],
'rename': ['cmd', '/c', 'rename'],
'rmdir': ['cmd', '/c', 'rmdir'],
'time': ['cmd', '/c', 'time'],
'type': ['cmd', '/c', 'type'],
'vol': ['cmd', '/c', 'vol'],
}
activate
/deactivate
on Windows with Anaconda¶
On Windows with an Anaconda Python distribution, activate
and
deactivate
are aliased to ['source-bat activate']
and ['source-bat deactivate']
.
This makes it possible to use the same commands to activate/deactivate conda environments as
in cmd.exe.
sudo
on Windows¶
On Windows, if no executables named sudo
are found, Xonsh adds a sudo
alias
that poly fills the “run as Admin” behavior with the help of ShellExecuteEx
and
ctypes
. It doesn’t support any actual sudo
parameters and just takes the
command to run.
ls
¶
The ls
command is aliased to ['ls', '--color=auto', '-v']
normally. On Mac OSX
it is instead aliased to ['ls', '-G']
.
grep
¶
The grep
command is aliased to ['grep', '--color=auto']
.
xontrib
¶
Manages xonsh extensions.