mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-26 07:41:15 -03:00
Move terminal name into status subcommand not variable
Forgot about that; less namespace pollution this way, and it's more obvious that it's read-only.
This commit is contained in:
@@ -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 <term-compat-xtversion>`).
|
||||
This is not available during early startup but only just before the first interactive prompt is shown (possibly via builtin :doc:`read <read>`),
|
||||
that is, on the first ``fish_prompt`` or ``fish_read`` :ref:`event <event>`.
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
|
||||
@@ -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 <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`).
|
||||
|
||||
|
||||
@@ -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 <term-compat-xtversion>`).
|
||||
This is initialized just before the first interactive prompt is shown (possibly via builtin :doc:`read <cmds/read>`),
|
||||
that is, on the first ``fish_prompt`` or ``fish_read`` :ref:`event <event>`.
|
||||
|
||||
.. envvar:: history
|
||||
|
||||
a list containing the last commands that were entered.
|
||||
|
||||
3
po/de.po
3
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 ""
|
||||
|
||||
|
||||
3
po/en.po
3
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 ""
|
||||
|
||||
|
||||
3
po/fr.po
3
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é"
|
||||
|
||||
|
||||
3
po/pl.po
3
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 ""
|
||||
|
||||
|
||||
@@ -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 ""
|
||||
|
||||
|
||||
3
po/sv.po
3
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 ""
|
||||
|
||||
|
||||
@@ -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 "打印每个链接文件的名称"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
1
src/env/var.rs
vendored
1
src/env/var.rs
vendored
@@ -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},
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user