xonsh.readline_shell

The readline based xonsh shell.

Portions of this code related to initializing the readline library are included from the IPython project. The IPython project is:

class xonsh.readline_shell.ReadlineHistoryAdder(wait_for_gc=True, *args, **kwargs)[source]

Thread responsible for adding inputs from history to the current readline instance. May wait for the history garbage collector to finish.

getName()

Return a string used for identification purposes only.

This method is deprecated, use the name attribute instead.

isDaemon()

Return whether this thread is a daemon.

This method is deprecated, use the daemon attribute instead.

is_alive()

Return whether the thread is alive.

This method returns True just before the run() method starts until just after the run() method terminates. See also the module function enumerate().

join(timeout=None)

Wait until the thread terminates.

This blocks the calling thread until the thread whose join() method is called terminates – either normally or through an unhandled exception or until the optional timeout occurs.

When the timeout argument is present and not None, it should be a floating point number specifying a timeout for the operation in seconds (or fractions thereof). As join() always returns None, you must call is_alive() after join() to decide whether a timeout happened – if the thread is still alive, the join() call timed out.

When the timeout argument is not present or None, the operation will block until the thread terminates.

A thread can be join()ed many times.

join() raises a RuntimeError if an attempt is made to join the current thread as that would cause a deadlock. It is also an error to join() a thread before it has been started and attempts to do so raises the same exception.

run()[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

setDaemon(daemonic)

Set whether this thread is a daemon.

This method is deprecated, use the .daemon property instead.

setName(name)

Set the name string for this thread.

This method is deprecated, use the name attribute instead.

start()

Start the thread’s activity.

It must be called at most once per thread object. It arranges for the object’s run() method to be invoked in a separate thread of control.

This method will raise a RuntimeError if called more than once on the same thread object.

property daemon

A boolean value indicating whether this thread is a daemon thread.

This must be set before start() is called, otherwise RuntimeError is raised. Its initial value is inherited from the creating thread; the main thread is not a daemon thread and therefore all threads created in the main thread default to daemon = False.

The entire Python program exits when only daemon threads are left.

property ident

Thread identifier of this thread or None if it has not been started.

This is a nonzero integer. See the get_ident() function. Thread identifiers may be recycled when a thread exits and another thread is created. The identifier is available even after the thread has exited.

property name

A string used for identification purposes only.

It has no semantics. Multiple threads may be given the same name. The initial name is set by the constructor.

property native_id

Native integral thread ID of this thread, or None if it has not been started.

This is a non-negative integer. See the get_native_id() function. This represents the Thread ID as reported by the kernel.

class xonsh.readline_shell.ReadlineShell(completekey='tab', stdin=None, stdout=None, **kwargs)[source]

The readline based xonsh shell.

Notes

classes inheriting multiple base classes should call them explicitly as done for ReadlineShell

cmdloop(intro=None)[source]

Repeatedly issue a prompt, accept input, parse an initial prefix off the received input, and dispatch to action methods, passing them the remainder of the line as argument.

color_style()[source]

Returns the current color map.

color_style_names()[source]

Returns an iterable of all available style names.

columnize(list, displaywidth=80)

Display a list of strings as a compact set of columns.

Each column is only as wide as necessary. Columns are separated by two spaces (one was not legible enough).

compile(src)

Compiles source code and returns the (possibly modified) source and a valid code object.

complete(text, state)

Return the next possible completion for ‘text’.

If a command has not been entered, then complete against command list. Otherwise try to call complete_<command> to get list of completions.

complete_help(*args)
completedefault(prefix, line, begidx, endidx)[source]

Implements tab-completion for text.

completenames(prefix, line, begidx, endidx)

Implements tab-completion for text.

default(line, raw_line=None)

Implements code execution.

do_help(arg)

List available commands with “help” or detailed help with “help cmd”.

emptyline()

Called when an empty line has been entered.

format_color(string, hide=False, force_string=False, **kwargs)[source]

Readline implementation of color formatting. This uses ANSI color codes.

get_names()
onecmd(line)

Interpret the argument as though it had been typed in response to the prompt.

This may be overridden, but should not normally need to be; see the precmd() and postcmd() methods for useful execution hooks. The return value is a flag indicating whether interpretation of commands by the interpreter should stop.

parseline(line)[source]

Overridden to no-op.

postcmd(stop, line)[source]

Called just before execution of line. For readline, this handles the automatic indentation of code blocks.

postloop()

Hook method executed once when the cmdloop() method is about to return.

precmd(line)

Called just before execution of line.

preloop()

Hook method executed once when the cmdloop() method is called.

print_color(string, hide=False, **kwargs)[source]

Prints a string in color. This base implementation’s colors are based on ANSI color codes if a string was given as input. If a list of token pairs is given, it will color based on pygments, if available. If pygments is not available, it will print a colorless string.

print_topics(header, cmds, cmdlen, maxcol)
push(line)

Pushes a line onto the buffer and compiles the code in a way that enables multiline input.

reset_buffer()

Resets the line buffer.

restore_tty_sanity()[source]

An interface for resetting the TTY stdin mode. This is highly dependent on the shell backend. Also it is mostly optional since it only affects ^Z backgrounding behaviour.

settitle()

Sets terminal title.

singleline(store_in_history=True, **kwargs)[source]

Reads a single line of input. The store_in_history kwarg flags whether the input should be stored in readline’s in-memory history.

doc_header = 'Documented commands (type help <topic>):'
doc_leader = ''
identchars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
intro = None
lastcmd = ''
misc_header = 'Miscellaneous help topics:'
nohelp = '*** No help on %s'
property prompt

Obtains the current prompt string.

ruler = '='
property styler
undoc_header = 'Undocumented commands:'
use_rawinput = 1
xonsh.readline_shell.fix_readline_state_after_ctrl_c()[source]

Fix to allow Ctrl-C to exit reverse-i-search.

Based on code from:

http://bugs.python.org/file39467/raw_input__workaround_demo.py

xonsh.readline_shell.rl_completion_query_items(val=None)[source]

Sets the rl_completion_query_items variable, if possible. A None value will set this to $COMPLETION_QUERY_LIMIT, otherwise any integer is accepted.

xonsh.readline_shell.rl_completion_suppress_append(val=1)[source]

Sets the rl_completion_suppress_append variable, if possible. A value of 1 (default) means to suppress, a value of 0 means to enable.

xonsh.readline_shell.rl_on_new_line()[source]
xonsh.readline_shell.rl_variable_dumper(readable=True)[source]

Dumps the currently set readline variables. If readable is True, then this output may be used in an inputrc file.

xonsh.readline_shell.rl_variable_value(variable)[source]

Returns the currently set value for a readline configuration variable.

xonsh.readline_shell.setup_readline()[source]

Sets up the readline module and completion suppression, if available.

xonsh.readline_shell.teardown_readline()[source]

Tears down up the readline module, if available.