summaryrefslogtreecommitdiff
path: root/docs/settingchanges.rst
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-16 18:58:19 -0400
committerGitHub <noreply@github.com>2018-03-16 18:58:19 -0400
commit70b340da1ea080e42ec91d0d37a8c266d095df94 (patch)
treeba5666ae95ea8bb2376a61cf42f13fa71cf83b27 /docs/settingchanges.rst
parent3abfbf6c994f5a7e4aa918fc9fff10da99cf6f25 (diff)
parent9465ff2abd51bafa4c8928b19ed58140721fe567 (diff)
downloadcmd2-git-70b340da1ea080e42ec91d0d37a8c266d095df94.tar.gz
Merge pull request #314 from python-cmd2/alias
Alias
Diffstat (limited to 'docs/settingchanges.rst')
-rw-r--r--docs/settingchanges.rst26
1 files changed, 21 insertions, 5 deletions
diff --git a/docs/settingchanges.rst b/docs/settingchanges.rst
index 67292a48..f5ba16d4 100644
--- a/docs/settingchanges.rst
+++ b/docs/settingchanges.rst
@@ -9,12 +9,12 @@ its name is included in the dictionary ``app.settable``.
(To define your own user-settable parameters, see :ref:`parameters`)
-Shortcuts (command aliases)
+Shortcuts
===========================
-Command aliases for long command names such as special-character shortcuts for common commands can make life more
-convenient for your users. Shortcuts are used without a space separating them from their arguments,
-like ``!ls``. By default, the following shortcuts are defined:
+Command shortcuts for long command names and common commands can make life more convenient for your users.
+Shortcuts are used without a space separating them from their arguments, like ``!ls``. By default, the
+following shortcuts are defined:
``?``
help
@@ -41,12 +41,28 @@ To define more shortcuts, update the dict ``App.shortcuts`` with the
.. warning::
- Command aliases needed to be created by updating the ``shortcuts`` dictionary attribute prior to calling the
+ Shortcuts need to be created by updating the ``shortcuts`` dictionary attribute prior to calling the
``cmd2.Cmd`` super class ``__init__()`` method. Moreover, that super class init method needs to be called after
updating the ``shortcuts`` attribute This warning applies in general to many other attributes which are not
settable at runtime such as ``commentGrammars``, ``multilineCommands``, etc.
+Aliases
+================
+
+In addition to shortcuts, ``cmd2`` provides a full alias feature via the ``alias`` command which is similar to the
+``alias`` command in Bash.
+
+The syntax to create an alias is ``alias <name> <value>``. ``value`` can contain spaces and does not need
+to be quoted. Ex: ``alias ls !ls -lF``
+
+If ``alias`` is run without arguments, then a list of all aliases will be printed to stdout and are in the proper
+``alias`` command syntax, meaning they can easily be reused.
+
+The ``unalias`` is used to clear aliases. Using the ``-a`` flag will clear all aliases. Otherwise provide a list of
+aliases to clear. Ex: ``unalias ls cd pwd`` will clear the aliases called ls, cd, and pwd.
+
+
Default to shell
================