diff --git a/doc_src/cmds/status.rst b/doc_src/cmds/status.rst index e132c7939..3bb11e92c 100644 --- a/doc_src/cmds/status.rst +++ b/doc_src/cmds/status.rst @@ -33,6 +33,7 @@ Synopsis status build-info status get-file FILE status list-files [PATH] + status terminal Description ----------- @@ -117,6 +118,11 @@ The following operations (subcommands) are available: 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. +**terminal** + Prints the name and version of the terminal fish is running inside (for example as reported via :ref:`XTVERSION `). + This is not available during early startup but only just before the first interactive prompt is shown (possibly via builtin :doc:`read `), + that is, on the first ``fish_prompt`` or ``fish_read`` :ref:`event `. + Notes ----- diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 3f5d5e2cf..f40fc9174 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -332,7 +332,8 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`ctrl-u` removes contents from the beginning of line to the cursor (moving it to the :ref:`killring `). -- :kbd:`ctrl-l` clears and repaints the screen. +- :kbd:`ctrl-l` pushes any text above the prompt to the terminal's scrollback, + then clears and repaints the screen. - :kbd:`ctrl-w` removes the previous path component (everything up to the previous "/", ":" or "@") (moving it to the :ref:`killring`). diff --git a/doc_src/language.rst b/doc_src/language.rst index e8ec55f65..c6b6bd870 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -1699,12 +1699,6 @@ Fish also provides additional information through the values of certain environm the process ID (PID) of the shell. -.. envvar:: fish_terminal - - the name and version of the terminal fish is running inside (for example as reported via :ref:`XTVERSION `). - This is initialized just before the first interactive prompt is shown (possibly via builtin :doc:`read `), - that is, on the first ``fish_prompt`` or ``fish_read`` :ref:`event `. - .. envvar:: history a list containing the last commands that were entered. diff --git a/po/de.po b/po/de.po index 2da15b33f..630553ae4 100644 --- a/po/de.po +++ b/po/de.po @@ -43918,6 +43918,9 @@ msgstr "" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "" diff --git a/po/en.po b/po/en.po index 1c236ee0a..501c4f6e0 100644 --- a/po/en.po +++ b/po/en.po @@ -43914,6 +43914,9 @@ msgstr "" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "" diff --git a/po/fr.po b/po/fr.po index d78e783ad..45c83ce4d 100644 --- a/po/fr.po +++ b/po/fr.po @@ -44015,6 +44015,9 @@ msgstr "Afficher la taille maximale de paquet (MTU)" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "Afficher le nom de chaque fichier lié" diff --git a/po/pl.po b/po/pl.po index 9d1545616..3f87f491c 100644 --- a/po/pl.po +++ b/po/pl.po @@ -43910,6 +43910,9 @@ msgstr "" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 6de597e91..55e17f87d 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -43931,6 +43931,9 @@ msgstr "" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "" diff --git a/po/sv.po b/po/sv.po index 02777d5df..97b44d439 100644 --- a/po/sv.po +++ b/po/sv.po @@ -43913,6 +43913,9 @@ msgstr "" msgid "Print multiple document pages on each output page" msgstr "" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 11793f622..a04ff12b6 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -43913,6 +43913,9 @@ msgstr "打印 mtu" msgid "Print multiple document pages on each output page" msgstr "在每个输出页面上打印多页文档" +msgid "Print name and version of the terminal fish is running in" +msgstr "" + msgid "Print name of each linked file" msgstr "打印每个链接文件的名称" diff --git a/share/completions/status.fish b/share/completions/status.fish index 4091fdf97..502a76398 100644 --- a/share/completions/status.fish +++ b/share/completions/status.fish @@ -27,6 +27,7 @@ set -l __fish_status_all_commands \ list-files \ print-stack-trace \ stack-trace \ + terminal \ test-feature # These are the recognized flags. @@ -64,6 +65,7 @@ complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_com complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a get-file -d "Print an embedded file from the fish binary" complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a list-files -d "List embedded files contained in the fish binary" complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a fish-path -d "Print the path to the current instance of fish" +complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a terminal -d "Print name and version of the terminal fish is running in" # The job-control command changes fish state. complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a job-control -d "Set which jobs are under job control" diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 9841c0f6a..6304c60a0 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -147,7 +147,7 @@ end" >$__fish_config_dir/config.fish # Guidance from the VTE developers is to let them repaint. # Konsole reflows since version 21.04. Konsole added XTVERSION # in v22.03.80~7. - if string match -rq -- "$fish_terminal" '^(?:VTE\b|Konsole |WezTerm )' + if string match -rq -- (status terminal) '^(?:VTE\b|Konsole |WezTerm )' or begin set -q KONSOLE_VERSION and test "$KONSOLE_VERSION" -ge 210400 2>/dev/null @@ -169,7 +169,7 @@ end" >$__fish_config_dir/config.fish if not functions --query __fish_update_cwd_osc function __fish_update_cwd_osc --on-variable PWD --description 'Notify terminals when $PWD changes' set -l host $hostname - # if set -l konsole_version (string match -r -- '^Konsole (\d+)\..*' "$fish_terminal")[2] + # if set -l konsole_version (string match -r -- '^Konsole (\d+)\..*' (status terminal))[2] # # To-do: use a Konsole version where KF6_DEP_VERSION is >= 6.12 # and $konsole_version -lt ??? # end diff --git a/src/builtins/status.rs b/src/builtins/status.rs index 39b7d5a60..d9d04ed66 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -7,6 +7,7 @@ get_job_control_mode, get_login, is_interactive_session, set_job_control_mode, JobControl, }; use crate::reader::reader_in_interactive_read; +use crate::tty_handoff::xtversion; use crate::wutil::{waccess, wbasename, wdirname, wrealpath, Error}; use libc::F_OK; use nix::errno::Errno; @@ -63,6 +64,7 @@ enum StatusCmd { STATUS_BUILDINFO, STATUS_GET_FILE, STATUS_LIST_FILES, + STATUS_TERMINAL, } str_enum!( @@ -97,6 +99,7 @@ enum StatusCmd { (STATUS_LINE_NUMBER, "line-number"), (STATUS_STACK_TRACE, "print-stack-trace"), (STATUS_STACK_TRACE, "stack-trace"), + (STATUS_TERMINAL, "terminal"), (STATUS_TEST_FEATURE, "test-feature"), ); @@ -718,6 +721,14 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> B streams.out.appendln(path); } } + STATUS_TERMINAL => { + let xtversion = xtversion().unwrap_or_default(); + let first_line = &xtversion[..xtversion + .chars() + .position(|c| c == '\n') + .unwrap_or(xtversion.len())]; + streams.out.appendln(first_line); + } STATUS_SET_JOB_CONTROL | STATUS_FEATURES | STATUS_TEST_FEATURE diff --git a/src/env/var.rs b/src/env/var.rs index 669f7d3ed..0c2ba8a0e 100644 --- a/src/env/var.rs +++ b/src/env/var.rs @@ -249,7 +249,6 @@ pub struct ElectricVar { ElectricVar{name: L!("fish_kill_signal"), flags:electric::READONLY | electric::COMPUTED}, ElectricVar{name: L!("fish_killring"), flags:electric::READONLY | electric::COMPUTED}, ElectricVar{name: L!("fish_pid"), flags:electric::READONLY}, - ElectricVar{name: L!("fish_terminal"), flags:electric::READONLY}, ElectricVar{name: L!("history"), flags:electric::READONLY | electric::COMPUTED}, ElectricVar{name: L!("hostname"), flags:electric::READONLY}, ElectricVar{name: L!("pipestatus"), flags:electric::READONLY | electric::COMPUTED}, diff --git a/src/reader.rs b/src/reader.rs index 91313f1ed..6a973e61b 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -148,7 +148,6 @@ TOK_SHOW_COMMENTS, }; use crate::tty_handoff::get_scroll_content_up_capability; -use crate::tty_handoff::xtversion; use crate::tty_handoff::SCROLL_CONTENT_UP_TERMINFO_CODE; use crate::tty_handoff::{ get_tty_protocols_active, initialize_tty_metadata, safe_deactivate_tty_protocols, TtyHandoff, @@ -385,11 +384,6 @@ pub fn reader_push<'a>(parser: &'a Parser, history_name: &wstr, conf: ReaderConf let input_data = if !parser.interactive_initialized.swap(true) { let mut input_queue = terminal_init(parser.vars(), inputfd); let input_data = input_queue.get_input_data_mut(); - parser.vars().set_one( - L!("fish_terminal"), - EnvMode::GLOBAL, - xtversion().unwrap().to_owned(), - ); guess_emoji_width(parser.vars()); // Provide value for `status current-command`