Files
fish-shell/doc_src/cmds/status.rst

156 lines
6.6 KiB
ReStructuredText
Raw Normal View History

status - query fish runtime information
=======================================
Synopsis
--------
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 15:09:46 +01:00
.. synopsis::
status
status is-login
status is-interactive
Fix regression causing cursor shape commands to leak into noninteractive shell As reported in https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$CLuoHTdvcRj_8-HBBq0p-lmGWeix5khEtKEDxN2Ulfo Running fish -C ' fzf_key_bindings echo fish_vi_key_bindings >>~/.config/fish/config.fish fzf-history-widget ' and pressing "enter" will add escape sequences like "[2 q" (cursor shape) to fish's command line. This is because fzf-history-widget binds "enter" to a filter that happens to be a fish script: set -lx FZF_DEFAULT_OPTS \ ... \ "--bind='enter:become:string replace -a -- \n\t \n {2..} | string collect'" \ '--with-shell='(status fish-path)\\ -c) The above ~/.config/fish/config.fish (redundantly) runs "fish_vi_key_bindings" even in *noninteractive* shells, then "fish_vi_cursor" will print cursor sequences in its "fish_exit" handler. The sequence is not printed to the terminal but to fzf which doesn't parse CSI commands. This is a regression introduced by a5dfa84f73 (fish_vi_cursor: skip if stdin is not a tty, 2023-11-14). That commit wanted "fish -c read" to be able to use Vi cursor. This is a noninteractive shell, but inside "read" we are "effectively interactive". However "status is-interactive" does not tell us that. Let's use a more contained fix to make sure that we print escape sequences only if either fish is interactive, or if we are evaluating an interactive read. In general, "fish -c read" is prone to configuration errors, since we recommend gating configuration (for bind etc) on "status is-interactive" which will not run here.
2025-03-02 07:39:58 +01:00
status is-interactive-read
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 15:09:46 +01:00
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
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 15:09:46 +01: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
status build-info
status get-file FILE
status list-files [PATH]
help: get section titles from Sphinx functions/help and completions/help duplicate a lot of information from doc_src. Get this information from Sphinx. Drop short section titles such as "help globbing" in favor of the full HTML anchor: help language#wildcards-globbing I think the verbosity is no big deal because we have tab completion, we're trading in conciseness for consistency and better searchability. In future, we can add back shorter invocations like "help globbing" (especially given that completion descriptions often already repeated the anchor path), but it should be checked by CI. Also - Remove some unused Sphinx anchors - Remove an obsoleted script. - Test that completions are in sync with Sphinx sources. (note that an alternative would be to check in the generated help_sections.rs file, see https://internals.rust-lang.org/t/how-fail-on-cargo-warning-warnings-from-build-rs/23590/5) Here's a list of deleted msgids. Some of them were unused, for others there was a better message (+ translation). $variable $variable 变量 (command) command substitution (命令) 命令替换 < and > redirections < 和 > 重定向 Autoloading functions 自动加载函数 Background jobs 后台作业 Builtin commands 内建命令 Combining different expansions 合并不同的展开 Command substitution (SUBCOMMAND) 命令替换 (子命令) Defining aliases 定义别名 Escaping characters 转义字符 Help on how to reuse previously entered commands 关于如何重复使用先前输入的命令的帮助 How lists combine 列表如何组合 Job control 作业控制 Local, global and universal scope 局域、全局和通用作用域 Other features 其他功能 Programmable prompt 可编程提示符 Shell variable and function names Shell 变量和函数名 Some common words 一些常用词 The status variable 状况变量 Variable scope for functions 函数的变量作用域 Vi mode commands Vi 模式命令 What set -x does `set -x` 做什么 Writing your own completions 自己写补全 ifs and elses if 和 else var[x..y] slices var[x..y] 切片 {a,b} brace expansion {a,b} 大括号展开 ~ expansion ~ 展开 Closes #11796
2025-11-05 13:44:42 +01:00
status help-sections
status terminal
status test-terminal-feature FEATURE
Description
-----------
With no arguments, ``status`` displays a summary of the current login and job control status of the shell.
The following operations (subcommands) are available:
**is-command-substitution**, **-c** or **--is-command-substitution**
Returns 0 if fish is currently executing a command substitution.
**is-block**, **-b** or **--is-block**
Returns 0 if fish is currently executing a block of code.
**is-breakpoint**
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.
**is-interactive**, **-i** or **--is-interactive**
Returns 0 if fish is interactive - that is, connected to a keyboard.
Fix regression causing cursor shape commands to leak into noninteractive shell As reported in https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$CLuoHTdvcRj_8-HBBq0p-lmGWeix5khEtKEDxN2Ulfo Running fish -C ' fzf_key_bindings echo fish_vi_key_bindings >>~/.config/fish/config.fish fzf-history-widget ' and pressing "enter" will add escape sequences like "[2 q" (cursor shape) to fish's command line. This is because fzf-history-widget binds "enter" to a filter that happens to be a fish script: set -lx FZF_DEFAULT_OPTS \ ... \ "--bind='enter:become:string replace -a -- \n\t \n {2..} | string collect'" \ '--with-shell='(status fish-path)\\ -c) The above ~/.config/fish/config.fish (redundantly) runs "fish_vi_key_bindings" even in *noninteractive* shells, then "fish_vi_cursor" will print cursor sequences in its "fish_exit" handler. The sequence is not printed to the terminal but to fzf which doesn't parse CSI commands. This is a regression introduced by a5dfa84f73 (fish_vi_cursor: skip if stdin is not a tty, 2023-11-14). That commit wanted "fish -c read" to be able to use Vi cursor. This is a noninteractive shell, but inside "read" we are "effectively interactive". However "status is-interactive" does not tell us that. Let's use a more contained fix to make sure that we print escape sequences only if either fish is interactive, or if we are evaluating an interactive read. In general, "fish -c read" is prone to configuration errors, since we recommend gating configuration (for bind etc) on "status is-interactive" which will not run here.
2025-03-02 07:39:58 +01:00
**is-interactive-read** or **--is-interactive-read**
Returns 0 if fish is running an interactive :doc:`read <read>` builtin which is connected to a keyboard.
**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`.
**is-full-job-control** or **--is-full-job-control**
Returns 0 if full job control is enabled.
**is-interactive-job-control** or **--is-interactive-job-control**
Returns 0 if interactive job control is enabled.
**is-no-job-control** or **--is-no-job-control**
Returns 0 if no job control is enabled.
**current-command**
Prints the name of the currently-running function or command, like the deprecated :envvar:`_` variable.
**current-commandline**
Prints the entirety of the currently-running commandline, inclusive of all jobs and operators.
**filename**, **current-filename**, **-f** or **--current-filename**
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 ``-``.
**basename**
Prints just the filename of the running script, without any path components before.
**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.
**fish-path**
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".
**function** or **current-function**
Prints the name of the currently called function if able, when missing displays "Not a function" (or equivalent translated string).
**line-number**, **current-line-number**, **-n** or **--current-line-number**
Prints the line number of the currently running script.
**stack-trace**, **print-stack-trace**, **-t** or **--print-stack-trace**
Prints a stack trace of all function calls on the call stack.
**job-control**, **-j** or **--job-control** *CONTROL_TYPE*
Sets the job control type to *CONTROL_TYPE*, which can be **none**, **full**, or **interactive**.
**features**
Lists all available :ref:`feature flags <featureflags>`.
**test-feature** *FEATURE*
Returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized.
**build-info**
This prints information on how fish was build - which architecture, which build system or profile was used, etc.
This is mainly useful for debugging.
.. _status-get-file:
**get-file** *FILE*
NOTE: this subcommand is mainly intended for fish's internal use; let us know if you want to use it elsewhere.
This prints a file embedded in the fish binary at compile time. This includes the default set of functions and completions,
as well as the man pages and themes. Which files are included depends on build settings.
Returns 0 if the file was included, 1 otherwise.
**list-files** *FILE*
NOTE: this subcommand is mainly intended for fish's internal use; let us know if you want to use it elsewhere.
This lists the files embedded in the fish binary at compile time. Only files where the path starts with the optional *FILE* argument are shown.
Returns 0 if something was printed, 1 otherwise.
help: get section titles from Sphinx functions/help and completions/help duplicate a lot of information from doc_src. Get this information from Sphinx. Drop short section titles such as "help globbing" in favor of the full HTML anchor: help language#wildcards-globbing I think the verbosity is no big deal because we have tab completion, we're trading in conciseness for consistency and better searchability. In future, we can add back shorter invocations like "help globbing" (especially given that completion descriptions often already repeated the anchor path), but it should be checked by CI. Also - Remove some unused Sphinx anchors - Remove an obsoleted script. - Test that completions are in sync with Sphinx sources. (note that an alternative would be to check in the generated help_sections.rs file, see https://internals.rust-lang.org/t/how-fail-on-cargo-warning-warnings-from-build-rs/23590/5) Here's a list of deleted msgids. Some of them were unused, for others there was a better message (+ translation). $variable $variable 变量 (command) command substitution (命令) 命令替换 < and > redirections < 和 > 重定向 Autoloading functions 自动加载函数 Background jobs 后台作业 Builtin commands 内建命令 Combining different expansions 合并不同的展开 Command substitution (SUBCOMMAND) 命令替换 (子命令) Defining aliases 定义别名 Escaping characters 转义字符 Help on how to reuse previously entered commands 关于如何重复使用先前输入的命令的帮助 How lists combine 列表如何组合 Job control 作业控制 Local, global and universal scope 局域、全局和通用作用域 Other features 其他功能 Programmable prompt 可编程提示符 Shell variable and function names Shell 变量和函数名 Some common words 一些常用词 The status variable 状况变量 Variable scope for functions 函数的变量作用域 Vi mode commands Vi 模式命令 What set -x does `set -x` 做什么 Writing your own completions 自己写补全 ifs and elses if 和 else var[x..y] slices var[x..y] 切片 {a,b} brace expansion {a,b} 大括号展开 ~ expansion ~ 展开 Closes #11796
2025-11-05 13:44:42 +01:00
**help-sections**
NOTE: this subcommand is intended for fish's internal use.
List section arguments for the :doc:`help <help>` command.
If you have the latest version of fish, these URL fragments are valid on `<https://fishshell.com/docs/current/>`__.
Always returns 0.
.. _status-terminal:
**terminal**
Prints the name and version of the terminal fish is running inside (for example as reported via :ref:`XTVERSION <term-compat-xtversion>`).
This is not available during early startup but only starting from when the first interactive prompt is shown, possibly via builtin :doc:`read <read>`,
so before the first ``fish_prompt`` or ``fish_read`` :ref:`event <event>`.
.. _status-test-terminal-features:
**test-terminal-feature** *FEATURE*
Returns 0 when the terminal was :ref:`detected <term-compat-xtgettcap>` to support the given feature.
Like :ref:`status terminal <status-terminal>`, this only works once the first interactive prompt is shown.
Currently the only available *FEATURE* is :ref:`scroll-content-up <term-compat-indn>`.
An error will be printed when passed an unrecognized feature.
Notes
-----
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.
You can only specify one subcommand per invocation even if you use the flag form of the subcommand.