cd, cdh, command, commandline

Documentation.
This commit is contained in:
Aaron Gyes 2021-12-09 04:45:10 -08:00
parent 3b629d29aa
commit 124734cbaa
4 changed files with 76 additions and 49 deletions

View file

@ -6,21 +6,23 @@ cd - change directory
Synopsis
--------
::
cd [DIRECTORY]
``cd`` [*DIRECTORY*]
Description
-----------
``cd`` changes the current working directory.
If ``DIRECTORY`` is given, it will become the new directory. If no parameter is given, the ``$HOME`` environment variable will be used.
If *DIRECTORY* is given, it will become the new directory. If no parameter is given, the :envvar:`HOME` environment variable will be used.
If ``DIRECTORY`` is a relative path, all the paths in the ``$CDPATH`` will be tried as prefixes for it, in addition to ``$PWD``. It is recommended to keep ``.`` as the first element of ``$CDPATH``, or ``$PWD`` will be tried last.
If *DIRECTORY* is a relative path, all the paths in the :envvar:`CDPATH` will be tried as prefixes for it, in addition to :envvar:`PWD`.
It is recommended to keep **.** as the first element of :envvar:`CDPATH`, or :envvar:`PWD` will be tried last.
Fish will also try to change directory if given a command that looks like a directory (starting with ``.``, ``/`` or ``~``, or ending with ``/``), without explicitly requiring ``cd``.
Fish will also try to change directory if given a command that looks like a directory (starting with **.**, **/** or **~**, or ending with **/**), without explicitly requiring ``cd``.
Fish also ships a wrapper function around the builtin ``cd`` that understands ``cd -`` as changing to the previous directory. See also :ref:`prevd <cmd-prevd>`. This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables. If you make those universal variables your ``cd`` history is shared among all fish instances.
Fish also ships a wrapper function around the builtin ``cd`` that understands ``cd -`` as changing to the previous directory.
See also :ref:`prevd <cmd-prevd>`.
This wrapper function maintains a history of the 25 most recently visited directories in the ``$dirprev`` and ``$dirnext`` global variables.
If you make those universal variables your ``cd`` history is shared among all fish instances.
As a special case, ``cd .`` is equivalent to ``cd $PWD``, which is useful in cases where a mountpoint has been recycled or a directory has been removed and recreated.

View file

@ -1,4 +1,4 @@
.. _cmd-cdh:
.. _cmd-cdh:
cdh - change to a recently visited directory
============================================
@ -6,16 +6,19 @@ cdh - change to a recently visited directory
Synopsis
--------
::
cdh [ directory ]
``cdh`` [ *DIR* ]
Description
-----------
``cdh`` with no arguments presents a list of :ref:`recently visited directories <directory-history>`. You can then select one of the entries by letter or number. You can also press :kbd:`Tab` to use the completion pager to select an item from the list. If you give it a single argument it is equivalent to ``cd directory``.
``cdh`` with no arguments presents a list of :ref:`recently visited directories <directory-history>`.
You can then select one of the entries by letter or number.
You can also press :kbd:`Tab` to use the completion pager to select an item from the list.
If you give it a single argument it is equivalent to ``cd DIR``.
Note that the ``cd`` command limits directory history to the 25 most recently visited directories. The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates. If you make those universal variables your ``cd`` history is shared among all fish instances.
Note that the ``cd`` command limits directory history to the 25 most recently visited directories.
The history is stored in the ``$dirprev`` and ``$dirnext`` variables which this command manipulates.
If you make those universal variables your ``cd`` history is shared among all fish instances.
See Also
--------

View file

@ -6,9 +6,7 @@ command - run a program
Synopsis
--------
::
command [OPTIONS] COMMANDNAME [ARGS...]
``command`` [ *OPTIONS* ] [**COMMAND** [*ARG* ...]]
Description
-----------
@ -17,21 +15,22 @@ Description
The following options are available:
- ``-a`` or ``--all`` returns all the external COMMANDNAMEs that are found in ``$PATH`` in the order they are found.
**-a** or **--all**
Prints all *COMMAND* found in :envvar:`PATH`, in the order found.
- ``-q`` or ``--query``, silences the output and prints nothing, setting only the exit status. Implies ``--search``. For compatibility with old fish versions this is also ``--quiet`` (but this is deprecated).
**-q** or **--query**
Silence output and print nothing, setting only exit status.
Implies **--search**.
For compatibility, this is also **--quiet** (deprecated).
- ``-s`` or ``--search`` returns the name of the external command that would be executed, or nothing if no file with the specified name could be found in the ``$PATH``.
**-v** (or **-s** or **--search**)
Prints the external command that would be executed, or prints nothing if no file with the specified name could be found in :envvar:`PATH`.
With the ``-s`` option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing a ``-q`` or ``--quiet`` option prevents any paths from being printed, like ``type -q``, for testing only the exit status.
For basic compatibility with POSIX ``command``, the ``-v`` flag is recognized as an alias for ``-s``.
With the **-v** option, ``command`` treats every argument as a separate command to look up and sets the exit status to 0 if any of the specified commands were found, or 1 if no commands could be found. Additionally passing **--quiet** option prevents any paths from being printed, like ``type -q``.
Examples
--------
``command ls`` causes fish to execute the ``ls`` program, even if an ``ls`` function exists.
``command -s ls`` returns the path to the ``ls`` program.
``command -q git; and command git log`` runs ``git log`` only if ``git`` exists.
| ``command ls`` causes fish to execute the ``ls`` program, even if an ``ls`` function exists.
| ``command -s ls`` returns the path to the ``ls`` program.
| ``command -q git; and command git log`` runs ``git log`` only if ``git`` exists.

View file

@ -6,9 +6,7 @@ commandline - set or get the current command line buffer
Synopsis
--------
::
commandline [OPTIONS] [CMD]
``commandline`` [**OPTIONS**] [**CMD**]
Description
-----------
@ -17,53 +15,78 @@ Description
With no parameters, ``commandline`` returns the current value of the command line.
With ``CMD`` specified, the command line buffer is erased and replaced with the contents of ``CMD``.
With **CMD** specified, the command line buffer is erased and replaced with the contents of **CMD**.
The following options are available:
- ``-C`` or ``--cursor`` set or get the current cursor position, not the contents of the buffer. If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position. If one of the options ``-j``, ``-p`` or ``-t`` is given, the position is relative to the respective substring instead of the entire command line buffer.
**-C** or **--cursor**
Set or get the current cursor position, not the contents of the buffer.
If no argument is given, the current cursor position is printed, otherwise the argument is interpreted as the new cursor position.
If one of the options **-j**, **-p** or **-t** is given, the position is relative to the respective substring instead of the entire command line buffer.
- ``-f`` or ``--function`` causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are. This option cannot be combined with any other option. See :ref:`bind <cmd-bind>` for a list of input functions.
**-f** or **--function**
Causes any additional arguments to be interpreted as input functions, and puts them into the queue, so that they will be read before any additional actual key presses are.
This option cannot be combined with any other option.
See :ref:`bind <cmd-bind>` for a list of input functions.
The following options change the way ``commandline`` updates the command line buffer:
- ``-a`` or ``--append`` do not remove the current commandline, append the specified string at the end of it
**-a** or **--append**
Do not remove the current commandline, append the specified string at the end of it.
- ``-i`` or ``--insert`` do not remove the current commandline, insert the specified string at the current cursor position
**-i** or **--insert**
Do not remove the current commandline, insert the specified string at the current cursor position
- ``-r`` or ``--replace`` remove the current commandline and replace it with the specified string (default)
**-r** or **--replace**
Remove the current commandline and replace it with the specified string (default)
The following options change what part of the commandline is printed or updated:
- ``-b`` or ``--current-buffer`` select the entire commandline, not including any displayed autosuggestion (default)
**-b** or **--current-buffer**
Select the entire commandline, not including any displayed autosuggestion (default).
- ``-j`` or ``--current-job`` select the current job - a `job` here is one pipeline. It stops at logical operators or terminators (``;``, ``&`` or newlines).
**-j** or **--current-job**
Select the current job - a **job** here is one pipeline.
Stops at logical operators or terminators (**;**, **&**, and newlines).
- ``-p`` or ``--current-process`` select the current process - a `process` here is one simple command. It stops at logical operators, terminators or pipes.
**-p** or **--current-process**
Select the current process - a **process** here is one command.
Stops at logical operators, terminators, and pipes.
- ``-s`` or ``--current-selection`` selects the current selection
**-s** or **--current-selection**
Selects the current selection
- ``-t`` or ``--current-token`` select the current token
**-t** or **--current-token**
Selects the current token
The following options change the way ``commandline`` prints the current commandline buffer:
- ``-c`` or ``--cut-at-cursor`` only print selection up until the current cursor position
**-c** or **--cut-at-cursor**
Only print selection up until the current cursor position.
- ``-o`` or ``--tokenize`` tokenize the selection and print one string-type token per line
**-o** or **--tokenize**
Tokenize the selection and print one string-type token per line.
If ``commandline`` is called during a call to complete a given string using ``complete -C STRING``, ``commandline`` will consider the specified string to be the current contents of the command line.
The following options output metadata about the commandline state:
- ``-L`` or ``--line`` print the line that the cursor is on, with the topmost line starting at 1
**-L** or **--line**
Print the line that the cursor is on, with the topmost line starting at 1.
- ``-S`` or ``--search-mode`` evaluates to true if the commandline is performing a history search
**-S** or **--search-mode**
Evaluates to true if the commandline is performing a history search.
- ``-P`` or ``--paging-mode`` evaluates to true if the commandline is showing pager contents, such as tab completions
**-P** or **--paging-mode**
Evaluates to true if the commandline is showing pager contents, such as tab completions.
- ``--paging-full-mode`` evaluates to true if the commandline is showing pager contents, such as tab completions and all lines are shown (no "<n> more rows" message)
**--paging-full-mode**
Evaluates to true if the commandline is showing pager contents, such as tab completions and all lines are shown (no "<n> more rows" message).
- ``--is-valid`` returns true when the commandline is syntactically valid and complete. If it is, it would be executed when the ``execute`` bind function is called. If the commandline is incomplete, it returns 2, if it is erroneus, it returns 1.
**--is-valid**
Returns true when the commandline is syntactically valid and complete.
If it is, it would be executed when the ``execute`` bind function is called.
If the commandline is incomplete, return 2, if erroneus, return 1.
Example
-------
@ -84,7 +107,7 @@ The ``echo $flounder >&`` is the first process, ``less`` the second and ``and ec
``echo $flounder >&2 | less`` is the first job, ``and echo $catfish`` the second.
``$flounder`` is the current token.
**$flounder** is the current token.
More examples: