2019-03-31 17:05:09 +08:00
.. _cmd-status:
2018-12-17 09:39:33 +08:00
status - query fish runtime information
2019-01-03 12:10:47 +08:00
=======================================
2018-12-17 09:39:33 +08:00
2018-12-18 09:58:24 +08:00
Synopsis
--------
2018-12-17 05:08:41 +08:00
docs synopsis: add HTML highlighing and automate manpage markup
Recent synopsis changes move from literal code blocks to
[RST line blocks]. This does not translate well to HTML: it's not
rendered in monospace, so aligment is lost. Additionally, we don't
get syntax highlighting in HTML, which adds differences to our code
samples which are highlighted.
We hard-wrap synopsis lines (like code blocks). To align continuation
lines in manpages we need [backslashes in weird places]. Combined with
the **, *, and `` markup, it's a bit hard to get the alignment right.
Fix these by moving synopsis sources back to code blocks and compute
HTML syntax highlighting and manpage markup with a custom Sphinx
extension.
The new Pygments lexer can tokenize a synopsis and assign the various
highlighting roles, which closely matches fish's syntax highlighing:
- command/keyword (dark blue)
- parameter (light blue)
- operator like and/or/not/&&/|| (cyan)
- grammar metacharacter (black)
For manpage output, we don't project the fish syntax highlighting
but follow the markup convention in GNU's man(1):
bold text type exactly as shown.
italic text replace with appropriate argument.
To make it easy to separate these two automatically, formalize that
(italic) placeholders must be uppercase; while all lowercase text is
interpreted literally (so rendered bold).
This makes manpages more consistent, see string-join(1) and and(1).
Implementation notes:
Since we want manpage formatting but Sphinx's Pygments highlighing
plugin does not support manpage output, add our custom "synopsis"
directive. This directive parses differently when manpage output is
specified. This means that the HTML and manpage build processes must
not share a cache, because the parsed doctrees are cached. Work around
this by using separate cache locations for build targets "sphinx-docs"
(which creates HTML) and "sphinx-manpages". A better solution would
be to only override Sphinx's ManualPageBuilder but that would take a
bit more code (ideally we could override ManualPageWriter but Sphinx
4.3.2 doesn't really support that).
---
Alternative solution: stick with line blocks but use roles like
:command: or :option: (or custom ones). While this would make it
possible to produce HTML that is consistent with code blocks (by adding
a bit of CSS), the source would look uglier and is harder to maintain.
(Let's say we want to add custom formatting to the [|] metacharacters
in HTML. This is much easier with the proposed patch.)
---
[RST line blocks]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks
[backslashes in weird places]: https://github.com/fish-shell/fish-shell/pull/8626#discussion_r782837750
2022-01-09 22:09:46 +08:00
.. synopsis ::
status
status is-login
status is-interactive
status is-block
status is-breakpoint
status is-command-substitution
status is-no-job-control
status is-full-job-control
status is-interactive-job-control
status current-command
2022-10-23 03:49:11 +08:00
status current-commandline
docs synopsis: add HTML highlighing and automate manpage markup
Recent synopsis changes move from literal code blocks to
[RST line blocks]. This does not translate well to HTML: it's not
rendered in monospace, so aligment is lost. Additionally, we don't
get syntax highlighting in HTML, which adds differences to our code
samples which are highlighted.
We hard-wrap synopsis lines (like code blocks). To align continuation
lines in manpages we need [backslashes in weird places]. Combined with
the **, *, and `` markup, it's a bit hard to get the alignment right.
Fix these by moving synopsis sources back to code blocks and compute
HTML syntax highlighting and manpage markup with a custom Sphinx
extension.
The new Pygments lexer can tokenize a synopsis and assign the various
highlighting roles, which closely matches fish's syntax highlighing:
- command/keyword (dark blue)
- parameter (light blue)
- operator like and/or/not/&&/|| (cyan)
- grammar metacharacter (black)
For manpage output, we don't project the fish syntax highlighting
but follow the markup convention in GNU's man(1):
bold text type exactly as shown.
italic text replace with appropriate argument.
To make it easy to separate these two automatically, formalize that
(italic) placeholders must be uppercase; while all lowercase text is
interpreted literally (so rendered bold).
This makes manpages more consistent, see string-join(1) and and(1).
Implementation notes:
Since we want manpage formatting but Sphinx's Pygments highlighing
plugin does not support manpage output, add our custom "synopsis"
directive. This directive parses differently when manpage output is
specified. This means that the HTML and manpage build processes must
not share a cache, because the parsed doctrees are cached. Work around
this by using separate cache locations for build targets "sphinx-docs"
(which creates HTML) and "sphinx-manpages". A better solution would
be to only override Sphinx's ManualPageBuilder but that would take a
bit more code (ideally we could override ManualPageWriter but Sphinx
4.3.2 doesn't really support that).
---
Alternative solution: stick with line blocks but use roles like
:command: or :option: (or custom ones). While this would make it
possible to produce HTML that is consistent with code blocks (by adding
a bit of CSS), the source would look uglier and is harder to maintain.
(Let's say we want to add custom formatting to the [|] metacharacters
in HTML. This is much easier with the proposed patch.)
---
[RST line blocks]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#line-blocks
[backslashes in weird places]: https://github.com/fish-shell/fish-shell/pull/8626#discussion_r782837750
2022-01-09 22:09:46 +08:00
status filename
status basename
status dirname
status fish-path
status function
status line-number
status stack-trace
status job-control CONTROL_TYPE
status features
status test-feature FEATURE
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Description
2019-01-03 12:10:47 +08:00
-----------
2018-12-17 05:08:41 +08:00
2018-12-20 04:02:45 +08:00
With no arguments, `` status `` displays a summary of the current login and job control status of the shell.
2018-12-17 05:08:41 +08:00
2022-03-12 00:18:41 +08:00
The following operations (subcommands) are available:
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-command-substitution** , **-c** or **--is-command-substitution**
Returns 0 if fish is currently executing a command substitution.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-block** , **-b** or **--is-block**
Returns 0 if fish is currently executing a block of code.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-breakpoint**
2022-09-24 01:57:49 +08:00
Returns 0 if fish is currently showing a prompt in the context of a :doc: `breakpoint <breakpoint>` command. See also the :doc: `fish_breakpoint_prompt <fish_breakpoint_prompt>` function.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-interactive** , **-i** or **--is-interactive**
Returns 0 if fish is interactive - that is, connected to a keyboard.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-login** , **-l** or **--is-login**
Returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up :envvar: `PATH` .
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-full-job-control** or **--is-full-job-control**
Returns 0 if full job control is enabled.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-interactive-job-control** or **--is-interactive-job-control**
Returns 0 if interactive job control is enabled.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**is-no-job-control** or **--is-no-job-control**
Returns 0 if no job control is enabled.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**current-command**
Prints the name of the currently-running function or command, like the deprecated :envvar: `_` variable.
2019-02-25 07:01:16 +08:00
2022-10-23 03:49:11 +08:00
**current-commandline**
Prints the entirety of the currently-running commandline, inclusive of all jobs and operators.
2022-03-11 23:56:20 +08:00
**filename** , **current-filename** , **-f** or **--current-filename**
2022-09-24 01:57:49 +08:00
Prints the filename of the currently-running script. If the current script was called via a symlink, this will return the symlink. If the current script was received by piping into :doc: `source <source>` , then this will return `` - `` .
2020-06-01 22:46:20 +08:00
2022-03-11 23:56:20 +08:00
**basename**
Prints just the filename of the running script, without any path components before.
2020-06-01 22:46:20 +08:00
2022-03-11 23:56:20 +08:00
**dirname**
Prints just the path to the running script, without the actual filename itself. This can be relative to :envvar: `PWD` (including just "."), depending on how the script was called. This is the same as passing the filename to `` dirname(3) `` . It's useful if you want to use other files in the current script's directory or similar.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**fish-path**
2022-06-16 22:39:09 +08:00
Prints the absolute path to the currently executing instance of fish. This is a best-effort attempt and the exact output is down to what the platform gives fish. In some cases you might only get "fish".
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**function** or **current-function**
Prints the name of the currently called function if able, when missing displays "Not a function" (or equivalent translated string).
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**line-number** , **current-line-number** , **-n** or **--current-line-number**
Prints the line number of the currently running script.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**stack-trace** , **print-stack-trace** , **-t** or **--print-stack-trace**
Prints a stack trace of all function calls on the call stack.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**job-control** , **-j** or **--job-control** *CONTROL_TYPE*
Sets the job control type to *CONTROL_TYPE* , which can be **none** , **full** , or **interactive** .
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**features**
Lists all available feature flags.
2018-12-17 05:08:41 +08:00
2022-03-11 23:56:20 +08:00
**test-feature** *FEATURE*
Returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized.
2018-12-17 05:08:41 +08:00
2018-12-19 10:44:30 +08:00
Notes
2019-01-03 12:10:47 +08:00
-----
2018-12-17 05:08:41 +08:00
2021-04-15 03:46:24 +08:00
For backwards compatibility most subcommands can also be specified as a long or short option. For example, rather than `` status is-login `` you can type `` status --is-login `` . The flag forms are deprecated and may be removed in a future release (but not before fish 4.0).
2018-12-17 05:08:41 +08:00
You can only specify one subcommand per invocation even if you use the flag form of the subcommand.