mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
added showcmd alias
This commit is contained in:
parent
6f443cb266
commit
503b277992
4 changed files with 30 additions and 2 deletions
|
@ -11,7 +11,9 @@ Current Developments
|
|||
* Added comma literals to subproc mode.
|
||||
* ``@$(cmd)`` has been added as a subprocess-mode operator, which replaces in
|
||||
the subprocess command itself with the result of running ``cmd``.
|
||||
* The ``${...}`` shortcut for ``__xonsh_env__`` now returns appropriate
|
||||
* New ``showcmd`` alias for displaying how xonsh interprets subprocess mode
|
||||
commands and arguments.
|
||||
* The ``${...}`` shortcut for ``__xonsh_env__`` now returns appropriate
|
||||
completion options
|
||||
|
||||
**Changed:**
|
||||
|
|
|
@ -128,6 +128,10 @@ Runs timing study on arguments. Similar to IPython's ``%timeit`` magic.
|
|||
=================
|
||||
Simple alias defined as ``['rsync', '--partial', '-h', '--progress', '--rsh=ssh']``.
|
||||
|
||||
``showcmd``
|
||||
============
|
||||
Displays how comands and arguments are evaluated.
|
||||
|
||||
|
||||
``ipynb``
|
||||
=================
|
||||
|
|
|
@ -5,6 +5,7 @@ from argparse import ArgumentParser, Action
|
|||
import builtins
|
||||
from collections.abc import MutableMapping, Iterable, Sequence
|
||||
import os
|
||||
import sys
|
||||
import shlex
|
||||
|
||||
from xonsh.dirstack import cd, pushd, popd, dirs, _get_cwd
|
||||
|
@ -458,6 +459,26 @@ def vox(args, stdin=None):
|
|||
return vox(args, stdin=stdin)
|
||||
|
||||
|
||||
def showcmd(args, stdin=None):
|
||||
"""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']
|
||||
"""
|
||||
if len(args) == 0 or (len(args) == 1 and args[0] in {'-h', '--help'}):
|
||||
print(showcmd.__doc__.rstrip().replace('\n ', '\n'))
|
||||
else:
|
||||
sys.displayhook(args)
|
||||
|
||||
|
||||
def make_default_aliases():
|
||||
"""Creates a new default aliases dictionary."""
|
||||
default_aliases = {
|
||||
|
@ -485,6 +506,7 @@ def make_default_aliases():
|
|||
'timeit': timeit_alias,
|
||||
'xonfig': xonfig,
|
||||
'scp-resume': ['rsync', '--partial', '-h', '--progress', '--rsh=ssh'],
|
||||
'showcmd': showcmd,
|
||||
'ipynb': ['jupyter', 'notebook', '--no-browser'],
|
||||
'vox': vox,
|
||||
'which': which,
|
||||
|
|
|
@ -71,7 +71,7 @@ CHARACTERS_NEED_QUOTES = ' `\t\r\n${}*()"\',?&'
|
|||
if ON_WINDOWS:
|
||||
CHARACTERS_NEED_QUOTES += '%'
|
||||
|
||||
COMPLETION_SKIP_TOKENS = {'man', 'sudo', 'time', 'timeit', 'which'}
|
||||
COMPLETION_SKIP_TOKENS = {'man', 'sudo', 'time', 'timeit', 'which', 'showcmd'}
|
||||
|
||||
BASH_COMPLETE_SCRIPT = """source "{filename}"
|
||||
COMP_WORDS=({line})
|
||||
|
|
Loading…
Add table
Reference in a new issue