From 7069f3fe405576a1ecac305a4d9135999ccf6d15 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 22 Dec 2024 18:13:29 +0100 Subject: [PATCH 001/113] Allow installable builds to be installed into a specific path (#10923) * Pass path to install() It was dirty that it would re-get $HOME there anyway. * Import wcs2osstring * Allow installable builds to use a relocatable tree If you give a path to `--install`, it will install fish into a relocatable tree there, so PATH/share/fish contains the datafiles PATH/bin/fish contains the fish executable PATH/etc/fish is sysconf I am absolutely not sold on that last one - the way I always used sysconfdir is that it is always /etc. This would be easy to fix but should probably also be fixed for "regular" relocatable builds (no idea who uses them). An attempt at #10916 * Move install path into "install/" subdir * Disable --install harder if not installable --- doc_src/cmds/fish.rst | 4 +- src/bin/fish.rs | 88 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 76 insertions(+), 16 deletions(-) diff --git a/doc_src/cmds/fish.rst b/doc_src/cmds/fish.rst index 22c7e17c4..19889d964 100644 --- a/doc_src/cmds/fish.rst +++ b/doc_src/cmds/fish.rst @@ -40,9 +40,11 @@ The following options are available: **-i** or **--interactive** The shell is interactive. -**--install** +**--install[=PATH]** When built as self-installable (via cargo), this will unpack fish's datafiles and place them in ~/.local/share/fish/install/. Fish will also ask to do this automatically when run interactively. + If PATH is given, fish will install itself into a relocatable directory tree rooted at that path. + That means it will install the datafiles to PATH/share/fish and copy itself to PATH/bin/fish. **-l** or **--login** Act as if invoked as a login shell. diff --git a/src/bin/fish.rs b/src/bin/fish.rs index 40b2ebb32..0a7105b17 100644 --- a/src/bin/fish.rs +++ b/src/bin/fish.rs @@ -30,7 +30,7 @@ }, common::{ escape, get_executable_path, save_term_foreground_process_group, scoped_push_replacer, - str2wcstring, wcs2string, PACKAGE_NAME, PROFILING_ACTIVE, PROGRAM_NAME, + str2wcstring, wcs2osstring, wcs2string, PACKAGE_NAME, PROFILING_ACTIVE, PROGRAM_NAME, }, env::{ environment::{env_init, EnvStack, Environment}, @@ -80,7 +80,7 @@ #[cfg(feature = "installable")] // Disable for clippy because otherwise it would require sphinx #[cfg(not(clippy))] -fn install(confirm: bool) -> bool { +fn install(confirm: bool, dir: PathBuf) -> bool { use rust_embed::RustEmbed; #[derive(RustEmbed)] @@ -96,11 +96,6 @@ fn install(confirm: bool) -> bool { use std::io::ErrorKind; use std::io::Write; use std::io::{stderr, stdin}; - let Some(home) = fish::env::get_home() else { - FLOG!(error, "Can't find home directory."); - return false; - }; - let dir = PathBuf::from(home).join(DATA_DIR).join(DATA_DIR_SUBDIR); // TODO: Translation, // FLOG? @@ -197,7 +192,7 @@ fn install(confirm: bool) -> bool { } #[cfg(any(clippy, not(feature = "installable")))] -fn install(_confirm: bool) -> bool { +fn install(_confirm: bool, _dir: PathBuf) -> bool { eprintln!("Fish was built without support for self-installation"); return false; } @@ -300,10 +295,17 @@ fn determine_config_directory_paths(argv0: impl AsRef) -> ConfigPaths { } if !done { - // The next check is that we are in a reloctable directory tree + // The next check is that we are in a relocatable directory tree if exec_path.ends_with("bin/fish") { let base_path = exec_path.parent().unwrap().parent().unwrap(); paths = ConfigPaths { + // One obvious path is ~/.local (with fish in ~/.local/bin/). + // If we picked ~/.local/share/fish as our data path, + // we would install there and erase history. + // So let's isolate us a bit more. + #[cfg(feature = "installable")] + data: base_path.join("share/fish/install"), + #[cfg(not(feature = "installable"))] data: base_path.join("share/fish"), sysconf: base_path.join("etc/fish"), doc: base_path.join("share/doc/fish"), @@ -316,6 +318,9 @@ fn determine_config_directory_paths(argv0: impl AsRef) -> ConfigPaths { ); let base_path = exec_path.parent().unwrap(); paths = ConfigPaths { + #[cfg(feature = "installable")] + data: base_path.join("share/install"), + #[cfg(not(feature = "installable"))] data: base_path.join("share"), sysconf: base_path.join("etc"), doc: base_path.join("user_doc/html"), @@ -339,7 +344,8 @@ fn determine_config_directory_paths(argv0: impl AsRef) -> ConfigPaths { let Some(home) = fish::env::get_home() else { FLOG!( error, - "Cannot find home directory and will refuse to read configuration" + "Cannot find home directory and will refuse to read configuration.\n", + "Consider installing into a directory tree with `fish --install=PATH`." ); return paths; }; @@ -421,8 +427,7 @@ fn check_version_file(paths: &ConfigPaths, datapath: &wstr) -> Option { { // When fish is installable, we write the version to a file, // now we check it. - let verfile = - PathBuf::from(fish::common::wcs2osstring(datapath)).join("fish-install-version"); + let verfile = PathBuf::from(wcs2osstring(datapath)).join("fish-install-version"); let version = std::fs::read_to_string(verfile).ok()?; return Some(version == fish::BUILD_VERSION); @@ -458,7 +463,7 @@ fn read_init(parser: &Parser, paths: &ConfigPaths) { ); } - install(true); + install(true, PathBuf::from(wcs2osstring(&datapath))); // We try to go on if installation failed (or was rejected) here // If the assets are missing, we will trigger a later error, // if they are outdated, things will probably (tm) work somewhat. @@ -540,7 +545,7 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow ControlFlow opts.batch_cmds.push("__fish_print_help fish".into()), 'i' => opts.is_interactive_session = true, 'I' => { - install(false); + #[cfg(not(feature = "installable"))] + eprintln!("Fish was built without support for self-installation"); + #[cfg(feature = "installable")] + if let Some(path) = w.woptarg { + // We were given an explicit path. + // Install us there as a relocatable install. + // That means: + // path/bin/fish is the fish binary + // path/share/fish/ is the data directory + // path/etc/fish is sysconf???? + use std::fs; + let dir = PathBuf::from(wcs2osstring(path)); + if install(true, dir.join("share/fish/install")) { + for sub in &["share/fish/install", "etc/fish", "bin"] { + let p = dir.join(sub); + let Ok(_) = fs::create_dir_all(p.clone()) else { + eprintln!("Creating directory '{}' failed", p.display()); + std::process::exit(1); + }; + } + + // Copy ourselves there. + let argv0 = OsString::from_vec(wcs2string(&args[0])); + let exec_path = + get_executable_path(>::as_ref(&argv0)); + let binpath = dir.join("bin/fish"); + if let Ok(exec_path) = exec_path.canonicalize() { + if exec_path != binpath { + if let Err(err) = std::fs::copy(exec_path, binpath.clone()) { + FLOG!(error, "Cannot copy fish to", binpath.display()); + FLOG!(error, err); + std::process::exit(1); + } + println!( + "Fish installed in '{}'. Start that from now on.", + binpath.display() + ); + // TODO: Reexec fish? + std::process::exit(0); + } + } else { + FLOG!(error, "Cannot copy fish to '%ls'. Please copy the fish binary there manually", binpath.display()); + } + } + } else { + let paths = Some(determine_config_directory_paths(OsString::from_vec( + wcs2string(&args[0]), + ))); + let Some(paths) = paths else { + FLOG!(error, "Cannot find config paths"); + std::process::exit(1); + }; + install(true, paths.data); + } } 'l' => opts.is_login = true, 'N' => { From f237fb7b9f2c46e91f0077f4c6cd5d9efb30ac39 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 23 Dec 2024 14:30:46 +0100 Subject: [PATCH 002/113] Changelog: move over the bits that apply to this branch This seems more logical, especially since these need not be mentioned in the "final" 4.0. When we merge the integration branch back into master, we can combine changelog additions, so it won't be lost from master. --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 94412f6ec..a83c005e1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,10 @@ +Changes since 4.0b1 +------------------- +- :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. :issue:`10928` +- Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: + fish --install=$HOME/.local/ + In that case, the fish binary will be moved to "bin/" in that path. :issue:`10923` + fish 4.0b1 (released December 17, 2024) ======================================= From 70ba81e5b3d191c7dd61c02b788f5a9a866b18e0 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 23 Dec 2024 13:51:07 +0100 Subject: [PATCH 003/113] Provide old implementation of cancel-commandline as fallback __fish_cancel_commandline was unused (even before) and has some issues on multiline commandlines. Make it use the previously active logic. Closes #10935 Cherry-picked from 5de6f4bb3d8c3d4db1fd0b66c2ebfa59682ccc84 --- CHANGELOG.rst | 7 ++--- .../functions/__fish_cancel_commandline.fish | 30 ++---------------- src/input.rs | 1 + src/input_common.rs | 1 + src/reader.rs | 31 ++++++++++++++++++- 5 files changed, 36 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a83c005e1..fa91bd759 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,7 @@ Changes since 4.0b1 ------------------- - :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. :issue:`10928` +- Fix a regression in the beta where ``__fish_cancel_commandline`` caused glitches on multi-line command lines (:issue:`10935`). - Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: fish --install=$HOME/.local/ In that case, the fish binary will be moved to "bin/" in that path. :issue:`10923` @@ -8,10 +9,6 @@ Changes since 4.0b1 fish 4.0b1 (released December 17, 2024) ======================================= -Changes since 4.0b1 -------------------- -- :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. - These are the draft release notes for fish 4.0.0. Like this release of fish itself, they are in beta and are not complete. Please report any issues you find. .. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9751 9754 9765 9767 9768 9771 9777 9778 9786 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10707 10708 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10907 @@ -72,7 +69,7 @@ Notable improvements and fixes This build system is experimental; the main build system, using ``cmake``, remains the recommended approach for packaging and installation to a prefix. - A new function ``fish_should_add_to_history`` can be overridden to decide whether a command should be added to the history (:issue:`10302`). -- :kbd:`ctrl-c` during command input no longer prints ``^C`` and a new prompt, but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior, use ``bind ctrl-c __fish_cancel_commandline`` (:issue:`10213`). +- :kbd:`ctrl-c` during command input no longer prints ``^C`` and a new prompt, but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior, use ``for mode in (bind --list-modes); bind -M $mode ctrl-c cancel-commandline-traditional; end`` (:issue:`10213`). - Bindings can now mix special input functions and shell commands, so ``bind ctrl-g expand-abbr "commandline -i \n"`` works as expected (:issue:`8186`). - Special input functions run from bindings via ``commandline -f`` are now applied immediately, instead of after the currently executing binding (:issue:`3031`). For example, ``commandline -i foo; commandline | grep foo`` succeeds now. diff --git a/share/functions/__fish_cancel_commandline.fish b/share/functions/__fish_cancel_commandline.fish index 79bc3b302..6d1a37dc2 100644 --- a/share/functions/__fish_cancel_commandline.fish +++ b/share/functions/__fish_cancel_commandline.fish @@ -1,30 +1,4 @@ -function __fish_setup_cancel_text -v fish_color_cancel -v fish_color_normal - set -g __fish_cancel_text "^C" - if set -q fish_color_cancel - set __fish_cancel_text (echo -sn (set_color $fish_color_cancel) $__fish_cancel_text (set_color normal)) - end - if command -sq tput - # Clear to EOL (to erase any autosuggestions) - set __fish_cancel_text (echo -sn $__fish_cancel_text (tput el; or tput ce)) - end -end -__fish_setup_cancel_text - -# This is meant to be bound to something like \cC. +# This is meant to be bound to something like ctrl-c function __fish_cancel_commandline - set -l cmd (commandline) - if test -n "$cmd" - echo -sn $__fish_cancel_text - # `commandline -L` prints the line the cursor is on (starting from the prompt), so move the cursor - # "to the end" then call `commandline -L` to get the total number of lines typed in at the prompt. - commandline -C 10000000 - printf (string repeat -n (commandline -L) "\n") - commandline "" - emit fish_cancel - end - - # cancel: Close the pager if it's open (#4298) - # repaint: Repaint even if we haven't cancelled anything so the prompt refreshes - # and the terminal scrolls to it. - commandline -f cancel -f repaint + commandline -f cancel-commandline-traditional end diff --git a/src/input.rs b/src/input.rs index 6407ed9b0..fdca0f863 100644 --- a/src/input.rs +++ b/src/input.rs @@ -146,6 +146,7 @@ const fn make_md(name: &'static wstr, code: ReadlineCmd) -> InputFunctionMetadat make_md(L!("beginning-of-line"), ReadlineCmd::BeginningOfLine), make_md(L!("cancel"), ReadlineCmd::Cancel), make_md(L!("cancel-commandline"), ReadlineCmd::CancelCommandline), + make_md(L!("cancel-commandline-traditional"), ReadlineCmd::CancelCommandlineTraditional), make_md(L!("capitalize-word"), ReadlineCmd::CapitalizeWord), make_md(L!("clear-screen"), ReadlineCmd::ClearScreenAndRepaint), make_md(L!("complete"), ReadlineCmd::Complete), diff --git a/src/input_common.rs b/src/input_common.rs index 20b4124ec..27f7ff5aa 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -123,6 +123,7 @@ pub enum ReadlineCmd { DeleteOrExit, Exit, CancelCommandline, + CancelCommandlineTraditional, Cancel, Undo, Redo, diff --git a/src/reader.rs b/src/reader.rs index 3bbb491cc..dcbd3bc25 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -87,6 +87,7 @@ use crate::libc::MB_CUR_MAX; use crate::nix::isatty; use crate::operation_context::{get_bg_context, OperationContext}; +use crate::output::parse_color; use crate::output::Outputter; use crate::pager::{PageRendering, Pager, SelectionMotion}; use crate::panic::AT_EXIT; @@ -2308,7 +2309,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { self.data .update_buff_pos(EditableLineTag::Commandline, Some(self.command_line_len())); } - rl::CancelCommandline => { + rl::CancelCommandline | rl::CancelCommandlineTraditional => { if self.conf.exit_on_interrupt { self.parser .set_last_statuses(Statuses::just(STATUS_CMD_ERROR.unwrap())); @@ -2318,10 +2319,37 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { if self.command_line.is_empty() { return; } + if c == rl::CancelCommandlineTraditional { + // Move cursor to the end of the line. + let end = self.command_line.len(); + self.update_buff_pos(EditableLineTag::Commandline, Some(end)); + self.autosuggestion.clear(); + // Repaint also changes the actual cursor position + if self.is_repaint_needed(None) { + self.layout_and_repaint(L!("cancel")); + } + + let mut outp = Outputter::stdoutput().borrow_mut(); + if let Some(fish_color_cancel) = self.vars().get(L!("fish_color_cancel")) { + outp.set_color( + parse_color(&fish_color_cancel, false), + parse_color(&fish_color_cancel, true), + ); + } + outp.write_wstr(L!("^C")); + outp.set_color(RgbColor::RESET, RgbColor::RESET); + + // We print a newline last so the prompt_sp hack doesn't get us. + outp.push(b'\n'); + } self.push_edit( EditableLineTag::Commandline, Edit::new(0..self.command_line_len(), L!("").to_owned()), ); + if c == rl::CancelCommandlineTraditional { + self.screen + .reset_abandoning_line(usize::try_from(termsize_last().width).unwrap()); + } // Post fish_cancel. event::fire_generic(self.parser, L!("fish_cancel").to_owned(), vec![]); @@ -5006,6 +5034,7 @@ fn command_ends_paging(c: ReadlineCmd, focused_on_search_field: bool) -> bool { | rl::AcceptAutosuggestion | rl::DeleteOrExit | rl::CancelCommandline + | rl::CancelCommandlineTraditional | rl::Cancel => // These commands always end paging. { From 5fed900b94e0a868b8d05666e9f5c5cd1849087b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 19 Dec 2024 07:57:03 +0100 Subject: [PATCH 004/113] Temporary workaround for BSD WEXITSTATUS libc bug The libc crate has a bug on BSD where WEXITSTATUS is not an 8-bit value, causing assertion failures. Any libc higher than our 0.2.155 would increase our MSRV, see libc commit 5ddbdc29f (Bump MSRV to 1.71, 2024-01-07), so we want to woraround this anyway. It's probably not worth using a patched version of libc since it's just one line. While at it, tighten some types I guess. Upstream fix: https://github.com/rust-lang/libc/pull/4213 Closes #10919 Cherry-picked from c1b460525c6fc4a720cd40c5b214d0e92bbe047b --- CHANGELOG.rst | 1 + src/proc.rs | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index fa91bd759..bebb5ba10 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,7 @@ Changes since 4.0b1 ------------------- - :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. :issue:`10928` +- Fix a BSD-specific regression in the beta that caused crashes when a child process exited with a status like -1 (:issue:`10919`). - Fix a regression in the beta where ``__fish_cancel_commandline`` caused glitches on multi-line command lines (:issue:`10935`). - Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: fish --install=$HOME/.local/ diff --git a/src/proc.rs b/src/proc.rs index cc8012183..7537458fa 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -233,14 +233,14 @@ pub fn signal_code(&self) -> libc::c_int { } /// Return the exit code, given that we normal exited. - pub fn exit_code(&self) -> libc::c_int { + pub fn exit_code(&self) -> u8 { assert!(self.normal_exited(), "Process is not normal exited"); - WEXITSTATUS(self.status()) + u8::try_from(WEXITSTATUS(self.status()) & 0xff).unwrap() // Workaround for libc bug } /// Return if this status represents success. pub fn is_success(&self) -> bool { - self.normal_exited() && self.exit_code() == EXIT_SUCCESS + self.normal_exited() && self.exit_code() == u8::try_from(EXIT_SUCCESS).unwrap() } /// Return the value appropriate to populate $status. @@ -248,7 +248,7 @@ pub fn status_value(&self) -> i32 { if self.signal_exited() { 128 + self.signal_code() } else if self.normal_exited() { - self.exit_code() + i32::from(self.exit_code()) } else { panic!("Process is not exited") } From aed52049abfc38665fe3c6dde3033349b317c004 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 23 Dec 2024 17:01:04 +0100 Subject: [PATCH 005/113] Remove SIGUNUSED It is, as the name implies, unused - it became SIGSYS, which we already check. Since it is entirely undefined on some architectures it causes a build failure there, see discussion in #10633 --- src/signal.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/signal.rs b/src/signal.rs index 6aa995f98..9b51e6dfe 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -407,10 +407,6 @@ const fn new(signal: i32, name: &'static wstr, desc: &'static wstr) -> Self { #[cfg(target_os = "linux")] LookupEntry::new(libc::SIGIOT, L!("SIGIOT"), L!("Abort (Alias for SIGABRT)")), - #[cfg(target_os = "linux")] - #[allow(deprecated)] - LookupEntry::new(libc::SIGUNUSED, L!("SIGUNUSED"), L!("Unused signal")), - #[cfg(target_os = "linux")] LookupEntry::new(libc::SIGPWR, L!("SIGPWR"), L!("Power failure")), From d707a516d234ab096cb81368a624fb1f382ec9d5 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 25 Dec 2024 14:50:27 +0100 Subject: [PATCH 006/113] docs: Use grid in the CSS (#10942) Instead of hardcoded 230px margin. This also makes the ToC only take up a third of the screen when narrow, and lets you scroll the rest. Without, you'd have to scroll past the *entire* ToC, which is awkward Remaining issue is the search box up top. Since this disables the one in the sidebar once the window gets too narrow, that one is important, and it isn't *great* (cherry picked from commit 9b8793a2df508ac5f2cc7eeee72720488fa6f422) --- .../python_docs_theme/static/pydoctheme.css | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/doc_src/python_docs_theme/static/pydoctheme.css b/doc_src/python_docs_theme/static/pydoctheme.css index b6b00ad64..41c062b74 100644 --- a/doc_src/python_docs_theme/static/pydoctheme.css +++ b/doc_src/python_docs_theme/static/pydoctheme.css @@ -71,12 +71,10 @@ div.related h3 { } div.related li.right { - float: right; margin-right: 5px; } div.sphinxsidebar { - width: 230px; overflow-wrap: break-word; } @@ -113,7 +111,6 @@ div.sphinxsidebar ul { margin: 10px; padding: 0; color: var(--secondary-link-color); - margin: 10px; list-style: none; } @@ -548,10 +545,6 @@ div.sphinxsidebar ul { } -div.bodywrapper { - margin-left: 230px; -} - aside.footnote > .label { display: inline; } @@ -565,19 +558,36 @@ div.documentwrapper { width: 100%; } +div.document { + display: grid; + grid-template: 1fr min-content / 12rem minmax(0,1fr); +} + /* On screens that are less than 700px wide remove anything non-essential - the sidebar, the gradient background, ... */ @media screen and (max-width: 700px) { + div.document { + display: grid; + grid-template: 30vh min-content / 100%; + } div.sphinxsidebar { font-size: 16px; width: 100%; height: auto; position: relative; + /* To separate the "side"bar from the content below */ + border-bottom: 1px solid; + border-color: var(--sidebar-border-color); } - div.bodywrapper { + + /* Reduce margins to save space */ + div.sphinxsidebar ul ul, div.sphinxsidebar ul, div.bodywrapper, div.content { margin-left: 0; } + div.sphinxsidebar h3, div.sphinxsidebar h4 { + margin-top: 0; + } div.sphinxsidebar ul { flex-basis: content; @@ -585,14 +595,15 @@ div.documentwrapper { } div.sphinxsidebarwrapper { display: flex; + gap: 1em; + justify-content: space-between; } div.sphinxsidebarwrapper > h3:nth-child(5) { display: none; } - div#searchbox { + #searchbox { display: none !important; } - div.content {margin-left: 0;} div.body { padding: 1rem; } @@ -613,6 +624,9 @@ div.documentwrapper { /* On print media remove anything non-essential. */ @media print { + div.document { + display: block; + } .inline-search { display: none; } From 6db110916bd5af6d6b179bda93f6d16d17b130a0 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 26 Dec 2024 13:19:41 +0800 Subject: [PATCH 007/113] Debian packaging: reformat dependencies (cherry picked from commit 74b12474613e4107d55b49391b3ee0f0f20be3a0) --- debian/control | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/debian/control b/debian/control index 4cc47eeed..6dd45365d 100644 --- a/debian/control +++ b/debian/control @@ -3,10 +3,16 @@ Section: shells Priority: optional Maintainer: ridiculous_fish Uploaders: David Adam -Build-Depends: debhelper (>= 12), cmake (>= 3.19.0) | cmake-mozilla (>= 3.19.0), gettext, - rustc (>= 1.70), cargo (>= 0.66) | cargo-mozilla (>= 0.66), libpcre2-dev, +Build-Depends: debhelper (>= 12), + cargo (>= 0.66) | cargo-mozilla (>= 0.66), + cmake (>= 3.19.0) | cmake-mozilla (>= 3.19.0), + gettext, + libpcre2-dev, + rustc (>= 1.70), # Test dependencies - locales-all, ncurses-base, python3 + locales-all, + ncurses-base, + python3 Standards-Version: 4.1.5 Homepage: https://fishshell.com/ Vcs-Git: https://github.com/fish-shell/fish-shell.git @@ -14,8 +20,14 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell Package: fish Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, file, gettext-base, man-db, ncurses-base, procps, - python3 (>=3.5) +Depends: file, + gettext-base, + man-db, + ncurses-base, + procps, + python3 (>=3.5), + ${misc:Depends}, + ${shlibs:Depends} Conflicts: fish-common Recommends: xsel (>=1.2.0) Suggests: xdg-utils From bd2ddda9a4e3b6762f65aad48be7388fab596908 Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 26 Dec 2024 13:20:00 +0800 Subject: [PATCH 008/113] update CMake requirement find_rust uses LIST(POP_BACK), which was added in 3.15. (cherry picked from commit 044cea1bf39878b05a9b303345c9da3878d28e78) --- CMakeLists.txt | 2 +- README.rst | 2 +- debian/control | 2 +- fish.spec.in | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ae4f3714..310108df9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.15) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") diff --git a/README.rst b/README.rst index 9e115010e..a55ba0ab3 100644 --- a/README.rst +++ b/README.rst @@ -123,7 +123,7 @@ Dependencies Compiling fish requires: - Rust (version 1.70 or later) -- CMake (version 3.5 or later) +- CMake (version 3.15 or later) - a C compiler (for system feature detection and the test helper binary) - PCRE2 (headers and libraries) - optional, this will be downloaded if missing - gettext (headers and libraries) - optional, for translation support diff --git a/debian/control b/debian/control index 6dd45365d..063ef2927 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: ridiculous_fish Uploaders: David Adam Build-Depends: debhelper (>= 12), cargo (>= 0.66) | cargo-mozilla (>= 0.66), - cmake (>= 3.19.0) | cmake-mozilla (>= 3.19.0), + cmake (>= 3.15.0) | cmake-mozilla (>= 3.15.0), gettext, libpcre2-dev, rustc (>= 1.70), diff --git a/fish.spec.in b/fish.spec.in index 6c262ac9d..a74487df0 100644 --- a/fish.spec.in +++ b/fish.spec.in @@ -14,7 +14,7 @@ BuildRequires: cargo gettext gcc xz pcre2-devel BuildRequires: rust >= 1.70 # Packaging guidelines say to use a BuildRequires: rust-packaging, but it adds no value for our package -BuildRequires: cmake >= 3.19 +BuildRequires: cmake >= 3.15 %if 0%{?suse_version} BuildRequires: update-desktop-files From e858322749964e1488692833250bbfc457f7649f Mon Sep 17 00:00:00 2001 From: David Adam Date: Thu, 26 Dec 2024 13:21:33 +0800 Subject: [PATCH 009/113] Debian packaging: add some missing runtime dependencies (cherry picked from commit eade6a56728de60dcdc3bd0a069035a18bf704c8) --- debian/control | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 063ef2927..24d37f3c2 100644 --- a/debian/control +++ b/debian/control @@ -20,8 +20,10 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell Package: fish Architecture: any -Depends: file, +Depends: bsdextrautils, + file, gettext-base, + groff-base, man-db, ncurses-base, procps, From 06105e92074d7b2e2ed1226eb223145089b47eb0 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Thu, 26 Dec 2024 13:35:37 +0800 Subject: [PATCH 010/113] Fix alt-e cursor position restore on Vim <= 8 (#10946) Cherry-picked from commit 94dfe1b05304b9177f24f3daccefd272798b456c --- share/functions/edit_command_buffer.fish | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/share/functions/edit_command_buffer.fish b/share/functions/edit_command_buffer.fish index 0b942c404..0cee57abd 100644 --- a/share/functions/edit_command_buffer.fish +++ b/share/functions/edit_command_buffer.fish @@ -54,10 +54,7 @@ function edit_command_buffer --description 'Edit the command buffer in an extern end set cursor_from_editor (mktemp) set -a editor +$line "+norm! $col|" $f \ - '+autocmd VimLeave * ++once call writefile( - [printf("%s %s %s", shellescape(bufname()), line("."), col("."))], - "'$cursor_from_editor'" - )' + '+au VimLeave * ++once call writefile([printf("%s %s %s", shellescape(bufname()), line("."), col("."))], "'$cursor_from_editor'")' case emacs emacsclient gedit set -a editor +$line:$col $f case kak From ea2c53ca856ed34b5ee19b2ddf98e55ba37c31a9 Mon Sep 17 00:00:00 2001 From: Dmitry Gerasimov Date: Thu, 26 Dec 2024 18:52:15 +0100 Subject: [PATCH 011/113] completions/dnf: Fix completions for DNF5 (#9862) Since DNF5 there's no implicit \n in repoquery output. For DNF4 this change leaves blank lines in the output, but they are ignored anyway. --- share/completions/dnf.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/completions/dnf.fish b/share/completions/dnf.fish index 74c38dfcd..3e2d3d072 100644 --- a/share/completions/dnf.fish +++ b/share/completions/dnf.fish @@ -3,7 +3,7 @@ # function __dnf_list_installed_packages - dnf repoquery --cacheonly "$cur*" --qf "%{name}" --installed /dev/null) + set results (dnf repoquery --cacheonly "$tok*" --qf "%{name}\n" --available /dev/null) end if set -q results[1] set results (string match -r -- '.*\\.rpm$' $files) $results From 701853fdd3eb55a47d3dc64f9e0bcbe6fb850ba1 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Sat, 28 Dec 2024 15:31:49 +0800 Subject: [PATCH 012/113] docs: Distinguish documents in sidebar (cherry picked from commit a579abb81bf883486f8d89181ce99ba291d84893) --- doc_src/python_docs_theme/static/pydoctheme.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc_src/python_docs_theme/static/pydoctheme.css b/doc_src/python_docs_theme/static/pydoctheme.css index 41c062b74..02983ef1c 100644 --- a/doc_src/python_docs_theme/static/pydoctheme.css +++ b/doc_src/python_docs_theme/static/pydoctheme.css @@ -53,7 +53,6 @@ body { div.related ul { margin: 0; padding: 0 0 0 10px; - list-style: none; } div.related { @@ -581,7 +580,7 @@ div.document { } /* Reduce margins to save space */ - div.sphinxsidebar ul ul, div.sphinxsidebar ul, div.bodywrapper, div.content { + div.sphinxsidebar ul ul, div.bodywrapper, div.content { margin-left: 0; } From f75912d20543ec3eec5f90af8fb9f5d484a1f5b5 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sat, 28 Dec 2024 16:03:40 +0100 Subject: [PATCH 013/113] Create release-with-debug cargo profile, hook it up with cmake Fixes #10959 (cherry picked from commit 66b80041cc84d067662af9f07cdbca4d22379bab) --- CMakeLists.txt | 2 +- Cargo.toml | 4 ++++ cmake/Rust.cmake | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 310108df9..496226e89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ function(CREATE_TARGET target) ${Rust_CARGO} build --bin ${target} $<$:--release> - $<$:--release> + $<$:--profile=release-with-debug> --target ${Rust_CARGO_TARGET} --no-default-features ${CARGO_FLAGS} diff --git a/Cargo.toml b/Cargo.toml index 28693d3aa..69fc9bd02 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,10 @@ edition = "2021" overflow-checks = true lto = true +[profile.release-with-debug] +inherits = "release" +debug = true + [package] name = "fish" version = "4.0.0-beta.1" diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 7a7949663..82102fc3f 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -22,7 +22,7 @@ else() set(rust_target_dir "${FISH_RUST_BUILD_DIR}/${Rust_CARGO_HOST_TARGET}") endif() -set(rust_profile $,debug,release>) +set(rust_profile $,debug,$,release-with-debug,release>>) set(rust_debugflags "$<$:-g>$<$:-g>") From c0a2b55efd2b4bd23d2332f13ceb8e075318d64e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Bruguera=20Mic=C3=B3?= Date: Sat, 28 Dec 2024 12:05:58 +0000 Subject: [PATCH 014/113] Create new base directories with mode 0700 If base directories (e.g. $HOME/.config/fish) need to be created, create them with mode 0700 (i.e. restricted to the owner). This both keeps the behavior of old fish versions (e.g. 3.7.1) and is compliant with the XDG Base Directory Specification. See: https://specifications.freedesktop.org/basedir-spec/0.8/#referencing --- src/path.rs | 11 ++++++++++- tests/checks/create-base-directories.fish | 16 ++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 tests/checks/create-base-directories.fish diff --git a/src/path.rs b/src/path.rs index c8ad89458..b9185680f 100644 --- a/src/path.rs +++ b/src/path.rs @@ -667,7 +667,7 @@ fn make_base_directory(xdg_var: &wstr, non_xdg_homepath: &wstr) -> BaseDirectory let mut remoteness = DirRemoteness::unknown; if path.is_empty() { err = ENOENT; - } else if let Err(io_error) = std::fs::create_dir_all(wcs2osstring(&path)) { + } else if let Err(io_error) = create_dir_all_with_mode(wcs2osstring(&path), 0o700) { err = io_error.raw_os_error().unwrap_or_default(); } else { err = 0; @@ -685,6 +685,15 @@ fn make_base_directory(xdg_var: &wstr, non_xdg_homepath: &wstr) -> BaseDirectory } } +// Like std::fs::create_dir_all, but new directories are created using the given mode (e.g. 0o700). +fn create_dir_all_with_mode>(path: P, mode: u32) -> std::io::Result<()> { + use std::os::unix::fs::DirBuilderExt; + std::fs::DirBuilder::new() + .recursive(true) + .mode(mode) + .create(path.as_ref()) +} + /// Return whether the given path is on a remote filesystem. fn path_remoteness(path: &wstr) -> DirRemoteness { let narrow = wcs2zstring(path); diff --git a/tests/checks/create-base-directories.fish b/tests/checks/create-base-directories.fish new file mode 100644 index 000000000..1dc97891d --- /dev/null +++ b/tests/checks/create-base-directories.fish @@ -0,0 +1,16 @@ +#RUN: %fish -C 'set -l fish %fish' %s + +# Set a XDG_CONFIG_HOME with both pre-existing and non-existing directories. +set -l dir (mktemp -d) +mkdir -m 0755 $dir/old +set -gx XDG_CONFIG_HOME $dir/old/new + +# Launch fish so it will create all missing directories. +$fish -c '' + +# Check that existing directories kept their permissions, and new directories +# have the right permissions according to the XDG Base Directory Specification. +ls -ld $dir/old $dir/old/new $dir/old/new/fish | awk '{print $1}' +# CHECK: drwxr-xr-x +# CHECK: drwx------ +# CHECK: drwx------ From 5f76fc3e414d39a554402250bfc5af500e0190fa Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 29 Dec 2024 13:37:28 +0100 Subject: [PATCH 015/113] Add `status buildinfo` (#10896) This can be used to get some information on how fish was built - the version, the build system, the operating system and architecture, the features. (cherry picked from commit 6f9ca42a30ee982026958290fe24695131db5dc4) --- build.rs | 5 ++++ cmake/Rust.cmake | 2 ++ doc_src/cmds/status.rst | 5 ++++ src/builtins/status.rs | 46 ++++++++++++++++++++++++++++++++++++- tests/checks/buildinfo.fish | 15 ++++++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 tests/checks/buildinfo.fish diff --git a/build.rs b/build.rs index 04da46d50..6d6bdff4d 100644 --- a/build.rs +++ b/build.rs @@ -29,6 +29,11 @@ fn main() { .unwrap(), ); + // Some build info + rsconf::set_env_value("BUILD_TARGET_TRIPLE", &env::var("TARGET").unwrap()); + rsconf::set_env_value("BUILD_HOST_TRIPLE", &env::var("HOST").unwrap()); + rsconf::set_env_value("BUILD_PROFILE", &env::var("PROFILE").unwrap()); + let version = &get_version(&env::current_dir().unwrap()); // Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script, // the source directory is the current working directory of the build script diff --git a/cmake/Rust.cmake b/cmake/Rust.cmake index 82102fc3f..40887be45 100644 --- a/cmake/Rust.cmake +++ b/cmake/Rust.cmake @@ -49,6 +49,8 @@ set(VARS_FOR_CARGO "PREFIX=${CMAKE_INSTALL_PREFIX}" # Temporary hack to propogate CMake flags/options to build.rs. "CMAKE_WITH_GETTEXT=${CMAKE_WITH_GETTEXT}" + # Cheesy so we can tell cmake was used to build + "CMAKE=1" "DOCDIR=${CMAKE_INSTALL_FULL_DOCDIR}" "DATADIR=${CMAKE_INSTALL_FULL_DATADIR}" "SYSCONFDIR=${CMAKE_INSTALL_FULL_SYSCONFDIR}" diff --git a/doc_src/cmds/status.rst b/doc_src/cmds/status.rst index 825dc960b..f85df7c61 100644 --- a/doc_src/cmds/status.rst +++ b/doc_src/cmds/status.rst @@ -29,6 +29,7 @@ Synopsis status job-control CONTROL_TYPE status features status test-feature FEATURE + status buildinfo Description ----------- @@ -97,6 +98,10 @@ The following operations (subcommands) are available: **test-feature** *FEATURE* Returns 0 when FEATURE is enabled, 1 if it is disabled, and 2 if it is not recognized. +**buildinfo** + This prints information on how fish was build - which architecture, which build system or profile was used, etc. + This is mainly useful for debugging. + Notes ----- diff --git a/src/builtins/status.rs b/src/builtins/status.rs index f0b0ba107..e20f5678b 100644 --- a/src/builtins/status.rs +++ b/src/builtins/status.rs @@ -57,12 +57,14 @@ enum StatusCmd { STATUS_STACK_TRACE, STATUS_TEST_FEATURE, STATUS_CURRENT_COMMANDLINE, + STATUS_BUILDINFO, } str_enum!( StatusCmd, (STATUS_BASENAME, "basename"), (STATUS_BASENAME, "current-basename"), + (STATUS_BUILDINFO, "buildinfo"), (STATUS_CURRENT_CMD, "current-command"), (STATUS_CURRENT_COMMANDLINE, "current-commandline"), (STATUS_DIRNAME, "current-dirname"), @@ -420,6 +422,45 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O } return retval; } + STATUS_BUILDINFO => { + let version = str2wcstring(crate::BUILD_VERSION.as_bytes()); + let target = str2wcstring(env!("BUILD_TARGET_TRIPLE").as_bytes()); + let host = str2wcstring(env!("BUILD_HOST_TRIPLE").as_bytes()); + let profile = str2wcstring(env!("BUILD_PROFILE").as_bytes()); + streams.out.append(L!("Build system: ")); + let buildsystem = match option_env!("CMAKE") { + Some("1") => "CMake", + _ => "Cargo", + }; + streams.out.appendln(str2wcstring(buildsystem.as_bytes())); + streams.out.append(L!("Version: ")); + streams.out.appendln(version); + if target == host { + streams.out.append(L!("Target (and host): ")); + streams.out.appendln(target); + } else { + streams.out.append(L!("Target: ")); + streams.out.appendln(target); + streams.out.append(L!("Host: ")); + streams.out.appendln(host); + } + streams.out.append(L!("Profile: ")); + streams.out.appendln(profile); + streams.out.append(L!("Features: ")); + let features: &[&str] = &[ + #[cfg(gettext)] + "gettext", + #[cfg(feature = "installable")] + "installable", + #[cfg(target_feature = "crt-static")] + "crt-static", + ]; + streams + .out + .appendln(str2wcstring(features.join(" ").as_bytes())); + streams.out.appendln(""); + return STATUS_CMD_OK; + } ref s => { if !args.is_empty() { streams.err.append(wgettext_fmt!( @@ -558,7 +599,10 @@ pub fn status(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) -> O streams.out.appendln(path); } } - STATUS_SET_JOB_CONTROL | STATUS_FEATURES | STATUS_TEST_FEATURE => { + STATUS_BUILDINFO + | STATUS_SET_JOB_CONTROL + | STATUS_FEATURES + | STATUS_TEST_FEATURE => { unreachable!("") } } diff --git a/tests/checks/buildinfo.fish b/tests/checks/buildinfo.fish new file mode 100644 index 000000000..48b938549 --- /dev/null +++ b/tests/checks/buildinfo.fish @@ -0,0 +1,15 @@ +#RUN: %fish %s +# Example output: +# Build system: CMake +# Version: 3.7.1-2573-gea8301631-dirty +# Target (and host): x86_64-unknown-linux-gnu +# Profile: release +# Features: gettext + +status buildinfo | grep -v 'Host:' +# CHECK: Build system: {{CMake|Cargo}} +# CHECK: Version: {{.+}} +# (this could be "Target (and Host)" or "Target:" and a separate line "Host:") +# CHECK: Target{{.*}}: {{.+}} +# CHECK: Profile: {{release|debug}} +# CHECK: Features:{{.*}} From 2f99a8270019db845dfebbd587efc290fc87e689 Mon Sep 17 00:00:00 2001 From: Grant Hutchins Date: Sun, 29 Dec 2024 11:16:22 -0600 Subject: [PATCH 016/113] Improve documentation for `string escape` Before, it unnecessarily stated that there are three `--style` options, when there are actually four. I also align the default `--style=script` argument to the beginning of the line to match the other options visually for easier scanning. --- doc_src/cmds/string-escape.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc_src/cmds/string-escape.rst b/doc_src/cmds/string-escape.rst index ba9bc250b..ec83e4424 100644 --- a/doc_src/cmds/string-escape.rst +++ b/doc_src/cmds/string-escape.rst @@ -18,7 +18,9 @@ Description .. BEGIN DESCRIPTION -``string escape`` escapes each *STRING* in one of three ways. The first is **--style=script**. This is the default. It alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If **-n** or **--no-quoted** is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise. +``string escape`` escapes each *STRING* in one of several ways. + +**--style=script** (default) alters the string such that it can be passed back to ``eval`` to produce the original argument again. By default, all special characters are escaped, and quotes are used to simplify the output when possible. If **-n** or **--no-quoted** is given, the simplifying quoted format is not used. Exit status: 0 if at least one string was escaped, or 1 otherwise. **--style=var** ensures the string can be used as a variable name by hex encoding any non-alphanumeric characters. The string is first converted to UTF-8 before being encoded. From 57a7920e15bea100c92a9b88b00e0f6f26833f87 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 31 Dec 2024 14:35:55 +0100 Subject: [PATCH 017/113] CHANGELOG since 4.0b1 --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index bebb5ba10..b94c7bf4a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -3,9 +3,16 @@ Changes since 4.0b1 - :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. :issue:`10928` - Fix a BSD-specific regression in the beta that caused crashes when a child process exited with a status like -1 (:issue:`10919`). - Fix a regression in the beta where ``__fish_cancel_commandline`` caused glitches on multi-line command lines (:issue:`10935`). +- Autosuggestions are case-correcting again (:issue:`10915`). - Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: fish --install=$HOME/.local/ In that case, the fish binary will be moved to "bin/" in that path. :issue:`10923` +- The config directories will now be created with mode 700 again (:issue:`10962`). +- A ``status buildinfo`` command to print information on how fish was built, to help with debugging (:issue:`10896`). +- Remove the completions for ``dust`` because it conflicted with the Debian/Ubuntu package (:issue:`10922`). +- Improve the documentation style for narrow interfaces (like phones) (:issue:`10942`). +- Add debug information back to cmake builds with the "RelWithDebInfo" profile (:issue:`10959`). + fish 4.0b1 (released December 17, 2024) ======================================= From dd333cdc821d870660e93f0243faabe33e1edbfa Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 29 Dec 2024 06:37:21 -0800 Subject: [PATCH 018/113] completions/tmux: add skeleton "Windows and Panes" bindings (#10854) These are quite mechanical, but include all the commands (as of tmux 3.5a) in the "Windows and Panes" section of `man tmux`. For these commands, I included the target-pane/session/client/window flags and the -F formatstring flags (but not the less generic flags specific to individual commands). Nice completion is implemented for those flags where the helper functions were already implemented previously. After this, tmux pane will hopefully be useful. A few TODOs mention low-hanging fruit for somebody who better understands fish's `complete` command syntax (or a future me). Another piece of low-hanging fruit would be completion for all the target-window flags. This PR merely lists them. (cherry picked from commit b1064ac3a0884ea6e2e2ee3535c461b190df9fdf) --- share/completions/tmux.fish | 110 ++++++++++++++++++++++++++++++++++-- 1 file changed, 106 insertions(+), 4 deletions(-) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index 9ae15627d..16a93b256 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -94,6 +94,8 @@ complete -c tmux -n __fish_use_subcommand -a $rename -d 'rename session' complete -c tmux -n __fish_use_subcommand -a $showmsgs -d 'save msgs in status bar in per-client msg log' complete -c tmux -n __fish_use_subcommand -a $source -d 'execute commands from path' +complete -c tmux -n "__fish_seen_subcommand_from $source" -F + complete -c tmux -n __fish_use_subcommand -a $start -d 'start tmux server if not running; do not create a session' complete -c tmux -n __fish_use_subcommand -a $suspendc -d 'send SIGTSTP signal to client (tty stop)' @@ -113,14 +115,114 @@ complete -c tmux -xs t -n "__fish_seen_subcommand_from $detach $lockc $refresh $ complete -c tmux -xs c -n "__fish_seen_subcommand_from $switchc" -a '(__fish_tmux_clients)' -d target-client #commands with the -F format flag -complete -c tmux -n "__fish_seen_subcommand_from $lsc $ls" -rs F -d 'format string' +complete -c tmux -n "__fish_seen_subcommand_from $lsc $ls" -xs F -d 'format string' ############### End: Clients and Sessions ############### ############### Begin: Windows and Panes ############### -#TODO - these commands are not currently implemented. -#there is a section in the tmux man page that has the same title as this section -#use the "Clients and Sessions" code as an example when implementing this + +set -l breakp "break-pane breakp" +set -l capturep "capture-pane capturep" +set -l chooseclient choose-client +set -l choosetree choose-tree +set -l customizemode customize-mode +set -l displayp "display-panes displayp" +set -l findw "find-window findw" +set -l joinp "join-pane joinp move-pane movep" +set -l killp "kill-pane killp" +set -l killw "kill-window killw" +set -l lastp "last-pane lastp" +set -l lastw "last-window lastw" +set -l linkw "link-window linkw" +set -l lsp "list-panes lsp" +set -l lsw "list-windows lsw" +set -l movew "move-window movew" +set -l neww "new-window neww" +set -l nextl "next-layout nextl" +set -l next "next-window next" +set -l pipep "pipe-pane pipep" +set -l prevl "previous-layout prevl" +set -l prev "previous-window prev" +set -l renamew "rename-window renamew" +set -l resizep "resize-pane resizep" +set -l resizew "resize-window resizew" +set -l respawnp "respawn-pane respawnp" +set -l respawnw "respawn-window respawnw" +set -l rotatew "rotate-window rotatew" +set -l selectl "select-layout selectl" +set -l selectp "select-pane selectp" +set -l selectw "select-window selectw" +set -l splitw "split-window splitw" +set -l swapp "swap-pane swapp" +set -l swapw "swap-window swapw" +set -l unlinkw "unlink-window unlinkw" + +complete -c tmux -n __fish_use_subcommand -a $breakp -d 'break pane off into a new window' +complete -c tmux -n __fish_use_subcommand -a $capturep -d 'capture contents of a pane into a buffer' +complete -c tmux -n __fish_use_subcommand -a $chooseclient -d 'interactively choose client' +complete -c tmux -n __fish_use_subcommand -a $choosetree -d 'interactively choose session/window/pane' +complete -c tmux -n __fish_use_subcommand -a $customizemode -d 'interactively customize settings' +complete -c tmux -n __fish_use_subcommand -a $displayp -d 'display a visible indicator for each pane' +complete -c tmux -n __fish_use_subcommand -a $findw -d 'interactively choose window matching pattern' +complete -c tmux -n __fish_use_subcommand -a $joinp -d 'split destination pane and move source pane into one of the halves' +complete -c tmux -n __fish_use_subcommand -a $killp -d 'destroy a pane' +complete -c tmux -n __fish_use_subcommand -a $killw -d 'destroy a window' +complete -c tmux -n __fish_use_subcommand -a $lastp -d 'select the previusly selected pane' +complete -c tmux -n __fish_use_subcommand -a $lastw -d 'select the previusly selected window' +complete -c tmux -n __fish_use_subcommand -a $linkw -d 'link source window to destination window' +complete -c tmux -n __fish_use_subcommand -a $lsp -d 'list panes' +complete -c tmux -n __fish_use_subcommand -a $lsw -d 'list windows' +complete -c tmux -n __fish_use_subcommand -a $movew -d 'move window' +# TODO: Should accept shell command +complete -c tmux -n __fish_use_subcommand -a $neww -d 'create a new window' +complete -c tmux -n __fish_use_subcommand -a $nextl -d 'rearrange panes in a window according to the next layout' +complete -c tmux -n __fish_use_subcommand -a $next -d 'move to the next window in the session' +# TODO: Should accept shell command +complete -c tmux -n __fish_use_subcommand -a $pipep -d 'pipe output from pane to a shell command' +complete -c tmux -n __fish_use_subcommand -a $prevl -d 'rearrange panes in a window according to the previous layout' +complete -c tmux -n __fish_use_subcommand -a $prev -d 'move to the previous window in the session' +complete -c tmux -n __fish_use_subcommand -a $renamew -d 'rename a window' +complete -c tmux -n __fish_use_subcommand -a $resizep -d 'resize a pane' +complete -c tmux -n __fish_use_subcommand -a $resizew -d 'resize a window' +# TODO: Should accept shell command +complete -c tmux -n __fish_use_subcommand -a $respawnp -d 'reactivate a pane where a command exited' +# TODO: Should accept shell command +complete -c tmux -n __fish_use_subcommand -a $respawnw -d 'reactivate a window where a command exited' +complete -c tmux -n __fish_use_subcommand -a $rotatew -d 'rotate panes within a window' + +complete -c tmux -n __fish_use_subcommand -a $selectl -d 'rearrange panes according to a given layout' +set -l layouts 'even-horizontal even-vertical main-horizontal main-horizontal-mirrored main-vertical main-vertical-mirrored tiled' +complete -c tmux -n "__fish_seen_subcommand_from $selectl" -x -a "$layouts" -d 'predefined layout' + +complete -c tmux -n __fish_use_subcommand -a $selectp -d 'activate specific pane' +complete -c tmux -n __fish_use_subcommand -a $selectw -d 'activate specific window' +# TODO: Should accept shell command +complete -c tmux -n __fish_use_subcommand -a $splitw -d 'create a new pane by splitting target-pane' +complete -c tmux -n __fish_use_subcommand -a $swapp -d 'swap two panes' +complete -c tmux -n __fish_use_subcommand -a $swapw -d 'swap two windows' +complete -c tmux -n __fish_use_subcommand -a $unlinkw -d 'unlink target-window' + +## commands with pane flag +complete -c tmux -n "__fish_seen_subcommand_from $breakp $joinp $swapp" -xs s -a '(__fish_tmux_panes)' -d 'source pane' +complete -c tmux -n "__fish_seen_subcommand_from $capturep $chooseclient $choosetree $customizemode $findw" -xs t -a '(__fish_tmux_panes)' -d 'target pane' +complete -c tmux -n "__fish_seen_subcommand_from $killp $pipep $resizep $respawnp $selectl $selectp $splitw" -xs t -a '(__fish_tmux_panes)' -d 'target pane' +# Unclear if there's a meaningful difference between "target pane" and "destination pane", but tmux makes the distinction +complete -c tmux -n "__fish_seen_subcommand_from $joinp $swapp" -xs t -a '(__fish_tmux_panes)' -d 'destination pane' + +## commands with session flag +complete -c tmux -n "__fish_seen_subcommand_from $lastw $lsw $next $prev" -xs t -a '(__fish_tmux_sessions)' -d 'target session' + +## commands with the -F format flag +complete -c tmux -n "__fish_seen_subcommand_from $breakp $lsp $lsw $neww $chooseclient $choosetree" -xs F -d 'format string' + +## commands with -s/-t flags that are not panes/sessions (nice completion not yet implemented) +complete -c tmux -n "__fish_seen_subcommand_from $linkw $movew $swapw" -xs s -d 'source window' +complete -c tmux -n "__fish_seen_subcommand_from $breakp $linkw $movew $neww $swapw" -xs t -d 'destination window' +complete -c tmux -n "__fish_seen_subcommand_from $killw $lastp $nextl $prevl $renamew" -xs t -d 'target window' +complete -c tmux -n "__fish_seen_subcommand_from $resizew $reswpawnw $rotatew $selectw $unlinkw" -xs t -d 'target window' +complete -c tmux -n "__fish_seen_subcommand_from $displayp" -xs t -d 'target client' +complete -c tmux -n "__fish_seen_subcommand_from $lsp" -xs t -d 'target' + ############### End: Windows and Panes ############### ############### Begin: Key Bindings ############### From d2608588fce17a7e31280f070620563fc70d63a0 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Sun, 29 Dec 2024 15:33:29 +0100 Subject: [PATCH 019/113] add completion for btrbk (#10752) * add completion for btrbk completions for btrbk https://github.com/digint/btrbk/ * change indent + spaces (cherry picked from commit 2ac1523e54307fa7207b094e513e3167d38c92fa) --- share/completions/btrbk.fish | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 share/completions/btrbk.fish diff --git a/share/completions/btrbk.fish b/share/completions/btrbk.fish new file mode 100644 index 000000000..d27672b64 --- /dev/null +++ b/share/completions/btrbk.fish @@ -0,0 +1,62 @@ +# Filter Completion +function __fish_btrbk_complete_filter + btrbk list config --format col:h:snapshot_name,source_subvolume,target_url | string replace -r '([^ ]+)\s+([^ ]+)\s+([^ ]*)' '$1\t$2 -> $3' +end + +# options with arguments +complete -c btrbk -l format -x -d 'Change output format' -a "table long raw" +complete -c btrbk -l loglevel -s l -x -d 'Set logging level' -a "error warn info debug trace" +complete -c btrbk -l exclude -x -d 'Exclude configured sections' -a "(__fish_btrbk_complete_filter)" +complete -c btrbk -l override -x -d 'Globally override a configuration option' + +# options with file completion +complete -c btrbk -l config -r -s c -d 'Specify configuration file' +complete -c btrbk -l lockfile -r -d 'Create and check lockfile' + +# options without arguments +complete -c btrbk -l help -s h -d 'Display this help message' +complete -c btrbk -l version -d 'Display version information' +complete -c btrbk -l dry-run -s n -d 'Perform a trial run with no changes made' +complete -c btrbk -l preserve -s p -d 'Preserve all (do not delete anything)' +complete -c btrbk -l preserve-snapshots -d 'Preserve snapshots (do not delete snapshots)' +complete -c btrbk -l preserve-backups -d 'Preserve backups (do not delete backups)' +complete -c btrbk -l wipe -d 'Delete all but latest snapshots' +complete -c btrbk -l verbose -s v -d 'Be more verbose (increase logging level)' +complete -c btrbk -l quiet -s q -d 'Be quiet (do not print backup summary)' +complete -c btrbk -l table -s t -d 'Change output to table format' +complete -c btrbk -l long -s L -d 'Change output to long format' +complete -c btrbk -l print-schedule -s S -d 'Print scheduler details (for the "run" command)' +complete -c btrbk -l progress -d 'Show progress bar on send-receive operation' + +# uncommon options from manpage +complete -c btrbk -l single-column -s 1 -d 'Print output as a single column' +complete -c btrbk -l pretty -d 'Print pretty table output with lowercase and underlined column headings' +complete -c btrbk -l raw -d 'Create raw targets for archive command' + +# subcommands +complete -c btrbk -f -n __fish_use_subcommand -a run -d 'Run snapshot and backup operations' +complete -c btrbk -f -n __fish_use_subcommand -a dryrun -d 'Show what would be executed without running btrfs commands' +complete -c btrbk -f -n __fish_use_subcommand -a snapshot -d 'Run snapshot operations only' +complete -c btrbk -f -n __fish_use_subcommand -a resume -d 'Run backup operations and delete snapshots' +complete -c btrbk -f -n __fish_use_subcommand -a prune -d 'Only delete snapshots and backups' +complete -c btrbk -f -n __fish_use_subcommand -a archive -d 'Recursively copy all subvolumes (src -> dst)' +complete -c btrbk -f -n __fish_use_subcommand -a clean -d 'Delete incomplete (garbled) backups' +complete -c btrbk -f -n __fish_use_subcommand -a stats -d 'Print snapshot/backup statistics' +complete -c btrbk -f -n __fish_use_subcommand -a usage -d 'Print filesystem usage' +complete -c btrbk -f -n __fish_use_subcommand -a ls -d 'List all btrfs subvolumes below a given path' +complete -c btrbk -f -n __fish_use_subcommand -a origin -d 'Print origin information for a subvolume' +complete -c btrbk -f -n __fish_use_subcommand -a diff -d 'List file changes between related subvolumes' +complete -c btrbk -f -n __fish_use_subcommand -a extents -d 'Calculate accurate disk space usage for a path' +complete -c btrbk -f -n __fish_use_subcommand -a list -d 'List snapshots and backups' + +# subsubcommands for "list" +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a all -d 'List all snapshots and backups' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a snapshots -d 'List snapshots only' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a backups -d 'List backups and correlated snapshots' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a latest -d 'List most recent snapshots and backups' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a config -d 'List configured source/snapshot/target relations' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a source -d 'List configured source/snapshot relations' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a volume -d 'List configured volume sections' +complete -c btrbk -n '__fish_seen_subcommand_from list' -f -a target -d 'List configured targets' + +complete -c btrbk -n '__fish_seen_subcommand_from run dryrun snapshot resume prune clean' -x -a '(__fish_btrbk_complete_filter)' From c28659a0456dae45c84e4ef2affe12520bec2b89 Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Wed, 16 Oct 2024 05:20:22 +1000 Subject: [PATCH 020/113] feat(completion): support folderify command (cherry picked from commit d8d5913159e3d1175c5764e924273203b28c8786) --- share/completions/folderify.fish | 1 + 1 file changed, 1 insertion(+) create mode 100644 share/completions/folderify.fish diff --git a/share/completions/folderify.fish b/share/completions/folderify.fish new file mode 100644 index 000000000..cc53afd17 --- /dev/null +++ b/share/completions/folderify.fish @@ -0,0 +1 @@ +folderify --completions fish | source From 550a076fa33a3ed1a10e62d13d90690f6de085d2 Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Wed, 16 Oct 2024 05:32:56 +1000 Subject: [PATCH 021/113] feat(completion) support batsh command (cherry picked from commit 1bda6043c8cccc1d76f702f0fd2107b2fef002af) --- share/completions/batsh.fish | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 share/completions/batsh.fish diff --git a/share/completions/batsh.fish b/share/completions/batsh.fish new file mode 100644 index 000000000..b3aefe661 --- /dev/null +++ b/share/completions/batsh.fish @@ -0,0 +1,12 @@ +set -l command batsh + +complete -c $command -f + +complete -c $command -s h -l help \ + -a 'pager\tdefault plain groff' \ + -d 'Show help' + +complete -c $command -s v -l version -d 'Show version' + +complete -c $command \ + -a 'bash\t"Compile to Bash" batsh\t"Format file" winbat\t"Compile to Batch"' From 6749a44d0fee93cc577ce316743023abcd4cf2b7 Mon Sep 17 00:00:00 2001 From: Klaus Hipp Date: Tue, 17 Dec 2024 18:35:03 +0100 Subject: [PATCH 022/113] Update `code` completions (cherry picked from commit 2b46d97c682e831a058fcbe4b2e70ff2531ea7e6) --- share/completions/code.fish | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/share/completions/code.fish b/share/completions/code.fish index 9d356e3cc..ad58eee0b 100644 --- a/share/completions/code.fish +++ b/share/completions/code.fish @@ -16,14 +16,12 @@ complete -c code -l user-data-dir -ra "(__fish_complete_directories)" -d 'Specif complete -c code -l profile -d 'Opens the provided folder or workspace with the given profile' complete -c code -s v -l version -d 'Print version' complete -c code -s h -l help -d 'Print usage' -complete -c code -l folder-uri -d 'Opens a window with given folder uri(s)' -complete -c code -l file-uri -d 'Opens a window with given file uri(s)' # Extensions management -complete -c code -l extensions-dir -d 'Set the root path for extensions' +complete -c code -l extensions-dir -r -d 'Set the root path for extensions' complete -c code -l list-extensions -d 'List the installed extensions' complete -c code -l show-versions -d 'Show versions of installed extensions' -n '__fish_seen_argument -l list-extensions' -complete -c code -l category -d 'Filters installed extensions by provided category' -n '__fish_seen_argument -l list-extensions' +complete -c code -l category -x -d 'Filters installed extensions by provided category' -n '__fish_seen_argument -l list-extensions' complete -c code -l install-extension -ra "(__fish_complete_vscode_extensions)" -d 'Installs or updates the extension' complete -c code -l force -n '__fish_seen_argument -l install-extension' -d 'Updates to the latest version' complete -c code -l pre-release -n '__fish_seen_argument -l install-extension' -d 'Installs the pre-release version' @@ -35,12 +33,13 @@ complete -c code -l disable-extensions -d 'Disable all installed extensions' # Troubleshooting complete -c code -l verbose -d 'Print verbose output (implies --wait)' -complete -c code -l log -a 'critical error warn info debug trace off' -d 'Log level to use (default: info)' +complete -c code -l log -xa 'critical error warn info debug trace off' -d 'Log level to use (default: info)' complete -c code -s s -l status -d 'Print process usage and diagnostics information' complete -c code -l prof-startup -d 'Run CPU profiler during startup' -complete -c code -l sync -d 'Turn sync on or off' -complete -c code -l inspect-extensions -d 'Allow debugging and profiling of extensions' +complete -c code -l sync -xa 'on off' -d 'Turn sync on or off' +complete -c code -l inspect-extensions -x -d 'Allow debugging and profiling of extensions' complete -c code -l inspect-brk-extensions -x -d 'Allow debugging and profiling of extensions' +complete -c code -l disable-lcd-text -d 'Disable LCD font rendering' complete -c code -l disable-gpu -d 'Disable GPU hardware acceleration' complete -c code -l disable-chromium-sandbox -d 'Disable the Chromium sandbox environment' complete -c code -l telemetry -d 'Shows all telemetry events which VS code collects' From ff8a879e8072fd471dd360dc599a7d3e6ccf6c00 Mon Sep 17 00:00:00 2001 From: Alexei Mikhailov Date: Sun, 29 Dec 2024 23:02:43 +0200 Subject: [PATCH 023/113] completions/exercism: use generate script Exercism ships with it's own completions and a generation script, so let's use that one instead. (cherry picked from commit 9b26fff278a4cbc98e14884c2449ffd16cffd256) --- share/completions/exercism.fish | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/share/completions/exercism.fish b/share/completions/exercism.fish index adec3bfdd..1e9ab5bb9 100644 --- a/share/completions/exercism.fish +++ b/share/completions/exercism.fish @@ -1,26 +1 @@ -function __fish_exercism_no_subcommand -d 'Test if exercism has yet to be given the subcommand' - for i in (commandline -xpc) - if contains -- $i demo debug configure fetch restore submit unsubmit tracks download help - return 1 - end - end - return 0 -end - -complete -c exercism -s c -l config -d 'path to config file [$EXERCISM_CONFIG_FILE, $XDG_CONFIG_HOME]' -complete -c exercism -s v -l verbose -d "turn on verbose logging" -complete -c exercism -s h -l help -d "show help" -complete -c exercism -s v -l version -d "print the version" -complete -f -n __fish_exercism_no_subcommand -c exercism -a configure -d "Writes config values to a JSON file" -complete -f -n __fish_exercism_no_subcommand -c exercism -a debug -d "Outputs useful debug information" -complete -f -n __fish_exercism_no_subcommand -c exercism -a download -d "Downloads a solution given the ID of the latest iteration" -complete -f -n __fish_exercism_no_subcommand -c exercism -a fetch -d "Fetches the next unsubmitted problem in each track" -complete -f -n __fish_exercism_no_subcommand -c exercism -a list -d "Lists the available problems for a language track, given its ID" -complete -f -n __fish_exercism_no_subcommand -c exercism -a open -d "Opens exercism.io on given problem" -complete -f -n __fish_exercism_no_subcommand -c exercism -a restore -d "Downloads the most recent iteration for each of your solutions on exercism.io" -complete -f -n __fish_exercism_no_subcommand -c exercism -a skip -d "Skips a problem given a track ID and problem slug" -complete -f -n __fish_exercism_no_subcommand -c exercism -a status -d "Fetches information about your progress with a given language track" -complete -f -n __fish_exercism_no_subcommand -c exercism -a submit -d "Submits a new iteration to a problem on exercism.io" -complete -f -n __fish_exercism_no_subcommand -c exercism -a tracks -d "Lists the available language tracks" -complete -f -n __fish_exercism_no_subcommand -c exercism -a upgrade -d "Upgrades the CLI to the latest released version" -complete -f -n __fish_exercism_no_subcommand -c exercism -a help -d "show help" +exercism completion fish | source From 5845a3f7ad42ff5a9342529e9b3b26e61b45fa3f Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 30 Dec 2024 20:59:38 +0100 Subject: [PATCH 024/113] __fish_complete_subcommand: Just complete -C for a given commandline Fixes #10980. This would, if a commandline was given, still revert to checking the *real* commandline if it was empty. Unfortunately, in those cases, it could have found a command and tried to complete it. If a commandline is given, that is what needs to be completed. (note this means this is basically useless in completions that use it like `sudo` and could just be replaced with `complete -C"$commandline"`) (cherry picked from commit d5efef1cc52091066f93843dad52b472738c62f7) --- .../functions/__fish_complete_subcommand.fish | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index a5a05b150..f531d1f53 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -10,34 +10,31 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin case '--fcs-skip=*' set skip_next (string split = -- $arg)[2] case --commandline # --commandline means to use our arguments instead of the commandline. - set subcommand $argv - set -e argv - break + complete -C "$argv" + return end end set -l options_with_param $argv - if not string length -q -- $subcommand - set -l cmd (commandline -cxp | string escape) (commandline -ct) - while set -q cmd[1] - set -l token $cmd[1] - set -e cmd[1] - if contains -- $token $options_with_param - set skip_next (math $skip_next + 1) + set -l cmd (commandline -cxp | string escape) (commandline -ct) + while set -q cmd[1] + set -l token $cmd[1] + set -e cmd[1] + if contains -- $token $options_with_param + set skip_next (math $skip_next + 1) + continue + end + switch $token + case '-*' '*=*' continue - end - switch $token - case '-*' '*=*' + case '*' + if test $skip_next -gt 0 + set skip_next (math $skip_next - 1) continue - case '*' - if test $skip_next -gt 0 - set skip_next (math $skip_next - 1) - continue - end - # found the start of our command - set subcommand $token $cmd - break - end + end + # found the start of our command + set subcommand $token $cmd + break end end From e6e647092d29a364a6f8b0703cc487f705df9e33 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 30 Dec 2024 00:10:59 +0100 Subject: [PATCH 025/113] Fix off-by-one error in Vi-style upcase-word at commandline end cursor_selection_mode=inclusive means the commandline position is bounded by the last character. Fix a loop that fails to account for this. Fixes d51f669647 (Vi mode: avoid placing cursor beyond last character, 2024-02-14). This change looks very odd because if the commandline is like echo foo. it makes us try to uppercase the trailing period even though that's not part of word range. Hopefully this is harmless. Note that there seem to be more issues remaining, for example Vi-mode paste leaves the cursor in an out-of-bounds odd position. Fixes #10952 Closes #10953 Reported-by: Lzu Tao (cherry picked from commit 69f0d960cf69e4f390f41a47227389a2aac77237) --- src/reader.rs | 10 +++++++++- tests/pexpects/bind.py | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/reader.rs b/src/reader.rs index dcbd3bc25..fe118ae6b 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -3207,7 +3207,15 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { ); let (elt, el) = self.active_edit_line(); let mut replacement = WString::new(); - while pos < el.position() { + while pos + < if self.cursor_selection_mode == CursorSelectionMode::Inclusive + && self.is_at_end(el) + { + el.len() + } else { + el.position() + } + { let chr = el.text().as_char_slice()[pos]; // We always change the case; this decides whether we go uppercase (true) or diff --git a/tests/pexpects/bind.py b/tests/pexpects/bind.py index 75ef600cc..e9c939239 100644 --- a/tests/pexpects/bind.py +++ b/tests/pexpects/bind.py @@ -241,6 +241,12 @@ expect_prompt("foo") # send("hh~~bbve~\r") # expect_prompt("\r\n.*SOME TeXT\r\n", unmatched="Couldn't find expected output 'SOME TeXT") +send("echo echo") +send("\033") +sleep(0.200) +send("bgU\r") +expect_prompt("echo ECHO") + # Now test that exactly the expected bind modes are defined sendline("bind --list-modes") expect_prompt( From 7ea2ab4ebbd6b833d54d1010a5bfe5b1ff5ef790 Mon Sep 17 00:00:00 2001 From: Thayne McCombs Date: Sat, 4 Jan 2025 02:15:57 -0700 Subject: [PATCH 026/113] fix[completions]: Add set-timeout to bootctl (cherry picked from commit 33dd823f456f687f2d276aebbb3870b54730c241) --- share/completions/bootctl.fish | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/share/completions/bootctl.fish b/share/completions/bootctl.fish index 34309d2cd..73b67449a 100644 --- a/share/completions/bootctl.fish +++ b/share/completions/bootctl.fish @@ -1,4 +1,4 @@ -set -l commands status install update remove is-installed random-seed systemd-efi-options reboot-to-firmware list set-default set-oneshot +set -l commands status install update remove is-installed random-seed systemd-efi-options reboot-to-firmware list set-default set-oneshot set-timeout set-timeout-oneshot complete -c bootctl -f complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a status -d 'Show status of EFI variables' @@ -13,6 +13,8 @@ complete -c bootctl -n "__fish_seen_subcommand_from reboot-to-firmware" -a 'true complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a list -d 'List boot loader entries' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-default -d 'Set default boot loader entry' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-oneshot -d 'Set default boot loader entry (Once)' +complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout -d 'Set default boot loader timeout' +complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout-oneshot -d 'Set default boot loader timeout (Once)' complete -c bootctl -s h -l help -d 'Show this help' complete -c bootctl -l version -d 'Print version' From 566ff38feeddda3fe2200cc38524217f0996554e Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 23 Dec 2024 21:08:11 +0100 Subject: [PATCH 027/113] Mention lack of support for ctrl-backspace and alternatives Closes #10936 (cherry picked from commit cde503b0a8ec47d234ec36786d7118f7c7403d20) --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b94c7bf4a..d60830e31 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -34,7 +34,7 @@ Notable backwards-incompatible changes - Terminals that fail to ignore unrecognized OSC or CSI sequences may display garbage. We know cool-retro-term and emacs' ansi-term are affected, most mainstream terminals are not. - :kbd:`alt-left` and :kbd:`alt-right` will now move by one argument (which may contain quoted spaces), not just one word like :kbd:`ctrl-left` and :kbd:`ctrl-right` do. -- :kbd:`alt-backspace` will delete an entire argument, not just one word (which is :kbd:`ctrl-backspace` now). +- :kbd:`alt-backspace` will delete an entire argument, not just one word. The old word behavior has been moved to :kbd:`ctrl-backspace`. If your terminal doesn't support `ctrl-backspace`, consider using :kbd:`ctrl-w`, or :kbd:`alt-b` + :kbd:`alt-d`. - ``random`` will produce different values from previous versions of fish when used with the same seed, and will work more sensibly with small seed numbers. The seed was never guaranteed to give the same result across systems, so we do not expect this to have a large impact (:issue:`9593`). From 24397c71cd6aca99e7a853559e714a0d7a793da9 Mon Sep 17 00:00:00 2001 From: idealseal Date: Wed, 25 Dec 2024 14:11:53 +0100 Subject: [PATCH 028/113] feat(comp): Update completion for md5sum (cherry picked from commit a780e4da15190ec2b9ea75e97636b3ef15cfc8c1) --- share/completions/md5sum.fish | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/share/completions/md5sum.fish b/share/completions/md5sum.fish index a759dfc39..e83ac637a 100644 --- a/share/completions/md5sum.fish +++ b/share/completions/md5sum.fish @@ -1,10 +1,13 @@ complete -c md5sum -d "Compute and check message digest" -r complete -c md5sum -s b -l binary -d 'Read in binary mode' complete -c md5sum -s c -l check -d "Read sums from files and check them" -complete -c md5sum -s t -l text -d 'Read in text mode' -complete -c md5sum -l quiet -d 'Don''t print OK for each successfully verified file' -complete -c md5sum -l status -d 'Don''t output anything, status code shows success' -complete -c md5sum -s w -l warn -d 'Warn about improperly formatted checksum lines' +complete -c md5sum -l tag -d 'Create a BSD-style checksum' +complete -c md5sum -s t -l text -d 'Read in text mode (default)' +complete -c md5sum -s z -l zero -d 'End each output line with NUL, not newline, and disable file name escaping' +complete -c md5sum -l ignore-missing -d 'Don\'t fail or report status for missing files' +complete -c md5sum -l quiet -d 'Don\'t print OK for each successfully verified file' +complete -c md5sum -l status -d 'Don\'t output anything, status code shows success' complete -c md5sum -l strict -d 'With --check, exit non-zero for any invalid input' +complete -c md5sum -s w -l warn -d 'Warn about improperly formatted checksum lines' complete -c md5sum -l help -d 'Display help text' complete -c md5sum -l version -d 'Output version information and exit' From a5f99afa47f1181b0802ceea40c4747dff53bbd0 Mon Sep 17 00:00:00 2001 From: idealseal Date: Wed, 25 Dec 2024 01:30:30 +0100 Subject: [PATCH 029/113] feat(comp): Update completions for resolvectl (cherry picked from commit 2e12a2b6c475a690235a562166362727f6bb6032) --- share/completions/resolvectl.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/completions/resolvectl.fish b/share/completions/resolvectl.fish index e5836358d..70fe83507 100644 --- a/share/completions/resolvectl.fish +++ b/share/completions/resolvectl.fish @@ -18,6 +18,7 @@ end function __resolvectl_commands printf "%b\n" "query\tResolve domain names or IP addresses" \ + "query\tResolve domain names, IPv4 and IPv6 addresses" \ "service\tResolve service records" \ "openpgp\tQuery PGP keys for email" \ "tlsa\tQuery TLS public keys" \ @@ -26,6 +27,9 @@ function __resolvectl_commands "reset-statistics\tReset statistics counters" \ "flush-caches\tFlush DNS RR caches" \ "reset-server-features\tFlushe all feature level information" \ + "monitor\tMonitor DNS queries" \ + "show-cache\tShow cache contents" \ + "show-server-state\tShow server state" \ "dns\tSet per-interface DNS servers" \ "domain\tSet per-interface search or routing domains" \ "default-route\tSet per-interface default route flag" \ From 046cadb53a0fa4eab1e68cabb91bbb6f78cd0b5f Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Fri, 27 Dec 2024 16:14:44 +0700 Subject: [PATCH 030/113] Add completion for gem-fetch (cherry picked from commit 7eb254f2bac0be4d2575ae085c44de0473fcb434) --- share/completions/gem.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/completions/gem.fish b/share/completions/gem.fish index d529c5282..a7f6621df 100644 --- a/share/completions/gem.fish +++ b/share/completions/gem.fish @@ -16,6 +16,7 @@ complete -c gem -n __fish_use_subcommand -xa cleanup -d "Cleanup old versions of complete -c gem -n __fish_use_subcommand -xa contents -d "Display the contents of the installed gems" complete -c gem -n __fish_use_subcommand -xa dependency -d "Show the dependencies of an installed gem" complete -c gem -n __fish_use_subcommand -xa environment -d "Display RubyGems environmental information" +complete -c gem -n __fish_use_subcommand -xa fetch -d "Download a gem into current directory" complete -c gem -n __fish_use_subcommand -xa help -d "Provide help on the 'gem' command" complete -c gem -n __fish_use_subcommand -xa install -d "Install a gem into the local repository" complete -c gem -n __fish_use_subcommand -xa list -d "Display all gems whose name starts with STRING" @@ -86,6 +87,9 @@ complete $dep_opt -s p -l pipe -d "Pipe Format (name --version ver)" set -l env_opt -c gem -n 'contains environment (commandline -pxc)' complete $env_opt -xa "packageversion\t'display the package version' gemdir\t'display the path where gems are installed' gempath\t'display path used to search for gems' version\t'display the gem format version' remotesources\t'display the remote gem servers'" +set -l fetch_opt -c gem -n 'contains fetch (commandline -pxc)' +complete $fetch_opt -s v -l version -d "Specify version of gem to download" -x + ## # help set -l help_opt -c gem -n 'contains help (commandline -pxc)' From 92919effc57a08d3bb2180ad055bfecfcacb6b9e Mon Sep 17 00:00:00 2001 From: David Adam Date: Sat, 4 Jan 2025 21:53:32 +0800 Subject: [PATCH 031/113] CHANGELOG: work on 4.0.0 --- CHANGELOG.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d60830e31..7a059d429 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -19,7 +19,7 @@ fish 4.0b1 (released December 17, 2024) These are the draft release notes for fish 4.0.0. Like this release of fish itself, they are in beta and are not complete. Please report any issues you find. -.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9751 9754 9765 9767 9768 9771 9777 9778 9786 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10707 10708 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10907 +.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9751 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10707 10708 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10899 10906 10907 10911 10913 10922 10923 10944 10945 10951 10971 10994 10995 10999 fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. @@ -163,6 +163,7 @@ Interactive improvements The color scheme will not be upgraded for existing installs. If you want, you should select it again via ``fish_config``. - Command lines which are larger than the terminal are now displayed correctly, instead of multiple blank lines being displayed (:issue:`7296`). - Prompts that use external commands will no longer produce an infinite loop if the command crashes (:issue:`9796`). +- Undo (:kbd:`ctrl-z`) restores the cursor position too (:issue:`10838`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -170,7 +171,9 @@ New or improved bindings - During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager. - :kbd:`shift-delete` will also remove the currently-displayed autosuggestion from history, and remove it as a suggestion. - :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo. +- :kbd:`alt-backspace` deletes the argument (including quoted spaces) left of the cursor. - :kbd:`alt-delete` now deletes the argument (which may contain quoted spaces) right of the cursor. +- :kbd:`alt-right` and :kbd:`alt-left` will skip over command line tokens in the command line. - Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor: - The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune. - Cursor position synchronization is only supported for a set of known editors, which are now also detected in aliases which use ``complete --wraps``. For example, use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``. @@ -185,7 +188,7 @@ New or improved bindings - :kbd:`ctrl-delete` deletes the next word (same as :kbd:`alt-d`). - New special input functions: - ``forward-char-passive`` and ``backward-char-passive`` are like their non-passive variants but do not accept autosuggestions or move focus in the completion pager (:issue:`10398`). - - ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token which includes escaped spaces (:issue:`2014`). + - ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token (which includes escaped spaces) (:issue:`2014`). - The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept (:issue:`10608`). - Vi mode has seen some improvements but continues to suffer from the lack of people working on it. - New default cursor shapes for insert and replace mode. @@ -213,6 +216,7 @@ Completions This matches Bash's behavior. - Various new completion scripts and numerous updates to existing ones. - Generated completions are now stored in ``$XDG_CACHE_HOME/fish`` or ``~/.cache/fish`` by default (:issue:`10369`) +- A regression in fish 3.1, where completing a command line could change it completely, has been fixed (:issue:`10904`). Improved terminal support ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -240,7 +244,7 @@ For distributors fish has been ported to Rust. This means a significant change in dependencies, which are listed in the README. In short, Rust 1.70 or greater is required, and a C++ compiler is no longer needed (although a C compiler is still required, for some C glue code and the tests). -CMake remains the recommended build system, because of cargo's limited support for installing support files. Version 3.5 remains the minimum supported version. The Xcode generator for CMake is not supported any longer (:issue:`9924`) +CMake remains the recommended build system, because of cargo's limited support for installing support files. Version 3.5 remains the minimum supported version. The Xcode generator for CMake is not supported any longer (:issue:`9924`). fish no longer depends on the ncurses library, but still uses a terminfo database. When packaging fish, please add a dependency on the package containing your terminfo database instead of curses. From 44a8344da1f0ad7f5ff8a2e07d7f374d75cd0047 Mon Sep 17 00:00:00 2001 From: cornmander Date: Sat, 4 Jan 2025 20:45:05 -0500 Subject: [PATCH 032/113] Add completions for Google Cloud commands. (#11005) The `gcloud` and `gsutil` Google Cloud commands use argcomplete, so integrating them is easy with the `__fish_argcomplete_complete` function. (cherry picked from commit d842a6560e7333c373ea26eae7ba230814300c86) --- share/completions/gcloud.fish | 1 + share/completions/gsutil.fish | 1 + 2 files changed, 2 insertions(+) create mode 100644 share/completions/gcloud.fish create mode 100644 share/completions/gsutil.fish diff --git a/share/completions/gcloud.fish b/share/completions/gcloud.fish new file mode 100644 index 000000000..85fd4a340 --- /dev/null +++ b/share/completions/gcloud.fish @@ -0,0 +1 @@ +complete -c gcloud -f -a '(__fish_argcomplete_complete gcloud)' diff --git a/share/completions/gsutil.fish b/share/completions/gsutil.fish new file mode 100644 index 000000000..72db7f093 --- /dev/null +++ b/share/completions/gsutil.fish @@ -0,0 +1 @@ +complete -c gsutil -f -a '(__fish_argcomplete_complete gsutil)' From 13f7e6d0a57fd78c566f40ebaca9ef53e972e222 Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 5 Jan 2025 22:27:00 +0800 Subject: [PATCH 033/113] docs/interactive: update key bindings added for 4.0 (cherry picked from commit 6c3150aa056f3f3c4316a0f130ae0f12850971a0) --- doc_src/interactive.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index b1761085e..b21381f35 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -327,8 +327,12 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`alt-d` or :kbd:`ctrl-delete` moves the next word to the :ref:`killring`. +- :kbd:`alt-d` lists the directory history if the command line is empty. + - :kbd:`alt-delete` moves the next argument to the :ref:`killring`. +- :kbd:`shift-delete` removes the current history item or autosuggestion from the command history. + - :kbd:`alt-h` (or :kbd:`f1`) shows the manual page for the current command, if one exists. - :kbd:`alt-l` lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed. @@ -382,7 +386,7 @@ To enable emacs mode, use :doc:`fish_default_key_bindings Date: Sun, 4 Aug 2024 02:55:04 +0700 Subject: [PATCH 034/113] Add more convenient key bindings for VI mode To make it more familiar to vi/vim users. In all mode, ctrl-k is bind to kill-line. In Vi visual mode: * press v or i turn into normal or insert mode respectively. * press I turn to insert mode and move the cursor to beginning of line. * because fish doesn't have upcase/locase-selection, and most people reach for g-U rather than g-u, g-U binds to togglecase-selection temporarily. (cherry picked from commit f9b79926f1a9aba7da9b6fb9076c764e127ae2ef) --- share/functions/__fish_shared_key_bindings.fish | 1 + share/functions/fish_vi_key_bindings.fish | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 13faef8ca..21febbeba 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -69,6 +69,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod bind --preset $argv ctrl-l clear-screen bind --preset $argv ctrl-c cancel-commandline bind --preset $argv ctrl-u backward-kill-line + bind --preset $argv ctrl-k kill-line bind --preset $argv ctrl-w backward-kill-path-component bind --preset $argv end end-of-line bind --preset $argv home beginning-of-line diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 00c279cdf..0a1ef6a9a 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -312,6 +312,9 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -s --preset -M visual $key beginning-of-line end + bind -s --preset -M visual -m default v end-selection repaint-mode + bind -s --preset -M visual -m insert i end-selection repaint-mode + bind -s --preset -M visual -m insert I end-selection beginning-of-line repaint-mode bind -s --preset -M visual -m insert c kill-selection end-selection repaint-mode bind -s --preset -M visual -m insert s kill-selection end-selection repaint-mode bind -s --preset -M visual -m default d kill-selection end-selection backward-char repaint-mode @@ -321,6 +324,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -s --preset -M visual -m default '",*,y' "fish_clipboard_copy; commandline -f end-selection repaint-mode" bind -s --preset -M visual -m default '",+,y' "fish_clipboard_copy; commandline -f end-selection repaint-mode" bind -s --preset -M visual -m default '~' togglecase-selection end-selection repaint-mode + bind -s --preset -M visual -m default g,U togglecase-selection end-selection repaint-mode bind -s --preset -M visual -m default ctrl-c end-selection repaint-mode bind -s --preset -M visual -m default escape end-selection repaint-mode From 620eed466b6712154e5e1764ea43b02ad4450e68 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 29 Dec 2024 14:36:11 +0100 Subject: [PATCH 035/113] Retry writing some escape sequences on EINTR Cherry-picked from bc26481558298e2172dfeb033049a2dcc1f64691. --- src/input_common.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input_common.rs b/src/input_common.rs index 27f7ff5aa..1618d62b3 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -2,7 +2,7 @@ use crate::common::{ fish_reserved_codepoint, is_windows_subsystem_for_linux, read_blocked, shell_modes, - str2wcstring, WSL, + str2wcstring, write_loop, WSL, }; use crate::env::{EnvStack, Environment}; use crate::fd_readable_set::FdReadableSet; @@ -18,7 +18,7 @@ use crate::universal_notifier::default_notifier; use crate::wchar::{encode_byte_to_char, prelude::*}; use crate::wutil::encoding::{mbrtowc, mbstate_t, zero_mbstate}; -use crate::wutil::{fish_wcstol, write_to_fd}; +use crate::wutil::fish_wcstol; use std::collections::VecDeque; use std::ops::ControlFlow; use std::os::fd::RawFd; @@ -495,9 +495,9 @@ pub fn terminal_protocols_enable_ifn() { ) }; FLOG!(term_protocols, "Enabling extended keys and bracketed paste"); - let _ = write_to_fd(sequences.as_bytes(), STDOUT_FILENO); + let _ = write_loop(&STDOUT_FILENO, sequences.as_bytes()); if IS_TMUX.load() { - let _ = write_to_fd("\x1b[?1004h".as_bytes(), STDOUT_FILENO); + let _ = write_loop(&STDOUT_FILENO, "\x1b[?1004h".as_bytes()); } reader_current_data().map(|data| data.save_screen_state()); } @@ -522,9 +522,9 @@ pub(crate) fn terminal_protocols_disable_ifn() { term_protocols, "Disabling extended keys and bracketed paste" ); - let _ = write_to_fd(sequences.as_bytes(), STDOUT_FILENO); + let _ = write_loop(&STDOUT_FILENO, sequences.as_bytes()); if IS_TMUX.load() { - let _ = write_to_fd("\x1b[?1004l".as_bytes(), STDOUT_FILENO); + let _ = write_loop(&STDOUT_FILENO, "\x1b[?1004l".as_bytes()); } if is_main_thread() { reader_current_data().map(|data| data.save_screen_state()); From 4decacb933a5223d656b00788efcfddfa7e4aece Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 3 Jan 2025 22:19:41 +0100 Subject: [PATCH 036/113] Probe for kitty keyboard protocol support I believe this fixes more cases than it breaks. For example this should fix Termux which seems to be popular among fish users. Unfortunately I haven't yet managed to test that one. Cherry-pick of all of - e49dde87cc (Probe for kitty keyboard protocol support, 2025-01-03) - 10f1f21a4f (Don't send kitty kbd protocol probe until ECHO is disabled, 2025-01-05) - dda4371679 (Stop sending CSI 5n when querying for kitty keyboard support, 2025-01-05) --- src/bin/fish_key_reader.rs | 7 ++++--- src/input_common.rs | 39 ++++++++++++++++++++++++++++---------- src/reader.rs | 8 ++++++++ 3 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/bin/fish_key_reader.rs b/src/bin/fish_key_reader.rs index b401621b1..132e450ee 100644 --- a/src/bin/fish_key_reader.rs +++ b/src/bin/fish_key_reader.rs @@ -9,19 +9,19 @@ use std::{ops::ControlFlow, os::unix::prelude::OsStrExt}; -use libc::{STDIN_FILENO, TCSANOW, VEOF, VINTR}; +use libc::{STDIN_FILENO, STDOUT_FILENO, TCSANOW, VEOF, VINTR}; #[allow(unused_imports)] use fish::future::IsSomeAnd; use fish::{ builtins::shared::BUILTIN_ERR_UNKNOWN, - common::{shell_modes, str2wcstring, PROGRAM_NAME}, + common::{shell_modes, str2wcstring, write_loop, PROGRAM_NAME}, env::env_init, eprintf, fprintf, input::input_terminfo_get_name, input_common::{ terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, InputEventQueue, - InputEventQueuer, + InputEventQueuer, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY, }, key::{self, char_to_symbol, Key}, panic::panic_handler, @@ -140,6 +140,7 @@ fn setup_and_process_keys(continuous_mode: bool, verbose: bool) -> i32 { unsafe { libc::tcsetattr(STDIN_FILENO, TCSANOW, &*shell_modes()) }; terminal_protocol_hacks(); + let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY); if continuous_mode { eprintf!("\n"); diff --git a/src/input_common.rs b/src/input_common.rs index 1618d62b3..fe0f0e83a 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -431,10 +431,19 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) { static TERMINAL_PROTOCOLS: AtomicBool = AtomicBool::new(false); +static KITTY_KEYBOARD_SUPPORTED: RelaxedAtomicBool = RelaxedAtomicBool::new(false); + +macro_rules! kitty_progressive_enhancements { + () => { + "\x1b[=5u" + }; +} + +pub const KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY: &[u8] = b"\x1b[?u"; + static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); -static IN_JETBRAINS: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocol_hacks() { use std::env::var_os; @@ -449,10 +458,6 @@ pub fn terminal_protocol_hacks() { version < (3, 5, 6) }), ); - IN_JETBRAINS.store( - var_os("TERMINAL_EMULATOR") - .is_some_and(|term| term.as_os_str().as_bytes() == b"JetBrains-JediTerm"), - ); } fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> { @@ -483,15 +488,14 @@ pub fn terminal_protocols_enable_ifn() { "\x1b[?2004h" } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b[>5u", "\x1b=",) - } else if IN_JETBRAINS.load() { - // Jetbrains IDE terminals vomit CSI u + } else if !KITTY_KEYBOARD_SUPPORTED.load() { concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b=",) } else { concat!( "\x1b[?2004h", // Bracketed paste "\x1b[>4;1m", // XTerm's modifyOtherKeys - "\x1b[=5u", // CSI u with kitty progressive enhancement - "\x1b=", // set application keypad mode, so the keypad keys send unique codes + kitty_progressive_enhancements!(), + "\x1b=", // set application keypad mode, so the keypad keys send unique codes ) }; FLOG!(term_protocols, "Enabling extended keys and bracketed paste"); @@ -508,7 +512,7 @@ pub(crate) fn terminal_protocols_disable_ifn() { } let sequences = if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",) - } else if IN_JETBRAINS.load() { + } else if !KITTY_KEYBOARD_SUPPORTED.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) } else { concat!( @@ -989,6 +993,21 @@ fn parse_csi(&mut self, buffer: &mut Vec) -> Option { _ => return None, }, b'u' => { + if private_mode == Some(b'?') { + FLOG!( + reader, + "Received kitty progressive enhancement flags, marking as supported" + ); + KITTY_KEYBOARD_SUPPORTED.store(true); + if !IN_MIDNIGHT_COMMANDER_PRE_CSI_U.load() && !IN_ITERM_PRE_CSI_U.load() { + let _ = write_loop( + &STDOUT_FILENO, + kitty_progressive_enhancements!().as_bytes(), + ); + } + return None; + } + // Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here. let key = match params[0][0] { 57399 => '0', diff --git a/src/reader.rs b/src/reader.rs index fe118ae6b..17b34499a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -78,6 +78,7 @@ use crate::input::init_input; use crate::input_common::terminal_protocols_disable_ifn; use crate::input_common::IN_MIDNIGHT_COMMANDER_PRE_CSI_U; +use crate::input_common::KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY; use crate::input_common::{ terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData, ReadlineCmd, @@ -1932,6 +1933,13 @@ fn readline(&mut self, nchars: Option) -> Option { } } + static queried: RelaxedAtomicBool = RelaxedAtomicBool::new(false); + if !queried.load() { + queried.store(true); + // Query for kitty keyboard protocol support. + let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY); + } + // HACK: Don't abandon line for the first prompt, because // if we're started with the terminal it might not have settled, // so the width is quite likely to be in flight. From a9b7dd1a9b3aee77c8e1fbe8e9c0955154a3f211 Mon Sep 17 00:00:00 2001 From: Klaus Hipp Date: Tue, 7 Jan 2025 02:40:30 +0100 Subject: [PATCH 037/113] Fix typos in docs (#11015) (cherry picked from commit 9b67b2ae070bf29060e8d2c10a9d127fc1bf2dcf) --- doc_src/cmds/abbr.rst | 2 +- doc_src/cmds/bind.rst | 6 +++--- doc_src/cmds/commandline.rst | 2 +- doc_src/cmds/string-repeat.rst | 2 +- doc_src/cmds/string-shorten.rst | 2 +- doc_src/language.rst | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc_src/cmds/abbr.rst b/doc_src/cmds/abbr.rst index 7d1d29723..b4cd9a7aa 100644 --- a/doc_src/cmds/abbr.rst +++ b/doc_src/cmds/abbr.rst @@ -53,7 +53,7 @@ Combining these features, it is possible to create custom syntaxes, where a regu > abbr > ~/.config/fish/conf.d/myabbrs.fish - This will save all your abbrevations in "myabbrs.fish", overwriting the whole file so it doesn't leave any duplicates, + This will save all your abbreviations in "myabbrs.fish", overwriting the whole file so it doesn't leave any duplicates, or restore abbreviations you had erased. Of course any functions will have to be saved separately, see :doc:`funcsave `. diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index 9218123f7..e62a27fff 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -259,7 +259,7 @@ The following special input functions are available: search the history for the next matching argument ``forward-jump`` and ``backward-jump`` - read another character and jump to its next occurence after/before the cursor + read another character and jump to its next occurrence after/before the cursor ``forward-jump-till`` and ``backward-jump-till`` jump to right *before* the next occurrence @@ -269,7 +269,7 @@ The following special input functions are available: ``jump-to-matching-bracket`` jump to matching bracket if the character under the cursor is bracket; - otherwise, jump to the next occurence of *any right* bracket after the cursor. + otherwise, jump to the next occurrence of *any right* bracket after the cursor. The following brackets are considered: ``([{}])`` ``jump-till-matching-bracket`` @@ -292,7 +292,7 @@ The following special input functions are available: move the selected text to the killring ``kill-whole-line`` - move the line (including the following newline) to the killring. If the line is the last line, its preceeding newline is also removed + move the line (including the following newline) to the killring. If the line is the last line, its preceding newline is also removed ``kill-inner-line`` move the line (without the following newline) to the killring diff --git a/doc_src/cmds/commandline.rst b/doc_src/cmds/commandline.rst index 3a5ac34c7..73659a587 100644 --- a/doc_src/cmds/commandline.rst +++ b/doc_src/cmds/commandline.rst @@ -116,7 +116,7 @@ The following options output metadata about the commandline state: **--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. + If the commandline is incomplete, return 2, if erroneous, return 1. **--showing-suggestion** Evaluates to true (i.e. returns 0) when the shell is currently showing an automatic history completion/suggestion, available to be consumed via one of the `forward-` bindings. diff --git a/doc_src/cmds/string-repeat.rst b/doc_src/cmds/string-repeat.rst index d16d0ec11..c5f2c6897 100644 --- a/doc_src/cmds/string-repeat.rst +++ b/doc_src/cmds/string-repeat.rst @@ -19,7 +19,7 @@ Description .. BEGIN DESCRIPTION -``string repeat`` repeats the *STRING* **-n** or **--count** times. The **-m** or **--max** option will limit the number of outputted characters (excluding the newline). This option can be used by itself or in conjunction with **--count**. If both **--count** and **--max** are present, max char will be outputed unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both **--count** and **--max** will accept a number greater than or equal to zero, in the case of zero, nothing will be outputed. The first argument is interpreted as *COUNT* if **--count** or **--max** are not explicilty specified. If **-N** or **--no-newline** is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise. +``string repeat`` repeats the *STRING* **-n** or **--count** times. The **-m** or **--max** option will limit the number of outputted characters (excluding the newline). This option can be used by itself or in conjunction with **--count**. If both **--count** and **--max** are present, max char will be outputted unless the final repeated string size is less than max, in that case, the string will repeat until count has been reached. Both **--count** and **--max** will accept a number greater than or equal to zero, in the case of zero, nothing will be outputted. The first argument is interpreted as *COUNT* if **--count** or **--max** are not explicitly specified. If **-N** or **--no-newline** is given, the output won't contain a newline character at the end. Exit status: 0 if yielded string is not empty, 1 otherwise. .. END DESCRIPTION diff --git a/doc_src/cmds/string-shorten.rst b/doc_src/cmds/string-shorten.rst index fe5700f7e..0e24bf058 100644 --- a/doc_src/cmds/string-shorten.rst +++ b/doc_src/cmds/string-shorten.rst @@ -34,7 +34,7 @@ If **-q** or **--quiet** is given, ``string shorten`` only runs for the return v The default ellipsis is ``…``. If fish thinks your system is incapable because of your locale, it will use ``...`` instead. -The return value is 0 if any shortening occured, 1 otherwise. +The return value is 0 if any shortening occurred, 1 otherwise. .. END DESCRIPTION diff --git a/doc_src/language.rst b/doc_src/language.rst index 7f1cc37d8..008469e30 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -870,7 +870,7 @@ but if you need multiple or the command doesn't read from standard input, "proce This creates a temporary file, stores the output of the command in that file and prints the filename, so it is given to the outer command. -Fish has a default limit of 100 MiB on the data it will read in a command sustitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read ` command. +Fish has a default limit of 100 MiB on the data it will read in a command substitution. If that limit is reached the command (all of it, not just the command substitution - the outer command won't be executed at all) fails and ``$status`` is set to 122. This is so command substitutions can't cause the system to go out of memory, because typically your operating system has a much lower limit, so reading more than that would be useless and harmful. This limit can be adjusted with the ``fish_read_limit`` variable (`0` meaning no limit). This limit also affects the :doc:`read ` command. .. [#] One exception: Setting ``$IFS`` to empty will disable line splitting. This is deprecated, use :doc:`string split ` instead. @@ -1845,7 +1845,7 @@ The "locale" of a program is its set of language and regional settings that depe .. envvar:: LC_MONETARY - Determines currency, how it is formated, and the symbols used. + Determines currency, how it is formatted, and the symbols used. .. envvar:: LC_NUMERIC From cbfbac219846abcaee00e6ccf4cbb13a20004a34 Mon Sep 17 00:00:00 2001 From: Klaus Hipp Date: Tue, 7 Jan 2025 02:39:47 +0100 Subject: [PATCH 038/113] Fix completion typos for `apt-build`, `htop` and `wget` (#11016) (cherry picked from commit ea4e4a4279106d481daafe3e9c7b6bc635a36ca7) --- share/completions/apt-build.fish | 2 +- share/completions/htop.fish | 2 +- share/completions/wget.fish | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/share/completions/apt-build.fish b/share/completions/apt-build.fish index 5b3f56620..d74f4b168 100644 --- a/share/completions/apt-build.fish +++ b/share/completions/apt-build.fish @@ -2,7 +2,7 @@ complete -c apt-build -l help -d "Display help and exit" complete -f -c apt-build -a update -d "Update list of packages" complete -f -c apt-build -a upgrade -d "Upgrade packages" -complete -f -c apt-bulid -a world -d "Rebuild your system" +complete -f -c apt-build -a world -d "Rebuild your system" complete -x -c apt-build -a install -d "Build and install a new package" complete -x -c apt-build -a source -d "Download and extract a source" complete -x -c apt-build -a info -d "Info on a package" diff --git a/share/completions/htop.fish b/share/completions/htop.fish index 1e958a685..3ab848c93 100644 --- a/share/completions/htop.fish +++ b/share/completions/htop.fish @@ -15,7 +15,7 @@ complete -c htop -l readonly -d 'Disable all system and process changing feature complete -c htop -l version -s V -d 'Show version and exit' complete -c htop -l tree -s t -d 'Show processes in tree view' complete -c htop -l highlight-changes -s H -d 'Highlight new and old processes' -x -complete -c htop -l drop-capabilites -d 'Drop unneeded Linux capabilites (Requires libpcap support)' -xka " +complete -c htop -l drop-capabilities -d 'Drop unneeded Linux capabilities (Requires libpcap support)' -xka " off basic strict diff --git a/share/completions/wget.fish b/share/completions/wget.fish index 514dacdb3..ee02cd3f6 100644 --- a/share/completions/wget.fish +++ b/share/completions/wget.fish @@ -55,7 +55,7 @@ complete -c wget -o nd -d "Do not create a hierarchy of directories" complete -c wget -s x -l force-directories -d "Force creation of a hierarchy of directories" complete -c wget -l no-host-directories -d "Disable generation of host-prefixed directories" complete -c wget -o nH -d "Disable generation of host-prefixed directories" -complete -c wget -l protocal-directories -d "Use the protocol name as a directory component" +complete -c wget -l protocol-directories -d "Use the protocol name as a directory component" complete -c wget -l cut-dirs -d "Ignore specified number of directory components" -xa "1 2 3 4 5" complete -c wget -s P -l directory-prefix -d "Set directory prefix" -r complete -c wget -s E -l html-extension -d "Force html files to have html extension" From 52a2bed38c70b10e69f455ff3b165bde0ed5b391 Mon Sep 17 00:00:00 2001 From: Steve Walker <65963536+etherswangel@users.noreply.github.com> Date: Wed, 25 Dec 2024 23:27:35 +0800 Subject: [PATCH 039/113] fix python completion #10943 (cherry picked from commit b574a5e4f6bf142fe05980e55ace8143e889922f) --- share/completions/python.fish | 73 +++++++++++++++++++++------------- share/completions/python3.fish | 67 ++++++++++++++++++++----------- 2 files changed, 89 insertions(+), 51 deletions(-) diff --git a/share/completions/python.fish b/share/completions/python.fish index f97f1fd14..a69118065 100644 --- a/share/completions/python.fish +++ b/share/completions/python.fish @@ -1,23 +1,42 @@ -complete -c python -s B -d 'Don\'t write .py[co] files on import' -complete -c python -s c -x -d "Execute argument as command" -complete -c python -l check-hash-based-pycs -a "default always never" -d "Control validation behaviour of pyc files" -complete -c python -s d -d "Debug on" -complete -c python -s E -d "Ignore all PYTHON* env vars" -complete -c python -s h -s '?' -l help -d "Display help and exit" -complete -c python -s i -d "Interactive mode after executing commands" -complete -c python -s m -d 'Run library module as a script (terminates option list)' -xa '(python -c "import pkgutil; print(\'\n\'.join([p[1] for p in pkgutil.iter_modules()]))")' -complete -c python -s O -d "Enable optimizations" -complete -c python -o OO -d "Remove doc-strings in addition to the -O optimizations" -complete -c python -s s -d 'Don\'t add user site directory to sys.path' -complete -c python -s S -d "Disable import of site module" -complete -c python -s u -d "Unbuffered input and output" -complete -c python -s v -d "Verbose mode" -complete -c python -o vv -d "Even more verbose mode" -complete -c python -s V -l version -d "Display version and exit" -complete -c python -s W -x -d "Warning control" -a "ignore default all module once error" -complete -c python -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python -f -n "__fish_is_nth_token 1" -k -a "(__fish_complete_suffix .py)" -complete -c python -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdin' +# This function adjusts for options with arguments (-X, -W, etc.), ensures completions stop when a script/module is set (-c, -m, file, -) +function __fish_python_no_arg + set -l num 1 + set -l tokens (commandline -pxc) + set -l has_arg_list -X -W --check-hash-based-pycs + if contains -- - $tokens + set num (math $num - 1) + end + for has_arg in $has_arg_list + if contains -- $has_arg $tokens + set num (math $num + 1) + end + end + if test (__fish_number_of_cmd_args_wo_opts) -gt $num + return 1 + end + return 0 +end + +complete -c python -n __fish_python_no_arg -s B -d 'Don\'t write .py[co] files on import' +complete -c python -n __fish_python_no_arg -s c -x -d "Execute argument as command" +complete -c python -n __fish_python_no_arg -l check-hash-based-pycs -a "default always never" -d "Control validation behaviour of pyc files" +complete -c python -n __fish_python_no_arg -s d -d "Debug on" +complete -c python -n __fish_python_no_arg -s E -d "Ignore all PYTHON* env vars" +complete -c python -n __fish_python_no_arg -s h -s '?' -l help -d "Display help and exit" +complete -c python -n __fish_python_no_arg -s i -d "Interactive mode after executing commands" +complete -c python -n __fish_python_no_arg -s m -d 'Run library module as a script (terminates option list)' -xa '(python -c "import pkgutil; print(\'\n\'.join([p[1] for p in pkgutil.iter_modules()]))")' +complete -c python -n __fish_python_no_arg -s O -d "Enable optimizations" +complete -c python -n __fish_python_no_arg -o OO -d "Remove doc-strings in addition to the -O optimizations" +complete -c python -n __fish_python_no_arg -s s -d 'Don\'t add user site directory to sys.path' +complete -c python -n __fish_python_no_arg -s S -d "Disable import of site module" +complete -c python -n __fish_python_no_arg -s u -d "Unbuffered input and output" +complete -c python -n __fish_python_no_arg -s v -d "Verbose mode" +complete -c python -n __fish_python_no_arg -o vv -d "Even more verbose mode" +complete -c python -n __fish_python_no_arg -s V -l version -d "Display version and exit" +complete -c python -n __fish_python_no_arg -s W -x -d "Warning control" -a "ignore default all module once error" +complete -c python -n __fish_python_no_arg -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' +complete -c python -n __fish_python_no_arg -f -k -a "(__fish_complete_suffix .py)" +complete -c python -n __fish_python_no_arg -f -a - -d 'Read program from stdin' # Version-specific completions # We have to detect this at runtime because pyenv etc can change @@ -25,10 +44,10 @@ complete -c python -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdi complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s 3 -d 'Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix' complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s t -d "Warn on mixed tabs and spaces" complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s2"' -s Q -x -a "old new warn warnall" -d "Division control" -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -s q -d 'Don\'t print version and copyright messages on interactive startup' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -s X -x -d 'Set implementation-specific option' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -s b -d 'Warn when comparing bytes with str or int' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -o bb -d 'Error when comparing bytes with str or int' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -s R -d 'Turn on hash randomization' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -s I -d 'Run in isolated mode' -complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3"' -o VV -d 'Print further version info' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -s q -d 'Don\'t print version and copyright messages on interactive startup' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -s X -x -d 'Set implementation-specific option' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -s b -d 'Warn when comparing bytes with str or int' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -o bb -d 'Error when comparing bytes with str or int' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -s R -d 'Turn on hash randomization' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -s I -d 'Run in isolated mode' +complete -c python -n 'python -V 2>&1 | string match -rq "^.*\s3" && __fish_python_no_arg' -o VV -d 'Print further version info' diff --git a/share/completions/python3.fish b/share/completions/python3.fish index 27664ff45..74421af6d 100644 --- a/share/completions/python3.fish +++ b/share/completions/python3.fish @@ -1,24 +1,43 @@ -complete -c python3 -s B -d 'Don\'t write .py[co] files on import' -complete -c python3 -s c -x -d "Execute argument as command" -complete -c python3 -s d -d "Debug on" -complete -c python3 -s E -d "Ignore environment variables" -complete -c python3 -s h -s '?' -l help -d "Display help and exit" -complete -c python3 -s i -d "Interactive mode after executing commands" -complete -c python3 -s O -d "Enable optimizations" -complete -c python3 -o OO -d "Remove doc-strings in addition to the -O optimizations" -complete -c python3 -s s -d 'Don\'t add user site directory to sys.path' -complete -c python3 -s S -d "Disable import of site module" -complete -c python3 -s u -d "Unbuffered input and output" -complete -c python3 -s v -d "Verbose mode" -complete -c python3 -s V -l version -d "Display version and exit" -complete -c python3 -s W -x -d "Warning control" -a "ignore default all module once error" -complete -c python3 -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' -complete -c python3 -n "__fish_is_nth_token 1" -k -fa "(__fish_complete_suffix .py)" -complete -c python3 -f -n "__fish_is_nth_token 1" -a - -d 'Read program from stdin' -complete -c python3 -s q -d 'Don\'t print version and copyright messages on interactive startup' -complete -c python3 -s X -x -d 'Set implementation-specific option' -a 'faulthandler showrefcount tracemalloc showalloccount importtime dev utf8 pycache_prefex=PATH:' -complete -c python3 -s b -d 'Issue warnings for possible misuse of `bytes` with `str`' -complete -c python3 -o bb -d 'Issue errors for possible misuse of `bytes` with `str`' -complete -c python3 -s m -d 'Run library module as a script (terminates option list)' -xa '(python3 -c "import pkgutil; print(\'\n\'.join([p[1] for p in pkgutil.iter_modules()]))")' -complete -c python3 -l check-hash-based-pycs -d 'Set pyc hash check mode' -xa "default always never" -complete -c python3 -s I -d 'Run in isolated mode' +# This function adjusts for options with arguments (-X, -W, etc.), ensures completions stop when a script/module is set (-c, -m, file, -) +function __fish_python_no_arg + set -l num 1 + set -l tokens (commandline -pxc) + set -l has_arg_list -X -W --check-hash-based-pycs + if contains -- - $tokens + set num (math $num - 1) + end + for has_arg in $has_arg_list + if contains -- $has_arg $tokens + set num (math $num + 1) + end + end + if test (__fish_number_of_cmd_args_wo_opts) -gt $num + return 1 + end + return 0 +end + +complete -c python3 -n __fish_python_no_arg -s B -d 'Don\'t write .py[co] files on import' +complete -c python3 -n __fish_python_no_arg -s c -x -d "Execute argument as command" +complete -c python3 -n __fish_python_no_arg -s d -d "Debug on" +complete -c python3 -n __fish_python_no_arg -s E -d "Ignore environment variables" +complete -c python3 -n __fish_python_no_arg -s h -s '?' -l help -d "Display help and exit" +complete -c python3 -n __fish_python_no_arg -s i -d "Interactive mode after executing commands" +complete -c python3 -n __fish_python_no_arg -s O -d "Enable optimizations" +complete -c python3 -n __fish_python_no_arg -o OO -d "Remove doc-strings in addition to the -O optimizations" +complete -c python3 -n __fish_python_no_arg -s s -d 'Don\'t add user site directory to sys.path' +complete -c python3 -n __fish_python_no_arg -s S -d "Disable import of site module" +complete -c python3 -n __fish_python_no_arg -s u -d "Unbuffered input and output" +complete -c python3 -n __fish_python_no_arg -s v -d "Verbose mode" +complete -c python3 -n __fish_python_no_arg -s V -l version -d "Display version and exit" +complete -c python3 -n __fish_python_no_arg -s W -x -d "Warning control" -a "ignore default all module once error" +complete -c python3 -n __fish_python_no_arg -s x -d 'Skip first line of source, allowing use of non-Unix forms of #!cmd' +complete -c python3 -n __fish_python_no_arg -k -fa "(__fish_complete_suffix .py)" +complete -c python3 -n __fish_python_no_arg -fa - -d 'Read program from stdin' +complete -c python3 -n __fish_python_no_arg -s q -d 'Don\'t print version and copyright messages on interactive startup' +complete -c python3 -n __fish_python_no_arg -s X -x -d 'Set implementation-specific option' -a 'faulthandler showrefcount tracemalloc showalloccount importtime dev utf8 pycache_prefex=PATH:' +complete -c python3 -n __fish_python_no_arg -s b -d 'Issue warnings for possible misuse of `bytes` with `str`' +complete -c python3 -n __fish_python_no_arg -o bb -d 'Issue errors for possible misuse of `bytes` with `str`' +complete -c python3 -n __fish_python_no_arg -s m -d 'Run library module as a script (terminates option list)' -xa '(python3 -c "import pkgutil; print(\'\n\'.join([p[1] for p in pkgutil.iter_modules()]))")' +complete -c python3 -n __fish_python_no_arg -l check-hash-based-pycs -d 'Set pyc hash check mode' -xa "default always never" +complete -c python3 -n __fish_python_no_arg -s I -d 'Run in isolated mode' From 8a5b1ccc1729ed36933dee1f7d03673c537c85aa Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 7 Jan 2025 20:28:24 +0100 Subject: [PATCH 040/113] Revert "Probe for kitty keyboard protocol support" This needs to be tested more, it has shown issues in MS conhost, and potentially others. Changing strategy after beta isn't the greatest idea. This reverts commit 4decacb933a5223d656b00788efcfddfa7e4aece. See #10994 --- src/bin/fish_key_reader.rs | 7 +++---- src/input_common.rs | 39 ++++++++++---------------------------- src/reader.rs | 8 -------- 3 files changed, 13 insertions(+), 41 deletions(-) diff --git a/src/bin/fish_key_reader.rs b/src/bin/fish_key_reader.rs index 132e450ee..b401621b1 100644 --- a/src/bin/fish_key_reader.rs +++ b/src/bin/fish_key_reader.rs @@ -9,19 +9,19 @@ use std::{ops::ControlFlow, os::unix::prelude::OsStrExt}; -use libc::{STDIN_FILENO, STDOUT_FILENO, TCSANOW, VEOF, VINTR}; +use libc::{STDIN_FILENO, TCSANOW, VEOF, VINTR}; #[allow(unused_imports)] use fish::future::IsSomeAnd; use fish::{ builtins::shared::BUILTIN_ERR_UNKNOWN, - common::{shell_modes, str2wcstring, write_loop, PROGRAM_NAME}, + common::{shell_modes, str2wcstring, PROGRAM_NAME}, env::env_init, eprintf, fprintf, input::input_terminfo_get_name, input_common::{ terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, InputEventQueue, - InputEventQueuer, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY, + InputEventQueuer, }, key::{self, char_to_symbol, Key}, panic::panic_handler, @@ -140,7 +140,6 @@ fn setup_and_process_keys(continuous_mode: bool, verbose: bool) -> i32 { unsafe { libc::tcsetattr(STDIN_FILENO, TCSANOW, &*shell_modes()) }; terminal_protocol_hacks(); - let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY); if continuous_mode { eprintf!("\n"); diff --git a/src/input_common.rs b/src/input_common.rs index fe0f0e83a..1618d62b3 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -431,19 +431,10 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) { static TERMINAL_PROTOCOLS: AtomicBool = AtomicBool::new(false); -static KITTY_KEYBOARD_SUPPORTED: RelaxedAtomicBool = RelaxedAtomicBool::new(false); - -macro_rules! kitty_progressive_enhancements { - () => { - "\x1b[=5u" - }; -} - -pub const KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY: &[u8] = b"\x1b[?u"; - static IS_TMUX: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +static IN_JETBRAINS: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocol_hacks() { use std::env::var_os; @@ -458,6 +449,10 @@ pub fn terminal_protocol_hacks() { version < (3, 5, 6) }), ); + IN_JETBRAINS.store( + var_os("TERMINAL_EMULATOR") + .is_some_and(|term| term.as_os_str().as_bytes() == b"JetBrains-JediTerm"), + ); } fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> { @@ -488,14 +483,15 @@ pub fn terminal_protocols_enable_ifn() { "\x1b[?2004h" } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b[>5u", "\x1b=",) - } else if !KITTY_KEYBOARD_SUPPORTED.load() { + } else if IN_JETBRAINS.load() { + // Jetbrains IDE terminals vomit CSI u concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b=",) } else { concat!( "\x1b[?2004h", // Bracketed paste "\x1b[>4;1m", // XTerm's modifyOtherKeys - kitty_progressive_enhancements!(), - "\x1b=", // set application keypad mode, so the keypad keys send unique codes + "\x1b[=5u", // CSI u with kitty progressive enhancement + "\x1b=", // set application keypad mode, so the keypad keys send unique codes ) }; FLOG!(term_protocols, "Enabling extended keys and bracketed paste"); @@ -512,7 +508,7 @@ pub(crate) fn terminal_protocols_disable_ifn() { } let sequences = if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",) - } else if !KITTY_KEYBOARD_SUPPORTED.load() { + } else if IN_JETBRAINS.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) } else { concat!( @@ -993,21 +989,6 @@ fn parse_csi(&mut self, buffer: &mut Vec) -> Option { _ => return None, }, b'u' => { - if private_mode == Some(b'?') { - FLOG!( - reader, - "Received kitty progressive enhancement flags, marking as supported" - ); - KITTY_KEYBOARD_SUPPORTED.store(true); - if !IN_MIDNIGHT_COMMANDER_PRE_CSI_U.load() && !IN_ITERM_PRE_CSI_U.load() { - let _ = write_loop( - &STDOUT_FILENO, - kitty_progressive_enhancements!().as_bytes(), - ); - } - return None; - } - // Treat numpad keys the same as their non-numpad counterparts. Could add a numpad modifier here. let key = match params[0][0] { 57399 => '0', diff --git a/src/reader.rs b/src/reader.rs index 17b34499a..fe118ae6b 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -78,7 +78,6 @@ use crate::input::init_input; use crate::input_common::terminal_protocols_disable_ifn; use crate::input_common::IN_MIDNIGHT_COMMANDER_PRE_CSI_U; -use crate::input_common::KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY; use crate::input_common::{ terminal_protocol_hacks, terminal_protocols_enable_ifn, CharEvent, CharInputStyle, InputData, ReadlineCmd, @@ -1933,13 +1932,6 @@ fn readline(&mut self, nchars: Option) -> Option { } } - static queried: RelaxedAtomicBool = RelaxedAtomicBool::new(false); - if !queried.load() { - queried.store(true); - // Query for kitty keyboard protocol support. - let _ = write_loop(&STDOUT_FILENO, KITTY_PROGRESSIVE_ENHANCEMENTS_QUERY); - } - // HACK: Don't abandon line for the first prompt, because // if we're started with the terminal it might not have settled, // so the width is quite likely to be in flight. From f36a7262db4df95ef9f0eb2504ab9b86b9d770fc Mon Sep 17 00:00:00 2001 From: Klaus Hipp Date: Tue, 7 Jan 2025 19:32:16 +0100 Subject: [PATCH 041/113] Revert "Fix typo in npm completions: isntall -> install" (#11014) * Revert "Fix typo in npm completions: isntall -> install" This reverts commit f4b01bb638fe0b8060403313fdcb617a52aca047. * Add comments about typos in `npm` completions (cherry picked from commit 4def0ac616a99398db18de54bb415bcc9eb320f1) --- share/completions/npm.fish | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/share/completions/npm.fish b/share/completions/npm.fish index ecafdbb4e..c5526e462 100644 --- a/share/completions/npm.fish +++ b/share/completions/npm.fish @@ -141,7 +141,8 @@ complete -f -c npm -n '__fish_npm_using_command cache' -s h -l help -d 'Display # install-ci-test complete -f -c npm -n __fish_npm_needs_command -a 'ci clean-install' -d 'Clean install a project' complete -f -c npm -n __fish_npm_needs_command -a 'install-ci-test cit' -d 'Install a project with a clean slate and run tests' -for c in ci clean-install ic install-clean install-clean install-ci-test cit clean-install-test sit +# typos are intentional +for c in ci clean-install ic install-clean isntall-clean install-ci-test cit clean-install-test sit complete -x -c npm -n "__fish_npm_using_command $c" -l install-strategy -a 'hoisted nested shallow linked' -d 'Install strategy' complete -x -c npm -n "__fish_npm_using_command $c" -l omit -a 'dev optional peer' -d 'Omit dependency type' complete -x -c npm -n "__fish_npm_using_command $c" -l strict-peer-deps -d 'Treat conflicting peerDependencies as failure' @@ -406,7 +407,8 @@ end complete -c npm -n __fish_npm_needs_command -a 'install add i' -d 'Install a package' complete -f -c npm -n __fish_npm_needs_command -a 'install-test it' -d 'Install package(s) and run tests' complete -f -c npm -n __fish_npm_needs_command -a 'link ln' -d 'Symlink a package folder' -for c in install add i in ins inst insta instal isnt isnta isntal install install-test it link ln +# typos are intentional +for c in install add i in ins inst insta instal isnt isnta isntal isntall install-test it link ln complete -f -c npm -n "__fish_npm_using_command $c" -s S -l save -d 'Save to dependencies' complete -f -c npm -n "__fish_npm_using_command $c" -l no-save -d 'Prevents saving to dependencies' complete -f -c npm -n "__fish_npm_using_command $c" -s P -l save-prod -d 'Save to dependencies' @@ -726,4 +728,4 @@ complete -f -c npm -n '__fish_npm_using_command whoami' -a registry -d 'Check re complete -f -c npm -n '__fish_npm_using_command whoami' -s h -l help -d 'Display help' # misc -complete -f -c npm -n '__fish_seen_subcommand_from add i in ins inst insta instal isnt isnta isntal install; and not __fish_is_switch' -a "(__npm_filtered_list_packages \"$npm_install\")" +complete -f -c npm -n '__fish_seen_subcommand_from add i in ins inst insta instal isnt isnta isntal isntall; and not __fish_is_switch' -a "(__npm_filtered_list_packages \"$npm_install\")" From d6dccc3c88c96a46b480795464474f70ce95aa55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Sagaert?= Date: Thu, 9 Jan 2025 16:35:46 +0100 Subject: [PATCH 042/113] DNF5 completion support (#11035) * dnf5 completions * address comments (cherry picked from commit 00c7baf68cf77c84ab47a7d256c2a076de0dbc03) --- share/completions/dnf.fish | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/share/completions/dnf.fish b/share/completions/dnf.fish index 3e2d3d072..1e749909d 100644 --- a/share/completions/dnf.fish +++ b/share/completions/dnf.fish @@ -2,6 +2,10 @@ # Completions for the dnf command # +function __dnf_is_dnf5 + path resolve -- $PATH/dnf | path filter | string match -q -- '*/dnf5' +end + function __dnf_list_installed_packages dnf repoquery --cacheonly "$cur*" --qf "%{name}\n" --installed /dev/null | string replace "|" \t end end From fb6d3c3669b3feb71064d17fba5574fb8195da29 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 9 Jan 2025 16:41:17 +0100 Subject: [PATCH 043/113] type: Do not translate the type "builtin" This is a functional string, it should not be translated. And we do not translate the others. --- src/builtins/type.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builtins/type.rs b/src/builtins/type.rs index 7a6c5727d..50e764d20 100644 --- a/src/builtins/type.rs +++ b/src/builtins/type.rs @@ -169,7 +169,7 @@ pub fn r#type(parser: &Parser, streams: &mut IoStreams, argv: &mut [&wstr]) -> O if !opts.get_type { streams.out.append(wgettext_fmt!("%ls is a builtin\n", arg)); } else if opts.get_type { - streams.out.append(wgettext!("builtin\n")); + streams.out.append(L!("builtin\n")); } if !opts.all { continue; From fbf9ac8046bd9059c5d706f2847398677752b1c9 Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Thu, 9 Jan 2025 21:24:16 +0800 Subject: [PATCH 044/113] Fix missing of builtin token description (cherry picked from commit ef7aa793c6e67744393dfdb93b2f51175c602d02) --- share/functions/__fish_whatis_current_token.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/functions/__fish_whatis_current_token.fish b/share/functions/__fish_whatis_current_token.fish index 7034c791c..a731cf90e 100644 --- a/share/functions/__fish_whatis_current_token.fish +++ b/share/functions/__fish_whatis_current_token.fish @@ -18,7 +18,7 @@ function __fish_whatis_current_token -d "Show man page entries or function descr and set desc "$token - $funcinfo[5]" case builtin - set desc (__fish_print_help $token | awk "/./ {print; exit}") + set desc (__fish_print_help $token | awk "/./ { getline; print; exit }" | string trim) case file set -l tmpdesc (whatis $token 2>/dev/null) From b3aa79e9aa237044044129a255f4be5448162277 Mon Sep 17 00:00:00 2001 From: Klaus Hipp Date: Wed, 8 Jan 2025 13:58:41 +0100 Subject: [PATCH 045/113] Fix completion typos (cherry picked from commit 5c25d3c3b1192b7ec9e6c3874562669b2ed4aa0b) --- share/completions/VBoxSDL.fish | 2 +- share/completions/bzr.fish | 2 +- share/completions/create_ap.fish | 2 +- share/completions/gprof.fish | 2 +- share/completions/pkg.fish | 2 +- share/completions/pygmentize.fish | 6 +++--- share/completions/python3.fish | 2 +- share/completions/virsh.fish | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/share/completions/VBoxSDL.fish b/share/completions/VBoxSDL.fish index f4ceef703..30c7bf166 100644 --- a/share/completions/VBoxSDL.fish +++ b/share/completions/VBoxSDL.fish @@ -1,6 +1,6 @@ complete -c VBoxSDL -l startvm -x -d "Set virtual machine to start" -a "(__fish_print_VBox_vms)" -complete -c VBoxSDL -l seperate -d "Run separate VM process or attach to a running VM" +complete -c VBoxSDL -l separate -d "Run separate VM process or attach to a running VM" complete -c VBoxSDL -l hda -f -d "Set temporary first hard disk" complete -c VBoxSDL -l fda -f -d "Set temporary first floppy disk" complete -c VBoxSDL -l cdrom -r -d "Set temporary CDROM/DVD" -a "none\tunmount" diff --git a/share/completions/bzr.fish b/share/completions/bzr.fish index bb90453a5..7572dd7d5 100644 --- a/share/completions/bzr.fish +++ b/share/completions/bzr.fish @@ -61,7 +61,7 @@ complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l pull -d 'If destina complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l remember -d 'Remember the specified location as a default' complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l force -d 'Merge even if the destination tree has uncommitted changes' complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l reprocess -d 'Reprocess to reduce spurious conflicts' -complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l uncommited -d 'Apply uncommitted changes from a working copy, instead of branch changes' +complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l uncommitted -d 'Apply uncommitted changes from a working copy, instead of branch changes' complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l show-base -d 'Show base revision text in conflicts' complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l preview -d 'Instead of merging, show a diff of the merge' complete -f -c bzr -n '__fish_seen_subcommand_from merge' -l interactive -s i -d 'Select changes interactively' diff --git a/share/completions/create_ap.fish b/share/completions/create_ap.fish index 7b61b2468..60159d4d0 100644 --- a/share/completions/create_ap.fish +++ b/share/completions/create_ap.fish @@ -5,7 +5,7 @@ complete -c create_ap -l version -d 'Print version number' complete -c create_ap -s c -x -d 'Channel number' complete -c create_ap -s w -x -a '1 2 1+2' -d 'WPA version to use' complete -c create_ap -s n -d 'Disable Internet sharing' -complete -c create_ap -s m -x -a 'nat brigde none' -d 'Method for Internet sharing' +complete -c create_ap -s m -x -a 'nat bridge none' -d 'Method for Internet sharing' complete -c create_ap -l psk -d 'Use 64 hex digits pre-shared-key' complete -c create_ap -l hidden -d 'Make the Access Point hidden' complete -c create_ap -l mac-filter -d 'Enable MAC address filtering' diff --git a/share/completions/gprof.fish b/share/completions/gprof.fish index 8ec61757f..fbb3af7f1 100644 --- a/share/completions/gprof.fish +++ b/share/completions/gprof.fish @@ -1,4 +1,4 @@ -complete -c gprof -s A -l annoted-source -d "Print annotated source" +complete -c gprof -s A -l annotated-source -d "Print annotated source" complete -c gprof -s b -l brief -d "Do not print explanations" complete -c gprof -s C -l exec-counts -d "Print tally" complete -c gprof -s i -l file-info -d "Display summary" diff --git a/share/completions/pkg.fish b/share/completions/pkg.fish index db1f8eb3a..c0a8b6e50 100644 --- a/share/completions/pkg.fish +++ b/share/completions/pkg.fish @@ -169,7 +169,7 @@ complete -c pkg -n '__fish_pkg_is list' -xa '(pkg query "%n")' complete -c pkg -n '__fish_pkg_is add update' -s f -l force -d "Force a full download of a repository" # alias -set -l with_packge_names all-depends annotations build-depends cinfo comment csearch desc iinfo isearch \ +set -l with_package_names all-depends annotations build-depends cinfo comment csearch desc iinfo isearch \ list options origin provided-depends roptions shared-depends show size for alias in (pkg alias -lq) diff --git a/share/completions/pygmentize.fish b/share/completions/pygmentize.fish index 4f4cb6042..91dfa0c12 100644 --- a/share/completions/pygmentize.fish +++ b/share/completions/pygmentize.fish @@ -16,12 +16,12 @@ complete -c pygmentize -s o -d "Set output file" complete -c pygmentize -s s -d "Read one line at a time" complete -c pygmentize -s l -d "Set lexer" -x -a "(__fish_print_pygmentize lexers Lexer)" complete -c pygmentize -s g -d "Guess lexer" -complete -c pygmentize -s f -d "Set formater" -x -a "(__fish_print_pygmentize formaters Formater)" -complete -c pygmentize -s O -d "Set coma-seperated options" -x +complete -c pygmentize -s f -d "Set formatter" -x -a "(__fish_print_pygmentize formatters Formatter)" +complete -c pygmentize -s O -d "Set coma-separated options" -x complete -c pygmentize -s P -d "Set one option" -x complete -c pygmentize -s F -d "Set filter" -x -a "(__fish_print_pygmentize filters Filter)" complete -c pygmentize -s S -d "Print style definition for given style" -x -a "(__fish_print_pygmentize styles Style)" -complete -c pygmentize -s L -d "List lexers, formaters, styles or filters" -x -a "lexers formaters styles filters" +complete -c pygmentize -s L -d "List lexers, formatters, styles or filters" -x -a "lexers formatters styles filters" complete -c pygmentize -s N -d "Guess and print lexer name based on given file" complete -c pygmentize -s H -d "Print detailed help" -x -a "lexer formatter filter" complete -c pygmentize -s v -d "Print detailed traceback on unhandled exceptions" diff --git a/share/completions/python3.fish b/share/completions/python3.fish index 74421af6d..99e0636ce 100644 --- a/share/completions/python3.fish +++ b/share/completions/python3.fish @@ -35,7 +35,7 @@ complete -c python3 -n __fish_python_no_arg -s x -d 'Skip first line of source, complete -c python3 -n __fish_python_no_arg -k -fa "(__fish_complete_suffix .py)" complete -c python3 -n __fish_python_no_arg -fa - -d 'Read program from stdin' complete -c python3 -n __fish_python_no_arg -s q -d 'Don\'t print version and copyright messages on interactive startup' -complete -c python3 -n __fish_python_no_arg -s X -x -d 'Set implementation-specific option' -a 'faulthandler showrefcount tracemalloc showalloccount importtime dev utf8 pycache_prefex=PATH:' +complete -c python3 -n __fish_python_no_arg -s X -x -d 'Set implementation-specific option' -a 'faulthandler showrefcount tracemalloc showalloccount importtime dev utf8 pycache_prefix=PATH:' complete -c python3 -n __fish_python_no_arg -s b -d 'Issue warnings for possible misuse of `bytes` with `str`' complete -c python3 -n __fish_python_no_arg -o bb -d 'Issue errors for possible misuse of `bytes` with `str`' complete -c python3 -n __fish_python_no_arg -s m -d 'Run library module as a script (terminates option list)' -xa '(python3 -c "import pkgutil; print(\'\n\'.join([p[1] for p in pkgutil.iter_modules()]))")' diff --git a/share/completions/virsh.fish b/share/completions/virsh.fish index c55924fa6..ebf49e441 100644 --- a/share/completions/virsh.fish +++ b/share/completions/virsh.fish @@ -75,7 +75,7 @@ function __fish_virsh_get_networks set -l network_autostart $network[3] set -l network_persistent $network[4] - set -l network_qualities $network_state (test $network_autostart = 'yes'; and echo 'autostart') (test $network_persistent = 'yes'; and echo 'persistant') + set -l network_qualities $network_state (test $network_autostart = 'yes'; and echo 'autostart') (test $network_persistent = 'yes'; and echo 'persistent') set -l show true if set -q argv[1] for filter in $argv From b009c0d480438387b949e312988428a9e43b43ee Mon Sep 17 00:00:00 2001 From: David Adam Date: Sun, 12 Jan 2025 21:19:59 +0800 Subject: [PATCH 046/113] Debian packaging: update dependencies Ubuntu Focal calls the package with col "bsdmainutils", which is a transitional package on newer version of both Debian and Ubuntu. Closes #11037. (Adapted from commit 54fef433e9f183b9527f82326926c6092c0375b5) --- debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/control b/debian/control index 24d37f3c2..92707ec6b 100644 --- a/debian/control +++ b/debian/control @@ -21,6 +21,7 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell Package: fish Architecture: any Depends: bsdextrautils, +Depends: bsdextrautils | bsdmainutils, file, gettext-base, groff-base, From 8e141070b215927f7392bd5213bc3cc977179242 Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Wed, 8 Jan 2025 09:25:36 -0800 Subject: [PATCH 047/113] completions: add `fish-lsp` (#11017) (cherry picked from commit 7970ca55af5dab5d47729bc2e3fa2a646305faae) --- share/completions/fish-lsp.fish | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 share/completions/fish-lsp.fish diff --git a/share/completions/fish-lsp.fish b/share/completions/fish-lsp.fish new file mode 100644 index 000000000..de974ea8e --- /dev/null +++ b/share/completions/fish-lsp.fish @@ -0,0 +1,2 @@ +__fish_cache_sourced_completions fish-lsp complete +or fish-lsp complete | source From 806734cc568e18def51eb7cb2fd8a9e42524bde0 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 14 Jan 2025 19:58:26 +0100 Subject: [PATCH 048/113] Make new ctrl-c behavior "clear-commandline" And leave the old behavior under the name "cancel-commandline". This renames "cancel-commandline-traditional" back to "cancel-commandline", so the old name triggers the old behavior. Fixes #10935 --- CHANGELOG.rst | 2 ++ doc_src/cmds/bind.rst | 3 +++ share/functions/__fish_shared_key_bindings.fish | 2 +- share/functions/fish_vi_key_bindings.fish | 2 +- src/input.rs | 2 +- src/input_common.rs | 2 +- src/reader.rs | 9 +++++---- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 7a059d429..06fbda85d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,6 +12,8 @@ Changes since 4.0b1 - Remove the completions for ``dust`` because it conflicted with the Debian/Ubuntu package (:issue:`10922`). - Improve the documentation style for narrow interfaces (like phones) (:issue:`10942`). - Add debug information back to cmake builds with the "RelWithDebInfo" profile (:issue:`10959`). +- the :kbd:`ctrl-c` binding now calls a new bind function called "clear-commandline", + the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) fish 4.0b1 (released December 17, 2024) diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index e62a27fff..ceb4972c7 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -170,6 +170,9 @@ The following special input functions are available: ``capitalize-word`` make the current word begin with a capital letter +``clear-commandline`` + empty the entire commandline + ``clear-screen`` clears the screen and redraws the prompt. if the terminal doesn't support clearing the screen it is the same as ``repaint``. diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 21febbeba..26be8e392 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -67,7 +67,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod bind --preset $argv alt-o __fish_preview_current_file bind --preset $argv alt-w __fish_whatis_current_token bind --preset $argv ctrl-l clear-screen - bind --preset $argv ctrl-c cancel-commandline + bind --preset $argv ctrl-c clear-commandline bind --preset $argv ctrl-u backward-kill-line bind --preset $argv ctrl-k kill-line bind --preset $argv ctrl-w backward-kill-path-component diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 0a1ef6a9a..cb8428e17 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -64,7 +64,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' # Default (command) mode bind -s --preset :,q exit - bind -s --preset -m insert ctrl-c cancel-commandline repaint-mode + bind -s --preset -m insert ctrl-c clear-commandline repaint-mode bind -s --preset -M default h backward-char bind -s --preset -M default l forward-char bind -s --preset -m insert enter execute diff --git a/src/input.rs b/src/input.rs index fdca0f863..537074677 100644 --- a/src/input.rs +++ b/src/input.rs @@ -146,8 +146,8 @@ const fn make_md(name: &'static wstr, code: ReadlineCmd) -> InputFunctionMetadat make_md(L!("beginning-of-line"), ReadlineCmd::BeginningOfLine), make_md(L!("cancel"), ReadlineCmd::Cancel), make_md(L!("cancel-commandline"), ReadlineCmd::CancelCommandline), - make_md(L!("cancel-commandline-traditional"), ReadlineCmd::CancelCommandlineTraditional), make_md(L!("capitalize-word"), ReadlineCmd::CapitalizeWord), + make_md(L!("clear-commandline"), ReadlineCmd::ClearCommandline), make_md(L!("clear-screen"), ReadlineCmd::ClearScreenAndRepaint), make_md(L!("complete"), ReadlineCmd::Complete), make_md(L!("complete-and-search"), ReadlineCmd::CompleteAndSearch), diff --git a/src/input_common.rs b/src/input_common.rs index 1618d62b3..abea88e6d 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -122,8 +122,8 @@ pub enum ReadlineCmd { ExpandAbbr, DeleteOrExit, Exit, + ClearCommandline, CancelCommandline, - CancelCommandlineTraditional, Cancel, Undo, Redo, diff --git a/src/reader.rs b/src/reader.rs index fe118ae6b..013115898 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -2309,7 +2309,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { self.data .update_buff_pos(EditableLineTag::Commandline, Some(self.command_line_len())); } - rl::CancelCommandline | rl::CancelCommandlineTraditional => { + rl::CancelCommandline | rl::ClearCommandline => { if self.conf.exit_on_interrupt { self.parser .set_last_statuses(Statuses::just(STATUS_CMD_ERROR.unwrap())); @@ -2319,10 +2319,11 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { if self.command_line.is_empty() { return; } - if c == rl::CancelCommandlineTraditional { + if c == rl::CancelCommandline { // Move cursor to the end of the line. let end = self.command_line.len(); self.update_buff_pos(EditableLineTag::Commandline, Some(end)); + self.autosuggestion.clear(); // Repaint also changes the actual cursor position if self.is_repaint_needed(None) { @@ -2346,7 +2347,7 @@ fn handle_readline_command(&mut self, c: ReadlineCmd) { EditableLineTag::Commandline, Edit::new(0..self.command_line_len(), L!("").to_owned()), ); - if c == rl::CancelCommandlineTraditional { + if c == rl::CancelCommandline { self.screen .reset_abandoning_line(usize::try_from(termsize_last().width).unwrap()); } @@ -5042,7 +5043,7 @@ fn command_ends_paging(c: ReadlineCmd, focused_on_search_field: bool) -> bool { | rl::AcceptAutosuggestion | rl::DeleteOrExit | rl::CancelCommandline - | rl::CancelCommandlineTraditional + | rl::ClearCommandline | rl::Cancel => // These commands always end paging. { From d2bfb516112d5323c34e55aeca44116d69a6f070 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 14 Jan 2025 20:08:12 +0100 Subject: [PATCH 049/113] Workaround Kitty spamming the log for ModifyOtherKeys Fixes #11040 --- src/input_common.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/input_common.rs b/src/input_common.rs index abea88e6d..d8befb2a3 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -435,6 +435,7 @@ pub fn update_wait_on_sequence_key_ms(vars: &EnvStack) { pub static IN_MIDNIGHT_COMMANDER_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_ITERM_PRE_CSI_U: RelaxedAtomicBool = RelaxedAtomicBool::new(false); static IN_JETBRAINS: RelaxedAtomicBool = RelaxedAtomicBool::new(false); +static IN_KITTY: RelaxedAtomicBool = RelaxedAtomicBool::new(false); pub fn terminal_protocol_hacks() { use std::env::var_os; @@ -453,6 +454,8 @@ pub fn terminal_protocol_hacks() { var_os("TERMINAL_EMULATOR") .is_some_and(|term| term.as_os_str().as_bytes() == b"JetBrains-JediTerm"), ); + IN_KITTY + .store(var_os("TERM").is_some_and(|term| term.as_os_str().as_bytes() == b"xterm-kitty")); } fn parse_version(version: &wstr) -> Option<(i64, i64, i64)> { @@ -486,6 +489,13 @@ pub fn terminal_protocols_enable_ifn() { } else if IN_JETBRAINS.load() { // Jetbrains IDE terminals vomit CSI u concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b=",) + } else if IN_KITTY.load() { + // Kitty spams the log for modifyotherkeys + concat!( + "\x1b[?2004h", // Bracketed paste + "\x1b[=5u", // CSI u with kitty progressive enhancement + "\x1b=", // set application keypad mode, so the keypad keys send unique codes + ) } else { concat!( "\x1b[?2004h", // Bracketed paste @@ -510,6 +520,13 @@ pub(crate) fn terminal_protocols_disable_ifn() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",) } else if IN_JETBRAINS.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) + } else if IN_KITTY.load() { + // Kitty spams the log for modifyotherkeys + concat!( + "\x1b[?2004l", // Bracketed paste + "\x1b[=0u", // CSI u with kitty progressive enhancement + "\x1b>", // application keypad mode + ) } else { concat!( "\x1b[?2004l", // Bracketed paste From 8c92ea16428bce6d4809172f1f9458e9a26b6e91 Mon Sep 17 00:00:00 2001 From: Daniel Fleischer Date: Sat, 11 Jan 2025 05:21:54 +0200 Subject: [PATCH 050/113] Add lazygit completions (#11019) (cherry picked from commit 29c45100fa9ebecbab4d7a2a4532bf9c96e3a1f4) --- share/completions/lazygit.fish | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 share/completions/lazygit.fish diff --git a/share/completions/lazygit.fish b/share/completions/lazygit.fish new file mode 100644 index 000000000..d0b50b557 --- /dev/null +++ b/share/completions/lazygit.fish @@ -0,0 +1,20 @@ +complete -c lazygit -xa "status branch log stash" +complete -c lazygit -s h -l help -d 'Display help' +complete -c lazygit -s v -l version -d 'Print version' +complete -c lazygit -s p -l path -d 'Path of git repo' -xa "(__fish_complete_directories)" + +# Config +complete -c lazygit -s c -l config -d 'Print the default config' +complete -c lazygit -o cd -l print-config-dir -d 'Print the config directory' +complete -c lazygit -o ucd -l use-config-dir -d 'Override default config directory with provided directory' -r +complete -c lazygit -o ucf -l use-config-file -d 'Comma separated list to custom config file(s)' -r + +# Git +complete -c lazygit -s f -l filter -d 'Path to filter on in `git log -- `' -r +complete -c lazygit -s g -l git-dir -d 'Equivalent of the --git-dir git argument' -r +complete -c lazygit -s w -l work-tree -d 'Equivalent of the --work-tree git argument' -xa "(__fish_complete_directories)" + +# Debug +complete -c lazygit -s d -l debug -d 'Run in debug mode with logging' +complete -c lazygit -s l -l logs -d 'Tail lazygit logs; used with --debug' +complete -c lazygit -l profile -d 'Start the profiler and serve it on http port 6060' From 452aa6c61427af3b23f6ec874d64f9dfc7277536 Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 15 Jan 2025 22:11:28 +0800 Subject: [PATCH 051/113] feature_flags: update target release for 3.8 flags to 4.0 (cherry picked from commit 24abbb6de7f0444340e27cde798f4a6d74a089f9) --- src/future_feature_flags.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/future_feature_flags.rs b/src/future_feature_flags.rs index 429baa8c9..503da62bd 100644 --- a/src/future_feature_flags.rs +++ b/src/future_feature_flags.rs @@ -94,7 +94,7 @@ pub struct FeatureMetadata { FeatureMetadata { flag: FeatureFlag::remove_percent_self, name: L!("remove-percent-self"), - groups: L!("3.8"), + groups: L!("4.0"), description: L!("%self is no longer expanded (use $fish_pid)"), default_value: false, read_only: false, @@ -102,7 +102,7 @@ pub struct FeatureMetadata { FeatureMetadata { flag: FeatureFlag::test_require_arg, name: L!("test-require-arg"), - groups: L!("3.8"), + groups: L!("4.0"), description: L!("builtin test requires an argument"), default_value: false, read_only: false, From 45439f07d7507566d4fd19600accf310e67d38d1 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 16 Jan 2025 13:37:55 +0100 Subject: [PATCH 052/113] Update tests and docs for 4.0 target --- doc_src/language.rst | 10 +++++----- tests/checks/status.fish | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc_src/language.rst b/doc_src/language.rst index 008469e30..2d3cfb3cc 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -2022,17 +2022,17 @@ You can see the current list of features via ``status features``:: qmark-noglob on 3.0 ? no longer globs regex-easyesc on 3.1 string replace -r needs fewer \\'s ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separating character - remove-percent-self off 3.8 %self is no longer expanded (use $fish_pid) - test-require-arg off 3.8 builtin test requires an argument + remove-percent-self off 4.0 %self is no longer expanded (use $fish_pid) + test-require-arg off 4.0 builtin test requires an argument Here is what they mean: - ``stderr-nocaret`` was introduced in fish 3.0 (and made the default in 3.3). It makes ``^`` an ordinary character instead of denoting an stderr redirection, to make dealing with quoting and such easier. Use ``2>`` instead. This can no longer be turned off since fish 3.5. The flag can still be tested for compatibility, but a ``no-stderr-nocaret`` value will simply be ignored. -- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 3.8). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. +- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 4.0). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. - ``regex-easyesc`` was introduced in 3.1. It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere. - ``ampersand-nobg-in-token`` was introduced in fish 3.4. It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already. -- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 3.8. To get fish's pid, you can use the :envvar:`fish_pid` variable. -- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 3.8. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. +- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable. +- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 4.0. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. These changes are introduced off by default. They can be enabled on a per session basis:: diff --git a/tests/checks/status.fish b/tests/checks/status.fish index 0a1089fae..3b2973268 100644 --- a/tests/checks/status.fish +++ b/tests/checks/status.fish @@ -57,8 +57,8 @@ status features #CHECK: qmark-noglob on 3.0 ? no longer globs #CHECK: regex-easyesc on 3.1 string replace -r needs fewer \'s #CHECK: ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separator -#CHECK: remove-percent-self off 3.8 %self is no longer expanded (use $fish_pid) -#CHECK: test-require-arg off 3.8 builtin test requires an argument +#CHECK: remove-percent-self off 4.0 %self is no longer expanded (use $fish_pid) +#CHECK: test-require-arg off 4.0 builtin test requires an argument status test-feature stderr-nocaret echo $status #CHECK: 0 From 28fb5b5207910660ed8852b6169360d9a47a61a4 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 17 Jan 2025 09:52:53 +0100 Subject: [PATCH 053/113] Fix error for "fish --foo" without option argument Wgetopt needs a ":" at the beginning to turn on this type of error. I'm not sure why that is now, and we might want to change it (but tbh wgetopt could do with a replacement anyway). Fixes #11049 --- src/bin/fish.rs | 2 +- tests/checks/invocation.fish | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/fish.rs b/src/bin/fish.rs index 0a7105b17..2a06f3a2c 100644 --- a/src/bin/fish.rs +++ b/src/bin/fish.rs @@ -532,7 +532,7 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> ControlFlow] = &[ wopt(L!("command"), RequiredArgument, 'c'), wopt(L!("init-command"), RequiredArgument, 'C'), diff --git a/tests/checks/invocation.fish b/tests/checks/invocation.fish index 19d20562f..dea961559 100644 --- a/tests/checks/invocation.fish +++ b/tests/checks/invocation.fish @@ -111,5 +111,8 @@ $fish --no-config -c 'echo notprinted | and true' # CHECKERR: echo notprinted | and true # CHECKERR: ^~^ +$fish --no-config --features +# CHECKERR: fish: --features: option requires an argument + # Regression test for a hang. echo "set -L" | $fish > /dev/null From 1c110552413fce035c94e80ace5bfa4e9f216535 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 16 Jan 2025 19:32:15 +0100 Subject: [PATCH 054/113] Don't clone argv for builtins We capture the process already, and we use argv by reference for the other cases. argv can be big, and this reduces allocations and thereby memory usage and speed. E.g. `set -l foo **` with 200k matches has 25% reduced memory usage and ~5% reduced runtime. --- src/exec.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/exec.rs b/src/exec.rs index 0d8362498..0b9e9b7ba 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -1106,7 +1106,6 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box Box, errput_stream: Option<&mut OutputStream>| { let output_stream = output_stream.unwrap(); @@ -1151,8 +1150,11 @@ fn get_performer_for_builtin(p: &Process, j: &Job, io_chain: &IoChain) -> Box = - argv.iter().map(|s| truncate_at_nul(s.as_ref())).collect(); + let mut shim_argv: Vec<&wstr> = p + .argv() + .iter() + .map(|s| truncate_at_nul(s.as_ref())) + .collect(); builtin_run(parser, &mut shim_argv, &mut streams) }, ) From 4024d824125b98dc7054126156c4a7135f1ec331 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 19 Jan 2025 17:13:05 +0100 Subject: [PATCH 055/113] Fix double expansion of tokenized command line Commit 798527d79a (completions: fix double evaluation of tokenized commandline, 2024-01-06) fixed some completions such as the "watchexec" ones by adding "string escape" here: set argv (commandline -opc | string escape) (commandline -ct) This fixed double evaluation when we later call `complete -C"$argv"`. Unfortunately -- searching for "complete -C" and "__fish_complete_subcommand" -- it seems like that commit missed some completions such as sudo. Fix them the same way. Alternatively, we could defer expansion of those arguments (via --tokens-raw), since the recursive call to completion will expand them anyway, and we don't really need to know their value. But there are (contrived) examples where we do want to expand first, to correctly figure out where the subcommand starts: sudo {-u,someuser} make ins By definition, the tokens returned by `commandline -opc` do not contain the token at cursor (which we're currently completing). So the expansion should not hurt us. There is an edge case where cartesian product expansion would produce too many results, and we pass on the unexpanded input. In that case the extra escaping is very unlikely to have negative effects. Fixes # 11041 Closes # 11067 Co-authored-by: kerty --- share/completions/doas.fish | 2 +- share/completions/env.fish | 2 +- share/completions/ip.fish | 2 +- share/completions/sudo.fish | 2 +- share/completions/svn.fish | 3 +-- share/completions/yadm.fish | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) diff --git a/share/completions/doas.fish b/share/completions/doas.fish index e754f7dc7..c7dc68d3e 100644 --- a/share/completions/doas.fish +++ b/share/completions/doas.fish @@ -3,7 +3,7 @@ # function __fish_doas_print_remaining_args - set -l tokens (commandline -xpc) (commandline -ct) + set -l tokens (commandline -xpc | string escape) (commandline -ct) set -e tokens[1] # These are all the options mentioned in the man page for openbsd's "doas" (in that order). set -l opts a= C= L n s u= diff --git a/share/completions/env.fish b/share/completions/env.fish index 838296501..64794826e 100644 --- a/share/completions/env.fish +++ b/share/completions/env.fish @@ -62,7 +62,7 @@ end # Get the text after all env arguments and variables, so we can complete it as a regular command function __fish_env_remaining_args -V is_gnu - set -l argv (commandline -xpc) (commandline -ct) + set -l argv (commandline -xpc | string escape) (commandline -ct) if set -q is_gnu[1] argparse -s i/ignore-environment u/unset= help version -- $argv 2>/dev/null or return 0 diff --git a/share/completions/ip.fish b/share/completions/ip.fish index ff3d530de..5e47170cf 100644 --- a/share/completions/ip.fish +++ b/share/completions/ip.fish @@ -14,7 +14,7 @@ set -l ip_all_commands $ip_commands $ip_addr $ip_link $ip_neigh $ip_route $ip_ru function __fish_ip_commandwords set -l skip 0 - set -l cmd (commandline -xpc) + set -l cmd (commandline -xpc | string escape) # Remove the first word because it's "ip" or an alias for it set -e cmd[1] set -l have_command 0 diff --git a/share/completions/sudo.fish b/share/completions/sudo.fish index dabb69ff2..4e64afc18 100644 --- a/share/completions/sudo.fish +++ b/share/completions/sudo.fish @@ -3,7 +3,7 @@ # function __fish_sudo_print_remaining_args - set -l tokens (commandline -xpc) (commandline -ct) + set -l tokens (commandline -xpc | string escape) (commandline -ct) set -e tokens[1] # These are all the options mentioned in the man page for Todd Miller's "sudo.ws" sudo (in that order). # If any other implementation has different options, this should be harmless, since they shouldn't be used anyway. diff --git a/share/completions/svn.fish b/share/completions/svn.fish index 7ae4903d1..507c2d1a2 100644 --- a/share/completions/svn.fish +++ b/share/completions/svn.fish @@ -1,6 +1,5 @@ function __fish_complete_svn_diff --description 'Complete "svn diff" arguments' - set -l cmdl (commandline -cxp) - #set -l cmdl svn diff --diff-cmd diff --extensions '-a -b' + set -l cmdl (commandline -cxp | string escape) set -l diff diff set -l args while set -q cmdl[1] diff --git a/share/completions/yadm.fish b/share/completions/yadm.fish index f542f90fc..d5c50d50c 100644 --- a/share/completions/yadm.fish +++ b/share/completions/yadm.fish @@ -51,7 +51,7 @@ end # don't want to inherit all completions from git function __fish_complete_yadm_like_git # Remove the first word from the commandline because that is "yadm" - set -l cmdline (commandline -xpc; commandline -ct)[2..-1] + set -l cmdline (commandline -xpc | string escape; commandline -ct)[2..-1] # `yadm gitconfig` is same as `git config` if __fish_seen_subcommand_from gitconfig From 4c9dfcc5d7177a2fa5cb5fff8e788c29f26806e7 Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 21 Jan 2025 00:06:40 +0800 Subject: [PATCH 056/113] CHANGELOG: work on 4.0.0 --- CHANGELOG.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 06fbda85d..ceedbcf68 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -21,7 +21,7 @@ fish 4.0b1 (released December 17, 2024) These are the draft release notes for fish 4.0.0. Like this release of fish itself, they are in beta and are not complete. Please report any issues you find. -.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9751 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10707 10708 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10899 10906 10907 10911 10913 10922 10923 10944 10945 10951 10971 10994 10995 10999 +.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10899 10906 10907 10911 10913 10922 10923 10943 10944 10945 10947 10951 10971 10994 10995 10999 11002 11014 11015 11016 11026 11034 11035 11037 11040 11041 11049 11067 fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. @@ -85,7 +85,7 @@ Notable improvements and fixes For example, ``commandline -i foo; commandline | grep foo`` succeeds now. - Undo history is no longer truncated after every command, but kept for the lifetime of the shell process. - The :kbd:`ctrl-r` history search now uses glob syntax (:issue:`10131`). -- The :kbd:`ctrl-r` history search now operates only on the line or command substitution at cursor, making it easier to combine commands from history. +- The :kbd:`ctrl-r` history search now operates only on the line or command substitution at cursor, making it easier to combine commands from history (:issue:`9751`). - Abbreviations can now be restricted to specific commands. For instance:: abbr --add --command git back 'reset --hard HEAD^' @@ -166,6 +166,8 @@ Interactive improvements - Command lines which are larger than the terminal are now displayed correctly, instead of multiple blank lines being displayed (:issue:`7296`). - Prompts that use external commands will no longer produce an infinite loop if the command crashes (:issue:`9796`). - Undo (:kbd:`ctrl-z`) restores the cursor position too (:issue:`10838`). +- The Web-based configuration removes old right-hand-side prompts again, fixing a regression in fish 3.4.0 (:issue:`10675`). +- Further protection against programs which crash and leave the terminal in an inconsistent state (:issue:`10834`, :issue:`11038`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -202,6 +204,7 @@ New or improved bindings - Added bindings for clipboard interaction, like :kbd:`",+,p` and :kbd:`",+,y,y`. - Deleting in visual mode now moves the cursor back, matching vi (:issue:`10394`). - Support :kbd:`%` motion (:issue:`10593`). + - :kbd:`ctrl-k` to remove the contents of the line beyond the cursor in all modes (:issue:`10648`). - Support `ab` and `ib` vi text objects. New input functions are introduced ``jump-{to,till}-matching-bracket`` (:issue:`1842`). - The :kbd:`E` binding now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`). From fd3ed7cfa55fd07ed17fe065c26e45debe8ed0fc Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 22 Jan 2025 17:43:59 +0100 Subject: [PATCH 057/113] functions/__fish_cancel_commandline: Follow rename of bind function See #10935 --- share/functions/__fish_cancel_commandline.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/functions/__fish_cancel_commandline.fish b/share/functions/__fish_cancel_commandline.fish index 6d1a37dc2..a5f1290ec 100644 --- a/share/functions/__fish_cancel_commandline.fish +++ b/share/functions/__fish_cancel_commandline.fish @@ -1,4 +1,4 @@ # This is meant to be bound to something like ctrl-c function __fish_cancel_commandline - commandline -f cancel-commandline-traditional + commandline -f cancel-commandline end From 8eb5e36aa6d3de5d0085c1a22e7b4b2fd905b907 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 11 Jan 2025 12:07:19 +0100 Subject: [PATCH 058/113] Swap code blocks for completing separator suffix resp. whole token Mainly to make the next commit's diff smaller. Not much functional change: since file completions never have the DONT_SORT flag set, these results will be sorted, and there are no data dependencies -- unless we're overflowing the max number of completions. But in that case the whole-token completions seem more important anyway. (cherry picked from commit 0cfc95993a8e79de108cdc4970a623b746e34c04) --- src/complete.rs | 74 +++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/src/complete.rs b/src/complete.rs index e7809df57..5639c42bc 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -1584,43 +1584,8 @@ fn complete_param_expand( }; let complete_from_start = sep_index.is_none() || !string_prefixes_string(L!("-"), s); - if let Some(sep_index) = sep_index { - let sep_string = s.slice_from(sep_index + 1); - let mut local_completions = Vec::new(); - if matches!( - expand_string( - sep_string.to_owned(), - &mut local_completions, - flags, - self.ctx, - None, - ) - .result, - ExpandResultCode::error | ExpandResultCode::overflow - ) { - FLOGF!(complete, "Error while expanding string '%ls'", sep_string); - } - - // Any COMPLETE_REPLACES_TOKEN will also stomp the separator. We need to "repair" them by - // inserting our separator and prefix. - Self::escape_opening_brackets(&mut local_completions, s); - Self::escape_separators( - &mut local_completions, - variable_override_prefix, - self.flags.autosuggestion, - true, - quoted, - ); - let prefix_with_sep = s.as_char_slice()[..sep_index + 1].into(); - for comp in &mut local_completions { - comp.prepend_token_prefix(prefix_with_sep); - } - if !self.completions.extend(local_completions) { - return; - } - } - if complete_from_start { + let mut flags = flags; // Don't do fuzzy matching for files if the string begins with a dash (issue #568). We could // consider relaxing this if there was a preceding double-dash argument. if string_prefixes_string(L!("-"), s) { @@ -1645,6 +1610,43 @@ fn complete_param_expand( quoted, ); } + + let Some(sep_index) = sep_index else { + return; + }; + let sep_string = s.slice_from(sep_index + 1); + let mut local_completions = Vec::new(); + if matches!( + expand_string( + sep_string.to_owned(), + &mut local_completions, + flags, + self.ctx, + None, + ) + .result, + ExpandResultCode::error | ExpandResultCode::overflow + ) { + FLOGF!(complete, "Error while expanding string '%ls'", sep_string); + } + + // Any COMPLETE_REPLACES_TOKEN will also stomp the separator. We need to "repair" them by + // inserting our separator and prefix. + Self::escape_opening_brackets(&mut local_completions, s); + Self::escape_separators( + &mut local_completions, + variable_override_prefix, + self.flags.autosuggestion, + true, + quoted, + ); + let prefix_with_sep = s.as_char_slice()[..sep_index + 1].into(); + for comp in &mut local_completions { + comp.prepend_token_prefix(prefix_with_sep); + } + if !self.completions.extend(local_completions) { + return; + } } fn escape_separators( From 92582d5b1fa6b6cdc8236211e81d39f42396f26b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Fri, 10 Jan 2025 21:18:10 +0100 Subject: [PATCH 059/113] Back out "Escape : and = in file completions" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If you don't care about file paths containing '=' or ':', you can stop reading now. In tokens like env var=/some/path PATH=/bin:/usr/local/b file completion starts after the last separator (#2178). Commit db365b5ef8 (Do not treat \: or \= as file completion anchor, 2024-04-19) allowed to override this behavior by escaping separators, matching Bash. Commit e97a4fab71 (Escape : and = in file completions, 2024-04-19) adds this escaping automatically (also matching Bash). The automatic escaping can be jarring and confusing, because separators have basically no special meaning in the tokenizer; the escaping is purely a hint to the completion engine, and often unnecessary. For "/path/to/some:file", we compute completions for "file" and for "/path/to/some:file". Usually the former already matches nothing, meaning that escaping isn't necessary. e97a4fab71 refers us to f7dac82ed6 (Escape separators (colon and equals) to improve completion, 2019-08-23) for the original motivation: $ ls /sys/bus/acpi/devices/d $ ls /sys/bus/acpi/devices/device: device:00/ device:0a/ … Before automatic escaping, this scenario would suggest all files from $PWD in addition to the expected completions shown above. Since this seems to be mainly about the case where the suffix after the separator is empty, Let's remove the automatic escaping and add a heuristic to skip suffix completions if: 1. the suffix is empty, to specifically address the above case. 2. the whole token completes to at least one appending completion. This makes sure that "git log -- :!:" still gets completions. (Not sure about the appending requirement) This heuristic is probably too conservative; we can relax it later should we hit this again. Since this reverts most of e97a4fab71, we address the code clone pointed out in 421ce13be6 (Fix replacing completions spuriously quoting ~, 2024-12-06). Note that e97a4fab71 quietly fixed completions for variable overrides with brackets. a=bracket[ But it did so in a pretty intrusive way, forcing a lot of completions to become replacing. Let's move this logic to a more appropriate place. --- Additionally, we could sort every whole-token completion before every suffix-completion. That would probably improve the situation further, but by itself it wouldn't address the immediate issue. Closes #11027 (cherry picked from commit b6c249be0c4f075a9e7d65f94fd1677da2c58e72) --- CHANGELOG.rst | 7 ++-- src/common.rs | 12 +----- src/complete.rs | 82 +++++++++++++---------------------------- src/reader.rs | 16 ++++++-- src/tests/complete.rs | 86 +++++++++++++++++++++---------------------- 5 files changed, 85 insertions(+), 118 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index ceedbcf68..979887e01 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -214,11 +214,12 @@ Completions - Option completion now uses fuzzy subsequence filtering, just like non-option completion (:issue:`830`). This means that ``--fb`` may be completed to ``--foobar`` if there is no better match. - Completions that insert an entire token now use quotes instead of backslashes to escape special characters (:issue:`5433`). -- Historically, file name completions are provided after the last ``:`` or ``=`` within a token. +- Normally, file name completions start after the last ``:`` or ``=`` in a token. This helps commands like ``rsync --files-from=``. - If the ``=`` or ``:`` is actually part of the filename, it will be escaped as ``\:`` and ``\=``, - and no longer get this special treatment. + This special meaning can now disabled by escaping these separators as ``\:`` and ``\=``. This matches Bash's behavior. + Note that this escaping is usually not necessary since the completion engine already tries + to guess whether the separator is actually part of a file name. - Various new completion scripts and numerous updates to existing ones. - Generated completions are now stored in ``$XDG_CACHE_HOME/fish`` or ``~/.cache/fish`` by default (:issue:`10369`) - A regression in fish 3.1, where completing a command line could change it completely, has been fixed (:issue:`10904`). diff --git a/src/common.rs b/src/common.rs index 213723ffb..2d339299c 100644 --- a/src/common.rs +++ b/src/common.rs @@ -119,10 +119,8 @@ pub struct EscapeFlags: u32 { const NO_TILDE = 1 << 2; /// Replace non-printable control characters with Unicode symbols. const SYMBOLIC = 1 << 3; - /// Escape : and = - const SEPARATORS = 1 << 4; /// Escape , - const COMMA = 1 << 5; + const COMMA = 1 << 4; } } @@ -183,7 +181,6 @@ pub fn escape_string(s: &wstr, style: EscapeStringStyle) -> WString { /// Escape a string in a fashion suitable for using in fish script. fn escape_string_script(input: &wstr, flags: EscapeFlags) -> WString { let escape_printables = !flags.contains(EscapeFlags::NO_PRINTABLES); - let escape_separators = flags.contains(EscapeFlags::SEPARATORS); let escape_comma = flags.contains(EscapeFlags::COMMA); let no_quoted = flags.contains(EscapeFlags::NO_QUOTED); let no_tilde = flags.contains(EscapeFlags::NO_TILDE); @@ -295,13 +292,6 @@ fn escape_string_script(input: &wstr, flags: EscapeFlags) -> WString { ANY_STRING_RECURSIVE => { out += L!("**"); } - ':' | '=' => { - if escape_separators { - need_escape = true; - out.push('\\'); - } - out.push(c); - } ',' => { if escape_comma { need_escape = true; diff --git a/src/complete.rs b/src/complete.rs index 5639c42bc..1a23c1116 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -10,7 +10,7 @@ }; use crate::{ - common::{charptr2wcstring, escape_string, EscapeFlags, EscapeStringStyle}, + common::charptr2wcstring, reader::{get_quote, is_backslashed}, util::wcsfilecmp, wutil::sprintf, @@ -96,7 +96,7 @@ pub struct CompletionMode { bitflags! { #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] - pub struct CompleteFlags: u8 { + pub struct CompleteFlags: u16 { /// Do not insert space afterwards if this is the only completion. (The default is to try insert /// a space). const NO_SPACE = 1 << 0; @@ -115,6 +115,8 @@ pub struct CompleteFlags: u8 { const DUPLICATES_ARGUMENT = 1 << 6; /// This completes not just a token but replaces an entire line. const REPLACES_LINE = 1 << 7; + /// If replacing the entire token, keep the "foo=" prefix. + const KEEP_VARIABLE_OVERRIDE_PREFIX = 1 << 8; } } @@ -737,13 +739,16 @@ fn perform_for_commandline_impl(&mut self, cmdline: WString) { if cmd_tok.location_in_or_at_end_of_source_range(cursor_pos) { let equals_sign_pos = variable_assignment_equals_pos(current_token); if let Some(pos) = equals_sign_pos { + let first = self.completions.len(); self.complete_param_expand( - ¤t_token[..pos + 1], ¤t_token[pos + 1..], /*do_file=*/ true, /*handle_as_special_cd=*/ false, cur_tok.is_unterminated_brace, ); + for c in &mut self.completions[first..] { + c.flags |= CompleteFlags::KEEP_VARIABLE_OVERRIDE_PREFIX; + } return; } // Complete command filename. @@ -842,7 +847,6 @@ fn perform_for_commandline_impl(&mut self, cmdline: WString) { // This function wants the unescaped string. self.complete_param_expand( - L!(""), current_argument, do_file, handle_as_special_cd, @@ -1524,7 +1528,6 @@ fn complete_param_for_command( /// Perform generic (not command-specific) expansions on the specified string. fn complete_param_expand( &mut self, - variable_override_prefix: &wstr, s: &wstr, do_file: bool, handle_as_special_cd: bool, @@ -1565,8 +1568,7 @@ fn complete_param_expand( // foo=bar => expand the whole thing, and also just bar // // We also support colon separator (#2178). If there's more than one, prefer the last one. - let quoted = get_quote(s, s.len()).is_some(); - let sep_index = if quoted { + let sep_index = if get_quote(s, s.len()).is_some() { None } else { let mut end = s.len(); @@ -1584,6 +1586,7 @@ fn complete_param_expand( }; let complete_from_start = sep_index.is_none() || !string_prefixes_string(L!("-"), s); + let first_from_start = self.completions.len(); if complete_from_start { let mut flags = flags; // Don't do fuzzy matching for files if the string begins with a dash (issue #568). We could @@ -1592,7 +1595,6 @@ fn complete_param_expand( flags -= ExpandFlags::FUZZY_MATCH; } - let first = self.completions.len(); if matches!( expand_to_receiver(s.to_owned(), &mut self.completions, flags, self.ctx, None) .result, @@ -1600,20 +1602,25 @@ fn complete_param_expand( ) { FLOGF!(complete, "Error while expanding string '%ls'", s); } - Self::escape_opening_brackets(&mut self.completions[first..], s); - let have_token = !s.is_empty(); - Self::escape_separators( - &mut self.completions[first..], - variable_override_prefix, - self.flags.autosuggestion, - have_token, - quoted, - ); + Self::escape_opening_brackets(&mut self.completions[first_from_start..], s); } let Some(sep_index) = sep_index else { return; }; + + // We generally expand both, the whole token ("foo=bar") and also just the "bar" + // suffix. If the whole token is a valid path prefix, completions of just the suffix + // are probably false positives, and are confusing when I'm using completions to list + // directory contents. Apply a wonky heuristic to work around the most visible case -- + // the empty suffix -- where all files in $PWD are completed/autosuggested. + if self.completions[first_from_start..] + .iter() + .any(|c| !c.replaces_token()) + && sep_index + 1 == s.len() + { + return; + } let sep_string = s.slice_from(sep_index + 1); let mut local_completions = Vec::new(); if matches!( @@ -1630,16 +1637,9 @@ fn complete_param_expand( FLOGF!(complete, "Error while expanding string '%ls'", sep_string); } + Self::escape_opening_brackets(&mut local_completions, s); // Any COMPLETE_REPLACES_TOKEN will also stomp the separator. We need to "repair" them by // inserting our separator and prefix. - Self::escape_opening_brackets(&mut local_completions, s); - Self::escape_separators( - &mut local_completions, - variable_override_prefix, - self.flags.autosuggestion, - true, - quoted, - ); let prefix_with_sep = s.as_char_slice()[..sep_index + 1].into(); for comp in &mut local_completions { comp.prepend_token_prefix(prefix_with_sep); @@ -1649,38 +1649,6 @@ fn complete_param_expand( } } - fn escape_separators( - completions: &mut [Completion], - variable_override_prefix: &wstr, - append_only: bool, - have_token: bool, - is_quoted: bool, - ) { - for c in completions { - if is_quoted && !c.replaces_token() { - continue; - } - // clone of completion_apply_to_command_line - let add_space = !c.flags.contains(CompleteFlags::NO_SPACE); - let no_tilde = c.flags.contains(CompleteFlags::DONT_ESCAPE_TILDES); - let mut escape_flags = EscapeFlags::SEPARATORS; - if append_only || !add_space || (!c.replaces_token() && have_token) { - escape_flags.insert(EscapeFlags::NO_QUOTED); - } - if no_tilde { - escape_flags.insert(EscapeFlags::NO_TILDE); - } - if c.replaces_token() { - c.completion = variable_override_prefix.to_owned() - + &escape_string(&c.completion, EscapeStringStyle::Script(escape_flags))[..]; - } else { - c.completion = - escape_string(&c.completion, EscapeStringStyle::Script(escape_flags)); - } - assert!(!c.flags.contains(CompleteFlags::DONT_ESCAPE)); - c.flags |= CompleteFlags::DONT_ESCAPE; - } - } /// Complete the specified string as an environment variable. /// Returns `true` if this was a variable, so we should stop completion. fn complete_variable(&mut self, s: &wstr, start_offset: usize) -> bool { diff --git a/src/reader.rs b/src/reader.rs index 013115898..cdd5619a4 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -120,6 +120,7 @@ Debounce, }; use crate::tokenizer::quote_end; +use crate::tokenizer::variable_assignment_equals_pos; use crate::tokenizer::{ tok_command, MoveWordStateMachine, MoveWordStyle, TokenType, Tokenizer, TOK_ACCEPT_UNFINISHED, TOK_SHOW_COMMENTS, @@ -5570,6 +5571,7 @@ pub fn completion_apply_to_command_line( let do_replace_line = flags.contains(CompleteFlags::REPLACES_LINE); let do_escape = !flags.contains(CompleteFlags::DONT_ESCAPE); let no_tilde = flags.contains(CompleteFlags::DONT_ESCAPE_TILDES); + let keep_variable_override = flags.contains(CompleteFlags::KEEP_VARIABLE_OVERRIDE_PREFIX); let cursor_pos = *inout_cursor_pos; let mut back_into_trailing_quote = false; @@ -5595,19 +5597,27 @@ pub fn completion_apply_to_command_line( } if do_replace_token { - let mut move_cursor; + let mut move_cursor = 0; let mut range = 0..0; parse_util_token_extent(command_line, cursor_pos, &mut range, None); let mut sb = command_line[..range.start].to_owned(); + if keep_variable_override { + let tok = &command_line[range.clone()]; + let separator_pos = variable_assignment_equals_pos(tok).unwrap(); + let key = &tok[..=separator_pos]; + sb.push_utfstr(&key); + move_cursor += key.len(); + } + if do_escape { let escaped = escape_string(val_str, EscapeStringStyle::Script(escape_flags)); sb.push_utfstr(&escaped); - move_cursor = escaped.len(); + move_cursor += escaped.len(); } else { sb.push_utfstr(val_str); - move_cursor = val_str.len(); + move_cursor += val_str.len(); } if add_space { diff --git a/src/tests/complete.rs b/src/tests/complete.rs index 891e41c08..21f267e30 100644 --- a/src/tests/complete.rs +++ b/src/tests/complete.rs @@ -137,6 +137,13 @@ fn test_complete() { assert_eq!(completions.len(), 1); assert_eq!(completions[0].completion, L!("space")); + completions = do_complete( + L!(": test/complete_test/colon:"), + CompletionRequestOptions::default(), + ); + assert_eq!(completions.len(), 1); + assert_eq!(completions[0].completion, L!("abc")); + macro_rules! unique_completion_applies_as { ( $cmdline:expr, $completion_result:expr, $applied:expr $(,)? ) => { let cmdline = L!($cmdline); @@ -168,24 +175,24 @@ macro_rules! unique_completion_applies_as { // Brackets - see #5831 unique_completion_applies_as!( "touch test/complete_test/bracket[", - r"'test/complete_test/bracket[abc]'", + "test/complete_test/bracket[abc]", "touch 'test/complete_test/bracket[abc]' ", ); unique_completion_applies_as!( "echo (ls test/complete_test/bracket[", - r"'test/complete_test/bracket[abc]'", + "test/complete_test/bracket[abc]", "echo (ls 'test/complete_test/bracket[abc]' ", ); #[cfg(not(windows))] // Square brackets are not legal path characters on WIN32/CYGWIN { unique_completion_applies_as!( r"touch test/complete_test/gnarlybracket\\[", - r"'test/complete_test/gnarlybracket\\[abc]'", + r"test/complete_test/gnarlybracket\[abc]", r"touch 'test/complete_test/gnarlybracket\\[abc]' ", ); unique_completion_applies_as!( r"a=test/complete_test/bracket[", - r"a='test/complete_test/bracket[abc]'", + r"test/complete_test/bracket[abc]", r"a='test/complete_test/bracket[abc]' ", ); } @@ -194,13 +201,13 @@ macro_rules! unique_completion_applies_as { { unique_completion_applies_as!( r"touch test/complete_test/colon", - r"\:abc", - r"touch test/complete_test/colon\:abc ", + r":abc", + r"touch test/complete_test/colon:abc ", ); unique_completion_applies_as!( - r"touch test/complete_test/colon\:", + r"touch test/complete_test/colon:", r"abc", - r"touch test/complete_test/colon\:abc ", + r"touch test/complete_test/colon:abc ", ); unique_completion_applies_as!( r#"touch "test/complete_test/colon:"#, @@ -462,9 +469,8 @@ fn test_autosuggest_suggest_special() { let parser = TestParser::new(); macro_rules! perform_one_autosuggestion_cd_test { ($command:literal, $expected:literal, $vars:expr) => { - let command = L!($command); let mut comps = complete( - command, + L!($command), CompletionRequestOptions::autosuggest(), &OperationContext::background($vars, EXPANSION_LIMIT_BACKGROUND), ) @@ -476,15 +482,7 @@ macro_rules! perform_one_autosuggestion_cd_test { if !expects_error { sort_and_prioritize(&mut comps, CompletionRequestOptions::default()); let suggestion = &comps[0]; - let mut cursor = command.len(); - let newcmdline = completion_apply_to_command_line( - &suggestion.completion, - suggestion.flags, - command, - &mut cursor, - /*append_only=*/ true, - ); - assert_eq!(newcmdline.strip_prefix(command).unwrap(), L!($expected)); + assert_eq!(suggestion.completion, L!($expected)); } }; } @@ -552,24 +550,24 @@ macro_rules! perform_one_completion_cd_test { perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/0", "foobar/", &vars); perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/0", "foobar/", &vars); perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/0", "foobar/", &vars); - perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/1", r"foo\ bar/", &vars); - perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/1", r"foo bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/1", r"foo bar/", &vars); - perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/2", r"foo\ \ bar/", &vars); - perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/2", r"foo bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/2", r"foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/1", "foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/1", "foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/1", "foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/2", "foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/2", "foo bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/2", "foo bar/", &vars); #[cfg(not(windows))] { - perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/3", r"foo\\bar/", &vars); - perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/3", r"foo\\bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/3", r"foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/3", "foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/3", "foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/3", "foo\\bar/", &vars); } - perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/4", r"foo\'bar/", &vars); + perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/4", "foo'bar/", &vars); perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/4", "foo'bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/4", r"foo\'bar/", &vars); - perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/5", r#"foo\"bar/"#, &vars); - perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/5", r#"foo\"bar/"#, &vars); - perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/5", r#"foo"bar/"#, &vars); + perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/4", "foo'bar/", &vars); + perform_one_autosuggestion_cd_test!("cd test/autosuggest_test/5", "foo\"bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"test/autosuggest_test/5", "foo\"bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 'test/autosuggest_test/5", "foo\"bar/", &vars); vars.parent .vars @@ -589,24 +587,24 @@ macro_rules! perform_one_completion_cd_test { perform_one_autosuggestion_cd_test!("cd 0", "foobar/", &vars); perform_one_autosuggestion_cd_test!("cd \"0", "foobar/", &vars); perform_one_autosuggestion_cd_test!("cd '0", "foobar/", &vars); - perform_one_autosuggestion_cd_test!("cd 1", r"foo\ bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 1", "foo bar/", &vars); perform_one_autosuggestion_cd_test!("cd \"1", "foo bar/", &vars); perform_one_autosuggestion_cd_test!("cd '1", "foo bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 2", r"foo\ \ bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 2", "foo bar/", &vars); perform_one_autosuggestion_cd_test!("cd \"2", "foo bar/", &vars); perform_one_autosuggestion_cd_test!("cd '2", "foo bar/", &vars); #[cfg(not(windows))] { - perform_one_autosuggestion_cd_test!("cd 3", r"foo\\bar/", &vars); - perform_one_autosuggestion_cd_test!("cd \"3", r"foo\\bar/", &vars); - perform_one_autosuggestion_cd_test!("cd '3", r"foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 3", "foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"3", "foo\\bar/", &vars); + perform_one_autosuggestion_cd_test!("cd '3", "foo\\bar/", &vars); } - perform_one_autosuggestion_cd_test!("cd 4", r"foo\'bar/", &vars); - perform_one_autosuggestion_cd_test!("cd \"4", r"foo'bar/", &vars); - perform_one_autosuggestion_cd_test!("cd '4", r"foo\'bar/", &vars); - perform_one_autosuggestion_cd_test!("cd 5", r#"foo\"bar/"#, &vars); - perform_one_autosuggestion_cd_test!("cd \"5", r#"foo\"bar/"#, &vars); - perform_one_autosuggestion_cd_test!("cd '5", r#"foo"bar/"#, &vars); + perform_one_autosuggestion_cd_test!("cd 4", "foo'bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"4", "foo'bar/", &vars); + perform_one_autosuggestion_cd_test!("cd '4", "foo'bar/", &vars); + perform_one_autosuggestion_cd_test!("cd 5", "foo\"bar/", &vars); + perform_one_autosuggestion_cd_test!("cd \"5", "foo\"bar/", &vars); + perform_one_autosuggestion_cd_test!("cd '5", "foo\"bar/", &vars); // A single quote should defeat tilde expansion. perform_one_autosuggestion_cd_test!("cd '~/test_autosuggest_suggest_specia'", "", &vars); From 9882849fdae3cc71b57f0bbf5feb2fd5d5e0a155 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 26 Jan 2025 15:48:21 +0100 Subject: [PATCH 060/113] Fix regression causing builtin commandline to report wrong relative cursor Regressed in 55fd43d86c (Port reader, 2023-12-22). Cherry-picked from c651a79c --- src/builtins/commandline.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/builtins/commandline.rs b/src/builtins/commandline.rs index 184184ed1..464ead432 100644 --- a/src/builtins/commandline.rs +++ b/src/builtins/commandline.rs @@ -633,7 +633,9 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) ); commandline_set_buffer(None, Some(new_pos)); } else { - streams.out.append(sprintf!("%lu\n", current_cursor_pos)); + streams + .out + .append(sprintf!("%lu\n", current_cursor_pos - range.start)); } return STATUS_CMD_OK; } From 7dc046b95956311c0de6beb0daae64c3be979a9a Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 27 Jan 2025 06:01:52 +0100 Subject: [PATCH 061/113] Fix regression causing crash in token history search I'm not yet sure how to reproduce 4dfcd4cb4e (reader: Check bounds for color, 2022-08-26). Commit 55fd43d86c (Port reader, 2023-12-22) accidentally changed historical behavior, fix that. Fixes #11096 --- src/reader.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index cdd5619a4..ee9f2fe11 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1492,12 +1492,13 @@ fn paint_layout(&mut self, reason: &wstr, is_final_rendering: bool) { // Highlight any history search. if !self.conf.in_silent_mode && data.history_search_range.is_some() { - let mut end = data.history_search_range.unwrap().end(); - if colors.len() < end { - end = colors.len(); + let mut range = data.history_search_range.unwrap().as_usize(); + if range.end > colors.len() { + range.start = range.start.min(colors.len()); + range.end = colors.len(); } - for color in &mut colors[data.history_search_range.unwrap().start()..end] { + for color in &mut colors[range] { color.foreground = HighlightRole::search_match; color.background = HighlightRole::search_match; } From 28d4fc33d85ee15f625ff52db63dca6f4964e1b2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 27 Jan 2025 06:59:06 +0100 Subject: [PATCH 062/113] fixup missing function --- src/parse_constants.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/parse_constants.rs b/src/parse_constants.rs index d9f19e809..8f08dec3c 100644 --- a/src/parse_constants.rs +++ b/src/parse_constants.rs @@ -44,6 +44,12 @@ pub struct SourceRange { pub length: u32, } +impl SourceRange { + pub fn as_usize(&self) -> std::ops::Range { + (*self).into() + } +} + #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum ParseTokenType { invalid = 1, From a62bae9e8f538a820fbcd7f0b254a769c189222f Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 16 Jan 2025 15:20:17 -0800 Subject: [PATCH 063/113] tmux completions: complete shell commands (cherry picked from commit bcc69da5697d6278b032fac4f5f597946a02dbd2) --- share/completions/tmux.fish | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index 16a93b256..91f488e2a 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -117,6 +117,9 @@ complete -c tmux -xs c -n "__fish_seen_subcommand_from $switchc" -a '(__fish_tmu #commands with the -F format flag complete -c tmux -n "__fish_seen_subcommand_from $lsc $ls" -xs F -d 'format string' +#commands that take shell commands +complete -c tmux -x -n "__fish_seen_subcommand_from $new " -a '(__fish_complete_subcommand --fcs-skip=2)' + ############### End: Clients and Sessions ############### ############### Begin: Windows and Panes ############### @@ -173,20 +176,16 @@ complete -c tmux -n __fish_use_subcommand -a $linkw -d 'link source window to de complete -c tmux -n __fish_use_subcommand -a $lsp -d 'list panes' complete -c tmux -n __fish_use_subcommand -a $lsw -d 'list windows' complete -c tmux -n __fish_use_subcommand -a $movew -d 'move window' -# TODO: Should accept shell command complete -c tmux -n __fish_use_subcommand -a $neww -d 'create a new window' complete -c tmux -n __fish_use_subcommand -a $nextl -d 'rearrange panes in a window according to the next layout' complete -c tmux -n __fish_use_subcommand -a $next -d 'move to the next window in the session' -# TODO: Should accept shell command complete -c tmux -n __fish_use_subcommand -a $pipep -d 'pipe output from pane to a shell command' complete -c tmux -n __fish_use_subcommand -a $prevl -d 'rearrange panes in a window according to the previous layout' complete -c tmux -n __fish_use_subcommand -a $prev -d 'move to the previous window in the session' complete -c tmux -n __fish_use_subcommand -a $renamew -d 'rename a window' complete -c tmux -n __fish_use_subcommand -a $resizep -d 'resize a pane' complete -c tmux -n __fish_use_subcommand -a $resizew -d 'resize a window' -# TODO: Should accept shell command complete -c tmux -n __fish_use_subcommand -a $respawnp -d 'reactivate a pane where a command exited' -# TODO: Should accept shell command complete -c tmux -n __fish_use_subcommand -a $respawnw -d 'reactivate a window where a command exited' complete -c tmux -n __fish_use_subcommand -a $rotatew -d 'rotate panes within a window' @@ -196,7 +195,6 @@ complete -c tmux -n "__fish_seen_subcommand_from $selectl" -x -a "$layouts" -d ' complete -c tmux -n __fish_use_subcommand -a $selectp -d 'activate specific pane' complete -c tmux -n __fish_use_subcommand -a $selectw -d 'activate specific window' -# TODO: Should accept shell command complete -c tmux -n __fish_use_subcommand -a $splitw -d 'create a new pane by splitting target-pane' complete -c tmux -n __fish_use_subcommand -a $swapp -d 'swap two panes' complete -c tmux -n __fish_use_subcommand -a $swapw -d 'swap two windows' @@ -223,6 +221,10 @@ complete -c tmux -n "__fish_seen_subcommand_from $resizew $reswpawnw $rotatew $s complete -c tmux -n "__fish_seen_subcommand_from $displayp" -xs t -d 'target client' complete -c tmux -n "__fish_seen_subcommand_from $lsp" -xs t -d 'target' +#commands that take shell commands +complete -c tmux -x -n "__fish_seen_subcommand_from $neww $pipep $respawnp $respawnw $splitw" \ + -a '(__fish_complete_subcommand --fcs-skip=2)' + ############### End: Windows and Panes ############### ############### Begin: Key Bindings ############### From d29d63d930d84746348ecfcfa8267e6b1e98c173 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 17 Nov 2024 23:40:00 -0800 Subject: [PATCH 064/113] completions/tmux: complete all subcommands when `tmux lscm` works For example, `tmux shell` now completes to `if-shell` and `run-shell`, though no additional information is provided. (cherry picked from commit 27e5ed7456ff6faa59c747ee3cfb0f95850d6ee5) --- share/completions/tmux.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index 91f488e2a..889fd767e 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -20,6 +20,10 @@ end #don't allow dirs in the completion list... complete -c tmux -x +# Complete even commands not explicitly listed below, as long as `tmux list-commands` works +set -l all_commands (tmux list-commands -F "#{command_list_name} #{command_list_alias}" 2>/dev/null) +and complete -c tmux -n __fish_use_subcommand -a "$all_commands" + ############### Begin: Front Flags ############### #these do not require parameters complete -c tmux -n __fish_use_subcommand -s 2 -d 'Force tmux to assume the terminal supports 256 colours' From 323bddcce609127d1757d19d18ac847c9355de15 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 18 Nov 2024 14:12:43 -0800 Subject: [PATCH 065/113] completions/tmux: complete all flags when `tmux lscm` is available These dynamic completions are exhaustive, but not as well-documented or as ergonomic as the manual completions. So, any manual completions should override them. (cherry picked from commit 183e20cc3a60bbf93f50d9bf35a68dab665208e6) --- share/completions/tmux.fish | 48 ++++++++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index 889fd767e..3aa2add42 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -20,9 +20,51 @@ end #don't allow dirs in the completion list... complete -c tmux -x -# Complete even commands not explicitly listed below, as long as `tmux list-commands` works -set -l all_commands (tmux list-commands -F "#{command_list_name} #{command_list_alias}" 2>/dev/null) -and complete -c tmux -n __fish_use_subcommand -a "$all_commands" +############### Begin: Dynamic Completions Using `tmux list-commands` ############### + +# The dynamic completions are exhaustive. The manual completions below override +# them with better-documented completions and custom completions for some +# arguments, e.g. for target panes, but only have partial coverage. +function __fish_tmux_parse_lscm_usage + set -l lscm (tmux list-commands -F "#{command_list_name} #{command_list_alias}"\t"#{command_list_usage}" 2>/dev/null) + or return + + for cmd_tab_usage in $lscm + set -l split_command (string split --max 2 \t -- $cmd_tab_usage) + set -l cmdnames $split_command[1] + set -l usage $split_command[2] + + complete -c tmux -n __fish_use_subcommand -a "$cmdnames" + + # $usage has the form '[-ABCD] [-L|-S|-U] [-e arg-name] [positional-arg-name]' + for item in (string match -ag --regex '\[([^\]]+)\]' $usage) + if not set -l item (string trim -l -c - -- $item) + continue + end + if set -l split_item (string split -n --max 2 " " -- "$item") + # The option should always have length 1 by tmux convention, + # but we double-check to avoid syntax errors. + if [ "$(string length $split_item[1])" = 1 ] + complete -c tmux -xs $split_item[1] -n "__fish_seen_subcommand_from $cmdnames" -d "$split_item[2]" + end + else + for char in (string split '' -- "$item") + if string match -q -r '\||-' -- $char + # TODO: Actually treat exclusive args, [-L|-S|-U], as exclusive + # For now, we just ignore the `-`s and `|`s + continue + end + complete -c tmux -n "__fish_seen_subcommand_from $cmdnames" -s $char + end + end + end + end +end + +__fish_tmux_parse_lscm_usage +functions -e __fish_tmux_parse_lscm_usage + +############### End: Dynamic Completions Using `tmux list-commands` ############### ############### Begin: Front Flags ############### #these do not require parameters From 9385a25c22b003f7ee62e42f9f8b21cd9faa93df Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Mon, 18 Nov 2024 16:03:35 -0800 Subject: [PATCH 066/113] completions/tmux: complete commands inside `tmux lscm` Make `tmux lscm ` work. (cherry picked from commit 77406ddd1112df84725570b6ab1834f16d00c8e1) --- share/completions/tmux.fish | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index 3aa2add42..ec32c73cd 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -64,6 +64,10 @@ end __fish_tmux_parse_lscm_usage functions -e __fish_tmux_parse_lscm_usage +# Completions for `tmux list-commands` itself +set -l all_commands (tmux list-commands -F "#{command_list_name} #{command_list_alias}" 2>/dev/null) +and complete -c tmux -n "__fish_seen_subcommand_from list-commands lscm" -x -a "$all_commands" + ############### End: Dynamic Completions Using `tmux list-commands` ############### ############### Begin: Front Flags ############### From f1bb4e02fe3d62dbf083b6c62e7bded283b7344a Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 19 Jan 2025 19:27:20 -0800 Subject: [PATCH 067/113] completions/tmux: some windows and panes boolean flag completions This documents some non-argument options for the window and panes commands. The choice of what to document is somewhat arbitrary, this commit is biased towards options that I find confusing or misleading without documentation (is `-a` "all" or "after"?) and the command that seem more useful to me. I also didn't cover the options that would be covered by #10855 (though this PR can be used independently). I'm not sure how much difference this made, it might not matter at all. (cherry picked from commit f241187c4a47bae2016da78ef2c6b2b7b5345747) --- share/completions/tmux.fish | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index ec32c73cd..b181e804e 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -211,29 +211,54 @@ set -l swapw "swap-window swapw" set -l unlinkw "unlink-window unlinkw" complete -c tmux -n __fish_use_subcommand -a $breakp -d 'break pane off into a new window' + complete -c tmux -n __fish_use_subcommand -a $capturep -d 'capture contents of a pane into a buffer' +complete -c tmux -n "__fish_seen_subcommand_from $capturep" -xs a -d 'capture alternate screen' +complete -c tmux -n "__fish_seen_subcommand_from $capturep" -xs p -d 'output to stdout' +complete -c tmux -n "__fish_seen_subcommand_from $capturep" -xs e -d 'include color escapes' +complete -c tmux -n "__fish_seen_subcommand_from $capturep" -xs C -d 'escape non-printable chars' + complete -c tmux -n __fish_use_subcommand -a $chooseclient -d 'interactively choose client' complete -c tmux -n __fish_use_subcommand -a $choosetree -d 'interactively choose session/window/pane' complete -c tmux -n __fish_use_subcommand -a $customizemode -d 'interactively customize settings' complete -c tmux -n __fish_use_subcommand -a $displayp -d 'display a visible indicator for each pane' complete -c tmux -n __fish_use_subcommand -a $findw -d 'interactively choose window matching pattern' + complete -c tmux -n __fish_use_subcommand -a $joinp -d 'split destination pane and move source pane into one of the halves' +# $joinp takes a subset of $splitw arguments +complete -c tmux -n "__fish_seen_subcommand_from $joinp $splitw" -xs b -d 'before target' +complete -c tmux -n "__fish_seen_subcommand_from $joinp $splitw" -xs h -d 'horizontal' +complete -c tmux -n "__fish_seen_subcommand_from $joinp $splitw" -xs v -d 'vertical' +complete -c tmux -n "__fish_seen_subcommand_from $joinp $splitw" -xs l -d 'size in lines/cols' +complete -c tmux -n "__fish_seen_subcommand_from $joinp $splitw" -xs f -d 'full height/width' + complete -c tmux -n __fish_use_subcommand -a $killp -d 'destroy a pane' complete -c tmux -n __fish_use_subcommand -a $killw -d 'destroy a window' complete -c tmux -n __fish_use_subcommand -a $lastp -d 'select the previusly selected pane' complete -c tmux -n __fish_use_subcommand -a $lastw -d 'select the previusly selected window' complete -c tmux -n __fish_use_subcommand -a $linkw -d 'link source window to destination window' + complete -c tmux -n __fish_use_subcommand -a $lsp -d 'list panes' +complete -c tmux -n "__fish_seen_subcommand_from $lsp" -xs s -d 'all in session' + complete -c tmux -n __fish_use_subcommand -a $lsw -d 'list windows' complete -c tmux -n __fish_use_subcommand -a $movew -d 'move window' + complete -c tmux -n __fish_use_subcommand -a $neww -d 'create a new window' +complete -c tmux -n "__fish_seen_subcommand_from $neww" -xs k -d 'replace if exists' +complete -c tmux -n "__fish_seen_subcommand_from $neww" -xs S -d 'select if exists' + complete -c tmux -n __fish_use_subcommand -a $nextl -d 'rearrange panes in a window according to the next layout' complete -c tmux -n __fish_use_subcommand -a $next -d 'move to the next window in the session' complete -c tmux -n __fish_use_subcommand -a $pipep -d 'pipe output from pane to a shell command' complete -c tmux -n __fish_use_subcommand -a $prevl -d 'rearrange panes in a window according to the previous layout' complete -c tmux -n __fish_use_subcommand -a $prev -d 'move to the previous window in the session' complete -c tmux -n __fish_use_subcommand -a $renamew -d 'rename a window' + complete -c tmux -n __fish_use_subcommand -a $resizep -d 'resize a pane' +complete -c tmux -n "__fish_seen_subcommand_from $resizep" -xs M -d 'begin mouse resize' +complete -c tmux -n "__fish_seen_subcommand_from $resizep" -xs T -d 'trim below cursor' + complete -c tmux -n __fish_use_subcommand -a $resizew -d 'resize a window' complete -c tmux -n __fish_use_subcommand -a $respawnp -d 'reactivate a pane where a command exited' complete -c tmux -n __fish_use_subcommand -a $respawnw -d 'reactivate a window where a command exited' @@ -244,8 +269,21 @@ set -l layouts 'even-horizontal even-vertical main-horizontal main-horizontal-mi complete -c tmux -n "__fish_seen_subcommand_from $selectl" -x -a "$layouts" -d 'predefined layout' complete -c tmux -n __fish_use_subcommand -a $selectp -d 'activate specific pane' +complete -c tmux -n "__fish_seen_subcommand_from $selectp" -xs d -d 'disable input' +complete -c tmux -n "__fish_seen_subcommand_from $selectp" -xs e -d 'enable input' +complete -c tmux -n "__fish_seen_subcommand_from $selectp" -xs l -d 'previously selected' +complete -c tmux -n "__fish_seen_subcommand_from $selectp" -xs m -d 'mark' +complete -c tmux -n "__fish_seen_subcommand_from $selectp" -xs M -d 'unmark' + complete -c tmux -n __fish_use_subcommand -a $selectw -d 'activate specific window' +complete -c tmux -n "__fish_seen_subcommand_from $selectw" -xs l -d 'previously selected' +complete -c tmux -n "__fish_seen_subcommand_from $selectw" -xs p -d 'previous' +complete -c tmux -n "__fish_seen_subcommand_from $selectw" -xs n -d 'next' + complete -c tmux -n __fish_use_subcommand -a $splitw -d 'create a new pane by splitting target-pane' +# See also $joinp's arguments +complete -c tmux -n "__fish_seen_subcommand_from $splitw" -xs I -d 'show stdin contents' + complete -c tmux -n __fish_use_subcommand -a $swapp -d 'swap two panes' complete -c tmux -n __fish_use_subcommand -a $swapw -d 'swap two windows' complete -c tmux -n __fish_use_subcommand -a $unlinkw -d 'unlink target-window' @@ -275,6 +313,29 @@ complete -c tmux -n "__fish_seen_subcommand_from $lsp" -xs t -d 'target' complete -c tmux -x -n "__fish_seen_subcommand_from $neww $pipep $respawnp $respawnw $splitw" \ -a '(__fish_complete_subcommand --fcs-skip=2)' +# Common boolean flags. TODO: -P for "print info", -Z for "zoom" +complete -c tmux -n "__fish_seen_subcommand_from $breakp $joinp $linkw $neww $movew $splitw $swapp $swapp" -xs d -d 'do not activate' + +set -l updownleftright "$resizep $resizew $selectp " +complete -c tmux -n "__fish_seen_subcommand_from $updownleftright" -xs D -d 'down' +complete -c tmux -n "__fish_seen_subcommand_from $updownleftright" -xs U -d 'up' +complete -c tmux -n "__fish_seen_subcommand_from $updownleftright" -xs L -d 'left' +complete -c tmux -n "__fish_seen_subcommand_from $updownleftright" -xs R -d 'right' + +set -l before_after "$breakp $linkw $movew $neww " +complete -c tmux -n "__fish_seen_subcommand_from $before_after" -xs a -d 'after' +complete -c tmux -n "__fish_seen_subcommand_from $before_after" -xs b -d 'before' + +# Boolean flags, ct'd. Unclear why these are not -a/-b for after/before +set -l updownnextprev "$rotatew $swapp " +complete -c tmux -n "__fish_seen_subcommand_from $updownnextprev" -xs D -d 'down/next' +complete -c tmux -n "__fish_seen_subcommand_from $updownnextprev" -xs U -d 'up/prev' + +# Boolean flags, ct'd. When `-a` does not mean "after" +complete -c tmux -n "__fish_seen_subcommand_from $lsp $lsw" -xs a -d 'all on this server' +complete -c tmux -n "__fish_seen_subcommand_from $killp $killw" -xs a -d 'all except chosen' +complete -c tmux -n "__fish_seen_subcommand_from $prev $next" -xs a -d 'with alert' + ############### End: Windows and Panes ############### ############### Begin: Key Bindings ############### From 3400844f9abdb2602659b760e98b09f8891ec4ec Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 28 Jan 2025 21:47:05 +0800 Subject: [PATCH 068/113] completions/acpi: correct the -c option as cooling Closes #11068. (cherry picked from commit 2184aaf9b468c1df77a57778533a3e1368e66ed4) --- share/completions/acpi.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/completions/acpi.fish b/share/completions/acpi.fish index 99c7619d0..79f8044ca 100644 --- a/share/completions/acpi.fish +++ b/share/completions/acpi.fish @@ -14,7 +14,7 @@ complete -c acpi -s A -l without-ac-adapter -d 'Suppress ac-adapter information' complete -c acpi -s V -l everything -d 'Show every device, overrides above options' complete -c acpi -s s -l show-empty -d 'Show non-operational devices' complete -c acpi -s S -l hide-empty -d 'Hide non-operational devices' -complete -c acpi -s c -l celcius -d 'Use celsius as the temperature unit' +complete -c acpi -s c -l cooling -d 'Show cooling device information' complete -c acpi -s f -l fahrenheit -d 'Use fahrenheit as the temperature unit' complete -c acpi -s k -l kelvin -d 'Use kelvin as the temperature unit' complete -c acpi -s d -l directory -d ' path to ACPI info (/proc/acpi)' From bfbee7a7ff3cd16f44d07f7b008c65558754e8c5 Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 28 Jan 2025 23:32:38 +0800 Subject: [PATCH 069/113] CHANGELOG: work on 4.0.0 --- CHANGELOG.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 979887e01..66271197b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -15,13 +15,10 @@ Changes since 4.0b1 - the :kbd:`ctrl-c` binding now calls a new bind function called "clear-commandline", the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) +fish 4.0.0 (released ???) +========================= -fish 4.0b1 (released December 17, 2024) -======================================= - -These are the draft release notes for fish 4.0.0. Like this release of fish itself, they are in beta and are not complete. Please report any issues you find. - -.. ignore: 751 2037 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10858 10863 10864 10873 10874 10880 10885 10891 10894 10899 10906 10907 10911 10913 10922 10923 10943 10944 10945 10947 10951 10971 10994 10995 10999 11002 11014 11015 11016 11026 11034 11035 11037 11040 11041 11049 11067 +.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. @@ -75,11 +72,10 @@ Notable improvements and fixes cargo install --path . # in a clone of the fish repository # or `cargo build --release` and copy target/release/fish{,_indent,_key_reader} wherever you want - The first time it runs interactively, it will extract all the data files to ``~/.local/share/fish/install/``. To uninstall, remove the fish binaries and that directory. + The first time it runs interactively, it will extract all the data files to ``~/.local/share/fish/install/``. A specific path can be used for the data files with ``fish --install=PATH`` To uninstall, remove the fish binaries and that directory. This build system is experimental; the main build system, using ``cmake``, remains the recommended approach for packaging and installation to a prefix. - A new function ``fish_should_add_to_history`` can be overridden to decide whether a command should be added to the history (:issue:`10302`). -- :kbd:`ctrl-c` during command input no longer prints ``^C`` and a new prompt, but merely clears the command line. This restores the behavior from version 2.2. To revert to the old behavior, use ``for mode in (bind --list-modes); bind -M $mode ctrl-c cancel-commandline-traditional; end`` (:issue:`10213`). - Bindings can now mix special input functions and shell commands, so ``bind ctrl-g expand-abbr "commandline -i \n"`` works as expected (:issue:`8186`). - Special input functions run from bindings via ``commandline -f`` are now applied immediately, instead of after the currently executing binding (:issue:`3031`). For example, ``commandline -i foo; commandline | grep foo`` succeeds now. @@ -141,6 +137,7 @@ Scripting improvements - A new ``path basename -E`` option that causes it to return the basename ("filename" with the directory prefix removed) with the final extension (if any) also removed. This is a shorter version of ``path change-extension "" (path basename $foo)`` (:issue:`10521`). - A new ``math --scale-mode`` option to select ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish; the default value is ``truncate``. (:issue:`9117`). - ``random`` is now less strict about its arguments, allowing a start larger or equal to the end. (:issue:`10879`) +- ``function --argument-names`` now produces an error if a read-only variable name is used, rather than simply ignoring it (:issue:`10842`). Interactive improvements ------------------------ @@ -160,12 +157,15 @@ Interactive improvements - Measuring a command with ``time`` now considers the time taken for command substitution (:issue:`9100`). - ``fish_add_path`` now automatically enables verbose mode when used interactively (in the command line), in an effort to be clearer about what it does (:issue:`10532`). - fish no longer adopts TTY modes of failed commands (:issue:`10603`). -- `complete -e cmd` now prevents autoloading completions for `cmd` (:issue:`6716`). +- ``complete -e cmd`` now prevents autoloading completions for ``cmd`` (:issue:`6716`). - fish's default color scheme no longer uses the color "blue", as it has bad contrast against the background in a few terminal's default palettes (:issue:`10758`, :issue:`10786`) The color scheme will not be upgraded for existing installs. If you want, you should select it again via ``fish_config``. - Command lines which are larger than the terminal are now displayed correctly, instead of multiple blank lines being displayed (:issue:`7296`). - Prompts that use external commands will no longer produce an infinite loop if the command crashes (:issue:`9796`). - Undo (:kbd:`ctrl-z`) restores the cursor position too (:issue:`10838`). +- The output of ``jobs`` shows "-" for jobs that have the same process group ID as the fish process, rather than "-2" (:issue:`10833`). +- Functions that have been erased are no longer highlighted as valid commands (:issue:`10866`). +- ``not``, ``time``, and variable assignments (that is ``not time a=b env``) is correctly recognized as valid syntax (:issue:`10890`). - The Web-based configuration removes old right-hand-side prompts again, fixing a regression in fish 3.4.0 (:issue:`10675`). - Further protection against programs which crash and leave the terminal in an inconsistent state (:issue:`10834`, :issue:`11038`). @@ -193,6 +193,7 @@ New or improved bindings - New special input functions: - ``forward-char-passive`` and ``backward-char-passive`` are like their non-passive variants but do not accept autosuggestions or move focus in the completion pager (:issue:`10398`). - ``forward-token``, ``backward-token``, ``kill-token``, and ``backward-kill-token`` are similar to the ``*-bigword`` variants but for the whole argument token (which includes escaped spaces) (:issue:`2014`). + - ``clear-commandline``, which merely clears the command line, as an alternative to ``cancel-commandline`` which prints ``^C`` and a new prompt (:issue:`10213`). - The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept (:issue:`10608`). - Vi mode has seen some improvements but continues to suffer from the lack of people working on it. - New default cursor shapes for insert and replace mode. @@ -240,6 +241,7 @@ Other improvements ------------------ - ``fish_indent`` will now collapse multiple empty lines into one (:issue:`10325`). - ``fish_indent`` now preserves the modification time of files if there were no changes (:issue:`10624`). +- Performance in launching external processes has been improved for many cases (:issue:`10869`). - Performance and interactivity under Windows Subsystem for Linux has been improved, with a workaround for Windows-specific locations being appended to ``$PATH`` by default (:issue:`10506`). - Additional filesystems such as AFS are properly detected as remote, which avoids certain hangs due to expensive filesystem locks (:issue:`10818`). From 4d6544591e734d950da7fc4b0ab9c4e3aacc772d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 29 Jan 2025 09:43:02 +0100 Subject: [PATCH 070/113] Fix regression breaking automatic history saving after adding ephemeral items Cherry-picked from acf9ba4195 (Fix regression causing missing automatic history saving after adding ephemeral items, 2025-01-29) --- src/history.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/history.rs b/src/history.rs index 458836a41..565c83f53 100644 --- a/src/history.rs +++ b/src/history.rs @@ -1080,7 +1080,6 @@ fn disable_automatic_saving(&mut self) { fn enable_automatic_saving(&mut self) { assert!(self.disable_automatic_save_counter > 0); // negative overflow! self.disable_automatic_save_counter -= 1; - self.save_unless_disabled(); } /// Irreversibly clears history. @@ -1614,7 +1613,7 @@ pub fn add_pending_with_file_detection( let when = imp.timestamp_now(); let identifier = imp.next_identifier(); let item = HistoryItem::new(s.to_owned(), when, identifier, persist_mode); - let do_save = persist_mode != PersistenceMode::Ephemeral; + let to_disk = persist_mode == PersistenceMode::Disk; if wants_file_detection { imp.disable_automatic_saving(); @@ -1622,7 +1621,7 @@ pub fn add_pending_with_file_detection( // Add the item. Then check for which paths are valid on a background thread, // and unblock the item. // Don't hold the lock while we perform this file detection. - imp.add(item, /*pending=*/ true, /*do_save=*/ true); + imp.add(item, /*pending=*/ true, to_disk); drop(imp); let vars_snapshot = vars.snapshot(); iothread_perform(move || { @@ -1630,16 +1629,17 @@ pub fn add_pending_with_file_detection( let validated_paths = expand_and_detect_paths(potential_paths, &vars_snapshot); let mut imp = self.imp(); imp.set_valid_file_paths(validated_paths, identifier); - if do_save { - imp.enable_automatic_saving(); + imp.enable_automatic_saving(); + if to_disk { + imp.save_unless_disabled(); } }); } else { // Add the item. // If we think we're about to exit, save immediately, regardless of any disabling. This may // cause us to lose file hinting for some commands, but it beats losing history items. - imp.add(item, /*pending=*/ true, do_save); - if do_save && needs_sync_write { + imp.add(item, /*pending=*/ true, to_disk); + if to_disk && needs_sync_write { imp.save(false); } } From 29e69bd11389b389e2629a20b5ca11816290b2a8 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 21 Nov 2024 08:55:45 +0100 Subject: [PATCH 071/113] Fix broken completions for "mount -ouid=" Cherry-picked from b46417c77b (Fix broken completions for "mount -ouid=", 2024-11-21). --- share/functions/__fish_complete_mount_opts.fish | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_complete_mount_opts.fish b/share/functions/__fish_complete_mount_opts.fish index 21be69d2b..f32a93137 100644 --- a/share/functions/__fish_complete_mount_opts.fish +++ b/share/functions/__fish_complete_mount_opts.fish @@ -134,8 +134,9 @@ function __fish_complete_mount_opts data_err={ignore,abort} \ barrier={0,1} \ user_xattr \ - acl \ - set -l token (commandline -tc | string replace -r '^-o' -- '') + acl + + set -l token (commandline -tc | string replace -r '^-o' -- '') set -l args (string split , -- $token) if test (count $args) -ne 0 From fa5de3ece8cc8ec066622794fc7fbe109d3598f0 Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Wed, 22 Jan 2025 23:18:39 -0800 Subject: [PATCH 072/113] language.rst: make description of features more consistent (minor) The version where a feature became the default is now described inline, to make it a single source of truth. I could have fixed the other section where this was described, but this seemed easier. I also removed a few details that seem no longer relevant. (cherry picked from commit 064d867873b96989fc5736a394d9264205905f7e) --- doc_src/language.rst | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/doc_src/language.rst b/doc_src/language.rst index 2d3cfb3cc..c4926e22a 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -2027,12 +2027,12 @@ You can see the current list of features via ``status features``:: Here is what they mean: -- ``stderr-nocaret`` was introduced in fish 3.0 (and made the default in 3.3). It makes ``^`` an ordinary character instead of denoting an stderr redirection, to make dealing with quoting and such easier. Use ``2>`` instead. This can no longer be turned off since fish 3.5. The flag can still be tested for compatibility, but a ``no-stderr-nocaret`` value will simply be ignored. -- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 4.0). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. -- ``regex-easyesc`` was introduced in 3.1. It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere. -- ``ampersand-nobg-in-token`` was introduced in fish 3.4. It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already. -- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable. -- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 4.0. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. +- ``stderr-nocaret`` was introduced in fish 3.0 and cannot be turned off since fish 3.5. It can still be tested for compatibility, but a ``no-stderr-nocaret`` value will simply be ignored. The flag made ``^`` an ordinary character instead of denoting an stderr redirection. Use ``2>`` instead. +- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 3.8). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. +- ``regex-easyesc`` was introduced in 3.1 (and made the default in 3.5). It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere. +- ``ampersand-nobg-in-token`` was introduced in fish 3.4 (and made the default in 3.5). It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already. +- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 3.8. To get fish's pid, you can use the :envvar:`fish_pid` variable. +- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 3.8. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. These changes are introduced off by default. They can be enabled on a per session basis:: @@ -2053,12 +2053,6 @@ Prefixing a feature with ``no-`` turns it off instead. E.g. to reenable the ``?` set -Ua fish_features no-qmark-noglob -Currently, the following features are enabled by default: - -- stderr-nocaret - ``^`` no longer redirects stderr, use ``2>``. Enabled by default in fish 3.3.0. No longer changeable since fish 3.5.0. -- regex-easyesc - ``string replace -r`` requires fewer backslashes in the replacement part. Enabled by default in fish 3.5.0. -- ampersand-nobg-in-token - ``&`` in the middle of a word is a normal character instead of backgrounding. Enabled by default in fish 3.5.0. - .. _event: Event handlers From d7fb0308a7ece5b180976d9011bda40127a09cea Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 29 Jan 2025 20:27:08 +0800 Subject: [PATCH 073/113] docs/language: update target release for feature flags from 3.8 to 4.0 see also 24abbb6de7f044 (cherry picked from commit 1cf71656efbc98ff672cbd1ff3e31956d9adb9d1) --- doc_src/language.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc_src/language.rst b/doc_src/language.rst index c4926e22a..2cb414c0e 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -2028,11 +2028,11 @@ You can see the current list of features via ``status features``:: Here is what they mean: - ``stderr-nocaret`` was introduced in fish 3.0 and cannot be turned off since fish 3.5. It can still be tested for compatibility, but a ``no-stderr-nocaret`` value will simply be ignored. The flag made ``^`` an ordinary character instead of denoting an stderr redirection. Use ``2>`` instead. -- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 3.8). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. +- ``qmark-noglob`` was also introduced in fish 3.0 (and made the default in 4.0). It makes ``?`` an ordinary character instead of a single-character glob. Use a ``*`` instead (which will match multiple characters) or find other ways to match files like ``find``. - ``regex-easyesc`` was introduced in 3.1 (and made the default in 3.5). It makes it so the replacement expression in ``string replace -r`` does one fewer round of escaping. Before, to escape a backslash you would have to use ``string replace -ra '([ab])' '\\\\\\\\$1'``. After, just ``'\\\\$1'`` is enough. Check your ``string replace`` calls if you use this anywhere. - ``ampersand-nobg-in-token`` was introduced in fish 3.4 (and made the default in 3.5). It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already. -- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 3.8. To get fish's pid, you can use the :envvar:`fish_pid` variable. -- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 3.8. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. +- ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable. +- ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 4.0. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. These changes are introduced off by default. They can be enabled on a per session basis:: From 5aec9e3b47bf731bf0d61f125975933e7d03928d Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 29 Jan 2025 20:28:00 +0800 Subject: [PATCH 074/113] docs/fish: minor style/proofing edits (cherry picked from commit be48d73599d01aa246ddfb2c2f03e094dacedf85) --- doc_src/cmds/fish.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc_src/cmds/fish.rst b/doc_src/cmds/fish.rst index 19889d964..78a664c53 100644 --- a/doc_src/cmds/fish.rst +++ b/doc_src/cmds/fish.rst @@ -34,17 +34,17 @@ The following options are available: See :ref:`Debugging ` below for details. **-o** or **--debug-output=DEBUG_FILE** - Specifies a file path to receive the debug output, including categories and :envvar:`fish_trace`. - The default is stderr. + Specifies a file path to receive the debug output, including categories and :envvar:`fish_trace`. + The default is standard error. **-i** or **--interactive** The shell is interactive. **--install[=PATH]** - When built as self-installable (via cargo), this will unpack fish's datafiles and place them in ~/.local/share/fish/install/. - Fish will also ask to do this automatically when run interactively. + When built as self-installable (via cargo), this will unpack fish's data files and place them in ``~/.local/share/fish/install/``. + fish will also ask to do this automatically when run interactively. If PATH is given, fish will install itself into a relocatable directory tree rooted at that path. - That means it will install the datafiles to PATH/share/fish and copy itself to PATH/bin/fish. + That means it will install the data files to PATH/share/fish and copy itself to PATH/bin/fish. **-l** or **--login** Act as if invoked as a login shell. From 93ac5d0eb390c234ac2de90e76da6d66a0523562 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 30 Jan 2025 16:22:07 +0100 Subject: [PATCH 075/113] pager: fix selected color regression To check: ```fish fish_config theme choose None set -g fish_pager_color_selected_completion blue ``` Now the selected color will only apply to the parentheses Missed in 43e2d7b48c21d1377c2bd34b3b2ef9c0016a38e4 (Port pager.cpp) (cherry picked from commit 6c4d658c15e258e48cce4874cb638c5d23522051) --- src/pager.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/pager.rs b/src/pager.rs index b5326e0de..cba84a043 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -495,15 +495,17 @@ fn completion_print_item( let bg_role = modify_role(HighlightRole::pager_background); let bg = HighlightSpec::with_bg(bg_role); let prefix_col = HighlightSpec::with_fg_bg( - if self.highlight_prefix { + modify_role(if self.highlight_prefix { HighlightRole::pager_prefix } else { HighlightRole::pager_completion - }, + }), bg_role, ); - let comp_col = HighlightSpec::with_fg_bg(HighlightRole::pager_completion, bg_role); - let desc_col = HighlightSpec::with_fg_bg(HighlightRole::pager_description, bg_role); + let comp_col = + HighlightSpec::with_fg_bg(modify_role(HighlightRole::pager_completion), bg_role); + let desc_col = + HighlightSpec::with_fg_bg(modify_role(HighlightRole::pager_description), bg_role); // Print the completion part let mut comp_remaining = comp_width; From acadf00718a25dcb8cecf3307eb4ff54d37db336 Mon Sep 17 00:00:00 2001 From: kerty Date: Fri, 24 Jan 2025 14:48:55 +0300 Subject: [PATCH 076/113] Fix regression causing variable completions to not have description Regressed in 17bd7d0 (Switch completion_request_options_t from a list of flags to a struct, 2022-06-07). --- src/complete.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/complete.rs b/src/complete.rs index 1a23c1116..28852b369 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -1676,7 +1676,7 @@ fn complete_variable(&mut self, s: &wstr, start_offset: usize) -> bool { }; let mut desc = WString::new(); - if self.flags.descriptions && self.flags.autosuggestion { + if self.flags.descriptions && !self.flags.autosuggestion { // $history can be huge, don't put all of it in the completion description; see // #6288. if env_name == "history" { From db48cd547b6fd326ed1e4e22ac16018f78ec5690 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 31 Jan 2025 16:28:03 +0100 Subject: [PATCH 077/113] Reset read_limit back to default Regression introduced in 6638c78b30310c9c0b235e989827d9639a7897c4 Reintroduces #9129 It's unclear why the tests didn't fail (cherry picked from commit 6d8f1aeb27671fc3735fc936919ddfdb167b6b13) --- src/env_dispatch.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/env_dispatch.rs b/src/env_dispatch.rs index 5b7f34b20..c495edbd1 100644 --- a/src/env_dispatch.rs +++ b/src/env_dispatch.rs @@ -2,7 +2,7 @@ use crate::complete::complete_invalidate_path; use crate::curses::{self, Term}; use crate::env::{setenv_lock, unsetenv_lock, EnvMode, EnvStack, Environment}; -use crate::env::{CURSES_INITIALIZED, READ_BYTE_LIMIT, TERM_HAS_XN}; +use crate::env::{CURSES_INITIALIZED, DEFAULT_READ_BYTE_LIMIT, READ_BYTE_LIMIT, TERM_HAS_XN}; use crate::flog::FLOG; use crate::function; use crate::input_common::{update_wait_on_escape_ms, update_wait_on_sequence_key_ms}; @@ -339,15 +339,9 @@ fn handle_read_limit_change(vars: &EnvStack) { } }); - // Clippy should recognize comments in an empty match branch as a valid pattern! - #[allow(clippy::single_match)] match read_byte_limit { Some(new_limit) => READ_BYTE_LIMIT.store(new_limit, Ordering::Relaxed), - None => { - // TODO: reset READ_BYTE_LIMIT to the default value on receiving an invalid value - // instead of persisting the previous value, which may or may not have been the - // default. - } + None => READ_BYTE_LIMIT.store(DEFAULT_READ_BYTE_LIMIT, Ordering::Relaxed), } } From 2f2ea729a7ffa04d8aa13f158d81c44fa30f380a Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Mon, 27 Jan 2025 17:51:35 +0100 Subject: [PATCH 078/113] completions/csvlens: Fix missing option (cherry picked from commit bba15c6d14583778e458bfc96364ffc2f3057eb0) --- share/completions/csvlens.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/completions/csvlens.fish b/share/completions/csvlens.fish index 10873fd08..f6431ef21 100644 --- a/share/completions/csvlens.fish +++ b/share/completions/csvlens.fish @@ -6,6 +6,6 @@ complete -c csvlens -l filter -r -d "Use this regex to filter rows to display by complete -c csvlens -l find -r -d "Use this regex to find and highlight matches by default" complete -c csvlens -s i -l ignore-case -d "Searches ignore case. Ignored if any uppercase letters are present in the search string" complete -c csvlens -l echo-column -r -d "Print the value of this column to stdout for the selected row" -complete -c csvlens -l debug "Show stats for debugging" +complete -c csvlens -l debug -d "Show stats for debugging" complete -c csvlens -s h -l help -f -d "Print help" complete -c csvlens -s V -l version -f -d "Print version" From bf91da5979df4e5741503c402338902970e4c0df Mon Sep 17 00:00:00 2001 From: phanium <91544758+phanen@users.noreply.github.com> Date: Sat, 1 Feb 2025 19:22:58 +0800 Subject: [PATCH 079/113] Fix twice tokenize editor_cmd ```fish export VISUAL='nvim --cmd let\ g:flatten_wait=1' funced -s fish_prompt ``` `editor_cmd[3]` would be `let` rather than `let g:flatten_wait=1` --- share/functions/funced.fish | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/share/functions/funced.fish b/share/functions/funced.fish index 2a38d2420..c68592547 100644 --- a/share/functions/funced.fish +++ b/share/functions/funced.fish @@ -20,7 +20,7 @@ function funced --description 'Edit function definition' if set -q _flag_interactive set editor fish else if set -q _flag_editor - set editor $_flag_editor + echo $_flag_editor | read -at editor else if set -q VISUAL echo $VISUAL | read -at editor else if set -q EDITOR @@ -37,11 +37,8 @@ function funced --description 'Edit function definition' set init function $funcname\n\nend end - # Break editor up to get its first command (i.e. discard flags) - set -l editor_cmd - echo $editor | read -ta editor_cmd - if not type -q -f "$editor_cmd[1]" - echo (_ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor_cmd[1]' could not be found") >&2 + if not type -q -f "$editor[1]" + echo (_ "funced: The value for \$EDITOR '$editor' could not be used because the command '$editor[1]' could not be found") >&2 set editor fish end @@ -88,7 +85,7 @@ function funced --description 'Edit function definition' while true set -l checksum (__fish_md5 "$tmpname") - if not $editor_cmd $tmpname + if not $editor $tmpname echo (_ "Editing failed or was cancelled") else # Verify the checksum (if present) to detect potential problems From 04151d758b7bc4bab1ba70b0a2d2779fb510ba33 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Sun, 2 Feb 2025 13:40:08 +0100 Subject: [PATCH 080/113] Remove cmake "test" target This can no longer be overridden, which means we have a broken "test" target now. Instead, you need to call "make fish_run_tests". Blergh. Fixes #11116 (cherry picked from commit 8d6fdfd9deb78545ecbf2a2eabd90aeb7cbaf78e) --- .github/workflows/main.yml | 14 +++++++------- CHANGELOG.rst | 2 ++ CONTRIBUTING.rst | 8 ++++---- cmake/Tests.cmake | 15 ++------------- tests/checks/features-qmark1.fish | 1 - 5 files changed, 15 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 374ea89aa..099107700 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: make test +name: make fish_run_tests on: [push, pull_request] @@ -29,7 +29,7 @@ jobs: - name: make run: | make VERBOSE=1 - - name: make test + - name: make fish_run_tests run: | make VERBOSE=1 test @@ -55,7 +55,7 @@ jobs: - name: make run: | make VERBOSE=1 - - name: make test + - name: make fish_run_tests run: | make VERBOSE=1 test @@ -93,7 +93,7 @@ jobs: - name: make run: | make VERBOSE=1 - - name: make test + - name: make fish_run_tests env: FISH_CI_SAN: 1 ASAN_OPTIONS: check_initialization_order=1:detect_stack_use_after_return=1:detect_leaks=1:fast_unwind_on_malloc=0 @@ -133,9 +133,9 @@ jobs: # - name: make # run: | # make - # - name: make test + # - name: make fish_run_tests # run: | - # make test + # make fish_run_tests macos: @@ -161,6 +161,6 @@ jobs: - name: make run: | make VERBOSE=1 - - name: make test + - name: make fish_run_tests run: | make VERBOSE=1 test diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 66271197b..40034f71b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,8 @@ Changes since 4.0b1 - Add debug information back to cmake builds with the "RelWithDebInfo" profile (:issue:`10959`). - the :kbd:`ctrl-c` binding now calls a new bind function called "clear-commandline", the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) +- The ``make test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. + The built-in test target will run if you built fish before, but will not print output if it fails (:issue:`11116`). fish 4.0.0 (released ???) ========================= diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 767cd7d69..5b14501fc 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -43,7 +43,7 @@ Guidelines In short: - Be conservative in what you need (keep to the agreed minimum supported Rust version, limit new dependencies) -- Use automated tools to help you (including ``make test`` and ``build_tools/style.fish``) +- Use automated tools to help you (including ``make fish_run_tests`` and ``build_tools/style.fish``) Contributing completions ======================== @@ -207,7 +207,7 @@ The tests can be run on your local computer on all operating systems. :: cmake path/to/fish-shell - make test + make fish_run_tests Git hooks --------- @@ -235,7 +235,7 @@ One possibility is a pre-push hook script like this one: done if [ "x$isprotected" = x1 ]; then echo "Running tests before push to master" - make test + make fish_run_tests RESULT=$? if [ $RESULT -ne 0 ]; then echo "Tests failed for a push to master, we can't let you do that" >&2 @@ -245,7 +245,7 @@ One possibility is a pre-push hook script like this one: exit 0 This will check if the push is to the master branch and, if it is, only -allow the push if running ``make test`` succeeds. In some circumstances +allow the push if running ``make fish_run_tests`` succeeds. In some circumstances it may be advisable to circumvent this check with ``git push --no-verify``, but usually that isn’t necessary. diff --git a/cmake/Tests.cmake b/cmake/Tests.cmake index 374f96726..5ade407ff 100644 --- a/cmake/Tests.cmake +++ b/cmake/Tests.cmake @@ -8,13 +8,11 @@ set(CMAKE_FOLDER tests) # pass but it should not be considered a failed test run, either. set(SKIP_RETURN_CODE 125) -# Even though we are using CMake's ctest for testing, we still define our own `make test` target +# Even though we are using CMake's ctest for testing, we still define our own `make fish_run_tests` target # rather than use its default for many reasons: # * CMake doesn't run tests in-proc or even add each tests as an individual node in the ninja # dependency tree, instead it just bundles all tests into a target called `test` that always just # shells out to `ctest`, so there are no build-related benefits to not doing that ourselves. -# * CMake devs insist that it is appropriate for `make test` to never depend on `make all`, i.e. -# running `make test` does not require any of the binaries to be built before testing. # * The only way to have a test depend on a binary is to add a fake test with a name like # "build_fish" that executes CMake recursively to build the `fish` target. # * Circling back to the point about individual tests not being actual Makefile targets, CMake does @@ -32,15 +30,6 @@ add_custom_target(fish_run_tests USES_TERMINAL ) -# If CMP0037 is available, also make an alias "test" target. -# Note that this policy may not be available, in which case definining such a target silently fails. -cmake_policy(PUSH) -if(POLICY CMP0037) - cmake_policy(SET CMP0037 OLD) - add_custom_target(test DEPENDS fish_run_tests) -endif() -cmake_policy(POP) - # The "test" directory. set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test) @@ -81,7 +70,7 @@ configure_file(build_tools/pexpect_helper.py pexpect_helper.py COPYONLY) set(CMAKE_XCODE_GENERATE_SCHEME 0) # CMake being CMake, you can't just add a DEPENDS argument to add_test to make it depend on any of -# your binaries actually being built before `make test` is executed (requiring `make all` first), +# your binaries actually being built before `make fish_run_tests` is executed (requiring `make all` first), # and the only dependency a test can have is on another test. So we make building fish # prerequisites to our entire top-level `test` target. function(add_test_target NAME) diff --git a/tests/checks/features-qmark1.fish b/tests/checks/features-qmark1.fish index b0ebdb03d..66eed3cc4 100644 --- a/tests/checks/features-qmark1.fish +++ b/tests/checks/features-qmark1.fish @@ -1,3 +1,2 @@ -# Explicitly overriding HOME/XDG_CONFIG_HOME is only required if not invoking via `make test` # RUN: %fish --features '' -c 'string match --quiet "??" ab ; echo "qmarkon: $status"' #CHECK: qmarkon: 1 From 378f452eaa0abbe1a6e3d41963adfcee11803a09 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 5 Feb 2025 19:06:37 +0100 Subject: [PATCH 081/113] Revert token movement bindings Comments by macOS users have shown that, apparently, on that platform this isn't wanted. The functions are there for people to use, but we need more time to figure out if and how we're going to bind these by default. For example, we could change these bindings depending on the OS in future. This reverts most of commit 6af96a81a8c6ff5e632d4dda7448f5f01d7a5d35. Fixes #10926 See #11107 --- CHANGELOG.rst | 1 + doc_src/interactive.rst | 4 ++-- share/functions/__fish_shared_key_bindings.fish | 4 ++-- share/functions/fish_default_key_bindings.fish | 3 +-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 40034f71b..acb828026 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,7 @@ Changes since 4.0b1 the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) - The ``make test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. The built-in test target will run if you built fish before, but will not print output if it fails (:issue:`11116`). +- :kbd:`alt-backspace`, :kdb:`alt-left` and :kbd:`alt-right` operate on words again instead of full arguments, reverting to how it was in 3.7 and before (:issue:`10926`). fish 4.0.0 (released ???) ========================= diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index b21381f35..3f9b1ba76 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -303,7 +303,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit - :kbd:`alt-enter` inserts a newline at the cursor position. This is useful to add a line to a commandline that's already complete. -- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor one argument left or right, or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first argument in the suggestion. +- :kbd:`alt-left` (``←``) and :kbd:`alt-right` (``→``) move the cursor one word left or right (to the next space or punctuation mark), or moves forward/backward in the directory history if the command line is empty. If the cursor is already at the end of the line, and an autosuggestion is available, :kbd:`alt-right` (``→``) (or :kbd:`alt-f`) accepts the first word in the suggestion. - :kbd:`ctrl-left` (``←``) and :kbd:`ctrl-right` (``→``) move the cursor one word left or right. These accept one word of the autosuggestion - the part they'd move over. @@ -368,7 +368,7 @@ To enable emacs mode, use :doc:`fish_default_key_bindings ` moves to the end. diff --git a/share/functions/__fish_shared_key_bindings.fish b/share/functions/__fish_shared_key_bindings.fish index 26be8e392..6c2259e03 100644 --- a/share/functions/__fish_shared_key_bindings.fish +++ b/share/functions/__fish_shared_key_bindings.fish @@ -54,8 +54,8 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod $legacy_bind --preset $argv -k sright forward-bigword $legacy_bind --preset $argv -k sleft backward-bigword - bind --preset $argv alt-right nextd-or-forward-token - bind --preset $argv alt-left prevd-or-backward-token + bind --preset $argv alt-right nextd-or-forward-word + bind --preset $argv alt-left prevd-or-backward-word bind --preset $argv alt-up history-token-search-backward bind --preset $argv alt-down history-token-search-forward diff --git a/share/functions/fish_default_key_bindings.fish b/share/functions/fish_default_key_bindings.fish index a64c628d9..166d160f0 100644 --- a/share/functions/fish_default_key_bindings.fish +++ b/share/functions/fish_default_key_bindings.fish @@ -57,9 +57,8 @@ function fish_default_key_bindings -d "emacs-like key binds" bind --preset $argv alt-u upcase-word bind --preset $argv alt-c capitalize-word - bind --preset $argv alt-backspace backward-kill-token + bind --preset $argv alt-backspace backward-kill-word bind --preset $argv ctrl-backspace backward-kill-word - bind --preset $argv alt-delete kill-token bind --preset $argv ctrl-delete kill-word bind --preset $argv alt-b backward-word bind --preset $argv alt-f forward-word From 3469fd25ec250d039a48a20fe9a6822f3f9af960 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 5 Feb 2025 19:22:26 +0100 Subject: [PATCH 082/113] CI: Use renamed test target Because CMake no longer allows making a custom "test" target, we removed it and now need to run "fish_run_tests" instead --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 099107700..79342973a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 test + make VERBOSE=1 fish_run_tests ubuntu-32bit-static-pcre2: @@ -57,7 +57,7 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 test + make VERBOSE=1 fish_run_tests ubuntu-asan: @@ -107,7 +107,7 @@ jobs: llvm_version=$(clang --version | awk 'NR==1 { split($NF, version, "."); print version[1] }') export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-$llvm_version export LSAN_OPTIONS="$LSAN_OPTIONS:suppressions=$PWD/build_tools/lsan_suppressions.txt" - make VERBOSE=1 test + make VERBOSE=1 fish_run_tests # Our clang++ tsan builds are not recognizing safe rust patterns (such as the fact that Drop # cannot be called while a thread is using the object in question). Rust has its own way of @@ -163,4 +163,4 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 test + make VERBOSE=1 fish_run_tests From db244e0492db4f4e6c5b0865a1cd591ba9104ce7 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 5 Feb 2025 22:04:48 +0100 Subject: [PATCH 083/113] reader: Only maintain cursor position in non-empty prefix search Otherwise this would always move the cursor to the beginning. Fixes #11133 --- src/reader.rs | 2 +- tests/pexpects/bind.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/reader.rs b/src/reader.rs index ee9f2fe11..b2f5fb78a 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1671,7 +1671,7 @@ fn update_command_line_from_history_search(&mut self) { 0..self.command_line.len(), new_text, ); - if self.history_search.by_prefix() { + if self.history_search.by_prefix() && !self.history_search.search_string().is_empty() { self.command_line .set_position(self.history_search.search_string().len()); } diff --git a/tests/pexpects/bind.py b/tests/pexpects/bind.py index e9c939239..fdbe9b629 100644 --- a/tests/pexpects/bind.py +++ b/tests/pexpects/bind.py @@ -364,6 +364,14 @@ send('\x02\x02\x02') # ctrl-b, backward-char sendline('\x1bu') # alt+u, upcase word expect_prompt("fooBAR") +sendline('bind ctrl-z history-prefix-search-backward') +expect_prompt() +sendline("echo this continues") +expect_prompt() +send("\x1A") +sendline(" with this text") +expect_prompt("this continues with this text") + sendline(""" bind ctrl-g " commandline --insert 'echo foo ar' From a11b9e5af76bf49f5138c58690c0d811664da3aa Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 5 Feb 2025 22:06:34 +0100 Subject: [PATCH 084/113] CHANGELOG: Fix some formatting --- CHANGELOG.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index acb828026..4d777d50a 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ Changes since 4.0b1 - Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: fish --install=$HOME/.local/ In that case, the fish binary will be moved to "bin/" in that path. :issue:`10923` + - The config directories will now be created with mode 700 again (:issue:`10962`). - A ``status buildinfo`` command to print information on how fish was built, to help with debugging (:issue:`10896`). - Remove the completions for ``dust`` because it conflicted with the Debian/Ubuntu package (:issue:`10922`). @@ -16,7 +17,7 @@ Changes since 4.0b1 the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) - The ``make test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. The built-in test target will run if you built fish before, but will not print output if it fails (:issue:`11116`). -- :kbd:`alt-backspace`, :kdb:`alt-left` and :kbd:`alt-right` operate on words again instead of full arguments, reverting to how it was in 3.7 and before (:issue:`10926`). +- :kbd:`alt-backspace`, :kbd:`alt-left` and :kbd:`alt-right` operate on words again instead of full arguments, reverting to how it was in 3.7 and before (:issue:`10926`). fish 4.0.0 (released ???) ========================= From 65ac71edccf5dcba8615753bde968ad9d978e87b Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 6 Jan 2025 21:09:41 +0100 Subject: [PATCH 085/113] Make alt-{b,f} move in directory history if commandline is empty alt-{left,right} move in the directory history (like in browsers). Arrow keys can be inconvenient to reach on some keyboards, so let's alias this to alt-{b,f}, which already have similar behavior. (historically the behavior was the same; we're considering changing that back on some platforms). This happens to fix alt-{left,right} in Terminal.app (where we had a workaround for some cases), Ghostty, though that alone should not be the reason for this change. Cherry-picked from commit f4503af037cf596f6dc4c2b2e39df703e3fd6d07. Closes #11105 --- doc_src/interactive.rst | 2 ++ share/functions/fish_default_key_bindings.fish | 10 ++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 3f9b1ba76..59c3b9fca 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -364,6 +364,8 @@ To enable emacs mode, use :doc:`fish_default_key_bindings end-of-buffer From 47d318961493c28735fcb0b781a8648fbddad7db Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 7 Feb 2025 12:28:37 +0100 Subject: [PATCH 086/113] abbr: Print optional set-cursor arg correctly Allows the output to round-trip. Fixes #11141 (cherry picked from commit b50c832a3533b61c8b92e01bccee413103f325d7) --- src/builtins/abbr.rs | 2 +- tests/checks/abbr.fish | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/builtins/abbr.rs b/src/builtins/abbr.rs index 9377e8a9a..323a6ace7 100644 --- a/src/builtins/abbr.rs +++ b/src/builtins/abbr.rs @@ -132,7 +132,7 @@ fn abbr_show(streams: &mut IoStreams) -> Option { for abbr in abbrs.list() { result.clear(); let mut add_arg = |arg: &wstr| { - if !result.is_empty() { + if !result.is_empty() && !result.ends_with("=") { result.push_str(" "); } result.push_utfstr(arg); diff --git a/tests/checks/abbr.fish b/tests/checks/abbr.fish index 3275022b4..dc98fe832 100644 --- a/tests/checks/abbr.fish +++ b/tests/checks/abbr.fish @@ -204,3 +204,7 @@ abbr --add regex_name --regex '(*UTF).*' bar # CHECKERR: abbr: Regular expression compile error: using UTF is disabled by the application # CHECKERR: abbr: (*UTF).* # CHECKERR: abbr: ^ + +abbr --add foo --set-cursor 'foo % bar' +abbr | grep foo +# CHECK: abbr -a --set-cursor='%' -- foo 'foo % bar' From 00b20098515d1ab663586947553144f2c8dd6398 Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Mon, 10 Feb 2025 00:03:14 +0100 Subject: [PATCH 087/113] Complete entries for bootctl Uses `jq` to parse and doesn't add these extra completions if not available. (cherry picked from commit d862e7bf26b7e9c1558174c591287ed98431a690) --- share/completions/bootctl.fish | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/share/completions/bootctl.fish b/share/completions/bootctl.fish index 73b67449a..fc587111e 100644 --- a/share/completions/bootctl.fish +++ b/share/completions/bootctl.fish @@ -1,5 +1,14 @@ set -l commands status install update remove is-installed random-seed systemd-efi-options reboot-to-firmware list set-default set-oneshot set-timeout set-timeout-oneshot +# Execute `bootctl list` and return entries +function __bootctl_entries + if not type -q jq + return 1 + end + + bootctl list --json short | jq '.[] | "\(.id)\t\(.showTitle)"' --raw-output +end + complete -c bootctl -f complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a status -d 'Show status of EFI variables' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a install -d 'Install systemd-boot' @@ -13,6 +22,7 @@ complete -c bootctl -n "__fish_seen_subcommand_from reboot-to-firmware" -a 'true complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a list -d 'List boot loader entries' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-default -d 'Set default boot loader entry' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-oneshot -d 'Set default boot loader entry (Once)' +complete -c bootctl -n "__fish_seen_subcommand_from set-default set-oneshot" -x -a '(__bootctl_entries)' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout -d 'Set default boot loader timeout' complete -c bootctl -n "not __fish_seen_subcommand_from $commands" -a set-timeout-oneshot -d 'Set default boot loader timeout (Once)' From 7ea368b6d355d13a0bc61cfa6fe7bd6b8bec7c30 Mon Sep 17 00:00:00 2001 From: Kemel Zaidan Date: Wed, 2 Oct 2024 17:12:13 -0300 Subject: [PATCH 088/113] adds completion for the default Elm cli tool (cherry picked from commit df6bd36e82d0529b475287a30678d230ead7847b) --- share/completions/elm.fish | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 share/completions/elm.fish diff --git a/share/completions/elm.fish b/share/completions/elm.fish new file mode 100644 index 000000000..15549e3cd --- /dev/null +++ b/share/completions/elm.fish @@ -0,0 +1,24 @@ +set -l commands repl init reactor make install bump diff publish + +complete -c elm -f +# repl completions +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a repl -d 'Open up an interactive programming session' +complete -c elm -n "__fish_seen_subcommand_from repl" -l no-colors -d 'Turn off the colors in REPL' +complete -c elm -n "__fish_seen_subcommand_from repl" -l interpreter= -d 'Path to an alternative JS interpreter' +# reactor completions +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a reactor -d 'Compile code with a click' +complete -c elm -n "__fish_seen_subcommand_from reactor" -l port= -d 'Compile code with a click' +# make completions +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a make -d 'Compiles Elm code in JS or HTML' +complete -c elm -n "__fish_seen_subcommand_from make" -l output= -F -r -d 'Specify the name of resulting JS file' +complete -c elm -n "__fish_seen_subcommand_from make" -l debug -d 'Turn on the time-travelling debugger' +complete -c elm -n "__fish_seen_subcommand_from make" -l optimize -d 'Turn on optimizations to make code smaller and faster' +complete -c elm -n "__fish_seen_subcommand_from make" -l docs= -d 'Generate a JSON file of documentation for a package' +#other commands completions +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a init -d 'Start an Elm project' +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a install -d 'Fetches packages from Elm repository' +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a bump -d 'Figures out the next version number based on API changes' +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a diff -d 'See what changed in a package between different versions' +complete -c elm -n "not __fish_seen_subcommand_from $commands" -a publish -d 'Publishes your package on package.elm-lang.org so anyone in the community can use it' + +complete -c elm -l help -d "Show a more detailed description" From 1b6e107131cd40fa851e70b172a50902f473d6eb Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 11 Feb 2025 22:27:47 +0800 Subject: [PATCH 089/113] completions/elm: remove = in long options elm's argument parser copes just fine without them Review comment from https://github.com/fish-shell/fish-shell/pull/10759#discussion_r1786918645 (cherry picked from commit 2849cd11aedcc4ba9d470ebab064f06d61212677) --- share/completions/elm.fish | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/share/completions/elm.fish b/share/completions/elm.fish index 15549e3cd..3393251f9 100644 --- a/share/completions/elm.fish +++ b/share/completions/elm.fish @@ -4,16 +4,16 @@ complete -c elm -f # repl completions complete -c elm -n "not __fish_seen_subcommand_from $commands" -a repl -d 'Open up an interactive programming session' complete -c elm -n "__fish_seen_subcommand_from repl" -l no-colors -d 'Turn off the colors in REPL' -complete -c elm -n "__fish_seen_subcommand_from repl" -l interpreter= -d 'Path to an alternative JS interpreter' +complete -c elm -n "__fish_seen_subcommand_from repl" -l interpreter -d 'Path to an alternative JS interpreter' # reactor completions complete -c elm -n "not __fish_seen_subcommand_from $commands" -a reactor -d 'Compile code with a click' -complete -c elm -n "__fish_seen_subcommand_from reactor" -l port= -d 'Compile code with a click' +complete -c elm -n "__fish_seen_subcommand_from reactor" -l port -d 'Compile code with a click' # make completions complete -c elm -n "not __fish_seen_subcommand_from $commands" -a make -d 'Compiles Elm code in JS or HTML' -complete -c elm -n "__fish_seen_subcommand_from make" -l output= -F -r -d 'Specify the name of resulting JS file' +complete -c elm -n "__fish_seen_subcommand_from make" -l output -F -r -d 'Specify the name of resulting JS file' complete -c elm -n "__fish_seen_subcommand_from make" -l debug -d 'Turn on the time-travelling debugger' complete -c elm -n "__fish_seen_subcommand_from make" -l optimize -d 'Turn on optimizations to make code smaller and faster' -complete -c elm -n "__fish_seen_subcommand_from make" -l docs= -d 'Generate a JSON file of documentation for a package' +complete -c elm -n "__fish_seen_subcommand_from make" -l docs -d 'Generate a JSON file of documentation for a package' #other commands completions complete -c elm -n "not __fish_seen_subcommand_from $commands" -a init -d 'Start an Elm project' complete -c elm -n "not __fish_seen_subcommand_from $commands" -a install -d 'Fetches packages from Elm repository' From 0677c03689a70ab6821b69c5f5f86f49700cb03d Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Tue, 28 Jan 2025 14:43:14 -0800 Subject: [PATCH 090/113] completions/tmux: replace embedded tabs with \t (cherry picked from commit 5dd6759d01afa1e1e901b966048e4dea93b237c7) --- share/completions/tmux.fish | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/share/completions/tmux.fish b/share/completions/tmux.fish index b181e804e..54fd7d761 100644 --- a/share/completions/tmux.fish +++ b/share/completions/tmux.fish @@ -1,20 +1,20 @@ function __fish_tmux_sessions -d 'available sessions' - tmux list-sessions -F "#S #{session_windows} windows created: #{session_created_string} [#{session_width}x#{session_height}]#{session_attached}" | sed 's/0$//;s/1$/ (attached)/' 2>/dev/null + tmux list-sessions -F "#S"\t"#{session_windows} windows created: #{session_created_string} [#{session_width}x#{session_height}]#{session_attached}" | sed 's/0$//;s/1$/ (attached)/' 2>/dev/null end function __fish_tmux_clients -d 'connected clients' - tmux list-clients -F "#{client_tty} #S: Created: #{client_created_string} [#{client_width}x#{client_height} #{client_termname}]" 2>/dev/null + tmux list-clients -F "#{client_tty}"\t"#S: Created: #{client_created_string} [#{client_width}x#{client_height} #{client_termname}]" 2>/dev/null end function __fish_tmux_panes -d 'window panes' #fully qualified pane names - tmux list-panes -F '#S:#W.#P session:window.pane' 2>/dev/null + tmux list-panes -F '#S:#W.#P'\t'session:window.pane' 2>/dev/null #panes by themselves - tmux list-panes -F '#P pane' 2>/dev/null + tmux list-panes -F '#P'\t'pane' 2>/dev/null #windows by themselves - tmux list-panes -F '#W window' 2>/dev/null + tmux list-panes -F '#W'\t'window' 2>/dev/null end #don't allow dirs in the completion list... From e1349b9c4a787913dbe0941bfae221afa6312142 Mon Sep 17 00:00:00 2001 From: Max Jacobson Date: Sun, 19 Jan 2025 19:24:10 -0500 Subject: [PATCH 091/113] Fix formatting of abbr example I'm running fish 4.0b1 locally and I tried running `help abbr` and browsing the docs. I noticed one example which wasn't formatted correctly. I'm not too familiar with rst, but based on looking at the file, it seems that this is how example code should be represented. (cherry picked from commit d47a4899b4179addaedd73f18cc1219bb6d9564a) --- doc_src/cmds/abbr.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc_src/cmds/abbr.rst b/doc_src/cmds/abbr.rst index b4cd9a7aa..91f952d25 100644 --- a/doc_src/cmds/abbr.rst +++ b/doc_src/cmds/abbr.rst @@ -125,6 +125,7 @@ This first creates a function ``vim_edit`` which prepends ``vim`` before its arg This creates an abbreviation "4DIRS" which expands to a multi-line loop "template." The template enters each directory and then leaves it. The cursor is positioned ready to enter the command to run in each directory, at the location of the ``!``, which is itself erased. :: + abbr --command git co checkout Turns "co" as an argument to "git" into "checkout". Multiple commands are possible, ``--command={git,hg}`` would expand "co" to "checkout" for both git and hg. From 6d7a7c225457e3346a4dcc60f1d9eed2c89155e4 Mon Sep 17 00:00:00 2001 From: idealseal Date: Thu, 16 Jan 2025 11:45:20 +0100 Subject: [PATCH 092/113] feat(comp): update to systemd 257 (cherry picked from commit 7accf4ffa1febcbfe2d6a90222fc573be7fe4f9a) --- share/completions/run0.fish | 42 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/share/completions/run0.fish b/share/completions/run0.fish index b29e81c95..ced61cb1e 100644 --- a/share/completions/run0.fish +++ b/share/completions/run0.fish @@ -1,21 +1,23 @@ -# -# Completion for run0 -# +function __run0_slice + systemctl -t slice --no-legend --no-pager --plain | string split -nf 1 ' ' + systemctl -t slice --user --no-legend --no-pager --plain | string split -nf 1 ' ' +end -complete -c run0 -l no-ask-password -d 'Do not query the user for authentication for privileged operations' -complete -c run0 -l unit -d 'Use this unit name instead of an automatically generated one' -complete -c run0 -l property -d 'Sets a property on the service unit that is created' -complete -c run0 -l description -d 'Provide a description for the service unit that is invoked' -complete -c run0 -l slice -d 'Make the new .service unit part of the specified slice, instead of user.slice.' -complete -c run0 -l slice-inherit -d 'Make the new .service unit part of the slice the run0 itself has been invoked in' -complete -c run0 -s u -l user -a "(__fish_complete_users)" -x -d "Switches to the specified user instead of root" -complete -c run0 -s g -l group -a "(__fish_complete_groups)" -x -d "Switches to the specified group instead of root" -complete -c run0 -l nice -d 'Runs the invoked session with the specified nice level' -complete -c run0 -s D -l chdir -d 'Runs the invoked session with the specified working directory' -complete -c run0 -l setenv -d 'Runs the invoked session with the specified environment variable set' -complete -c run0 -l background -d 'Change the terminal background color to the specified ANSI color' -complete -c run0 -l machine -d 'Execute operation on a local container' -complete -c run0 -s h -l help -d 'Print a short help text and exit' -complete -c run0 -l version -d 'Print a short version string and exit' - -complete -c run0 -x -a '(__fish_complete_subcommand)' +complete -c run0 -xa "(__fish_complete_subcommand)" +complete -c run0 -s h -l help -d "Show help" +complete -c run0 -s V -l version -d "Show version" +complete -c run0 -s u -l user -d "Switches to the specified user instead of root" -xa "(__fish_complete_users)" +complete -c run0 -s g -l group -d "Switches to the specified group instead of root" -xa "(__fish_complete_groups)" +complete -c run0 -l no-ask-password -d "Do not query the user for authentication for privileged operations" +complete -c run0 -l machine -d "Execute operation on a local container" -xa "(machinectl list --no-legend --no-pager | string split -f 1 ' ')" +complete -c run0 -l property -d "Sets a property on the service unit that is created" -x +complete -c run0 -l description -d "Description for unit" -x +complete -c run0 -l slice -d "Make the new .service unit part of the specified slice, instead of user.slice." -xa "(__run0_slice)" +complete -c run0 -l slice-inherit -d "Make the new .service unit part of the slice the run0 itself has been invoked in" +complete -c run0 -l nice -d "Runs the invoked session with the specified nice level" -xa "(seq -20 19)" +complete -c run0 -s D -l chdir -d "Set working directory" -xa "(__fish_complete_directories)" +complete -c run0 -l setenv -d "Runs the invoked session with the specified environment variable set" -x +complete -c run0 -l background -d "Change the terminal background color to the specified ANSI color" -x +complete -c run0 -l pty -d "Request allocation of a pseudo TTY for stdio" +complete -c run0 -l pipe -d "Request redirect pipe for stdio" +complete -c run0 -l shell-prompt-prefix -d "Set a shell prompt prefix string" -x From 774ad164040cb0c3b6e88ac781a0e429b24a82e3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Tue, 11 Feb 2025 23:28:07 +0800 Subject: [PATCH 093/113] CHANGELOG: work on 4.0.0 --- CHANGELOG.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4d777d50a..b841fd923 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,7 +22,7 @@ Changes since 4.0b1 fish 4.0.0 (released ???) ========================= -.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5991 6981 6996 7172 9332 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9542 9544 9554 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10588 10591 10594 10595 10596 10609 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 +.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5924 5991 6981 6996 7172 9332 9439 9440 9442 9452 9461 9469 9480 9482 9520 9536 9541 9542 9544 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9862 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10111 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10585 10588 10591 10594 10595 10596 10609 10616 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 11086 fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. @@ -81,7 +81,7 @@ Notable improvements and fixes This build system is experimental; the main build system, using ``cmake``, remains the recommended approach for packaging and installation to a prefix. - A new function ``fish_should_add_to_history`` can be overridden to decide whether a command should be added to the history (:issue:`10302`). - Bindings can now mix special input functions and shell commands, so ``bind ctrl-g expand-abbr "commandline -i \n"`` works as expected (:issue:`8186`). -- Special input functions run from bindings via ``commandline -f`` are now applied immediately, instead of after the currently executing binding (:issue:`3031`). +- Special input functions run from bindings via ``commandline -f`` are now applied immediately, instead of after the currently executing binding (:issue:`3031`, :issue:`10126`). For example, ``commandline -i foo; commandline | grep foo`` succeeds now. - Undo history is no longer truncated after every command, but kept for the lifetime of the shell process. - The :kbd:`ctrl-r` history search now uses glob syntax (:issue:`10131`). @@ -142,6 +142,7 @@ Scripting improvements - A new ``math --scale-mode`` option to select ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish; the default value is ``truncate``. (:issue:`9117`). - ``random`` is now less strict about its arguments, allowing a start larger or equal to the end. (:issue:`10879`) - ``function --argument-names`` now produces an error if a read-only variable name is used, rather than simply ignoring it (:issue:`10842`). +- Tilde expansion in braces (that is, ``{~,}``) works correctly (:issue:`10610`). Interactive improvements ------------------------ @@ -172,6 +173,7 @@ Interactive improvements - ``not``, ``time``, and variable assignments (that is ``not time a=b env``) is correctly recognized as valid syntax (:issue:`10890`). - The Web-based configuration removes old right-hand-side prompts again, fixing a regression in fish 3.4.0 (:issue:`10675`). - Further protection against programs which crash and leave the terminal in an inconsistent state (:issue:`10834`, :issue:`11038`). +- A workaround for git being very slow on macOS has been applied, improving performance after a fresh boot (:issue:`10535`). New or improved bindings ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,9 +207,11 @@ New or improved bindings - Outside insert mode, the cursor will no longer be placed beyond the last character on the commandline. - When the cursor is at the end of the commandline, a single :kbd:`l` will accept an autosuggestion (:issue:`10286`). - The cursor position after pasting (:kbd:`p`) has been corrected. + - Added an additional binding, :kbd:`_`, for moving to the beginning of the line (:issue:`10720`). - When the cursor is at the start of a line, escaping from insert mode no longer moves the cursor to the previous line. - Added bindings for clipboard interaction, like :kbd:`",+,p` and :kbd:`",+,y,y`. - Deleting in visual mode now moves the cursor back, matching vi (:issue:`10394`). + - The :kbd:`;`, :kbd:`,`, :kbd:`v`, :kbd:`V`, :kbd:`I`, and :kbd:`gU` bindings work in visual mode (:issue:`10601`, :issue:`10648`). - Support :kbd:`%` motion (:issue:`10593`). - :kbd:`ctrl-k` to remove the contents of the line beyond the cursor in all modes (:issue:`10648`). - Support `ab` and `ib` vi text objects. New input functions are introduced ``jump-{to,till}-matching-bracket`` (:issue:`1842`). @@ -260,6 +264,8 @@ CMake remains the recommended build system, because of cargo's limited support f fish no longer depends on the ncurses library, but still uses a terminfo database. When packaging fish, please add a dependency on the package containing your terminfo database instead of curses. +The Web-based configuration has been rewritten to use Alpine.js (:issue:`9554`). + -------------- fish 3.7.1 (released March 19, 2024) From 9c40f7264338ab1a41dfc603db6b0412b3d7bf51 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Thu, 16 Jan 2025 13:23:29 +0100 Subject: [PATCH 094/113] Add feature flag for turning off keyboard protocols To work around terminal bugs. The flag "keyboard-protocols" defaults to "on" and enables keyboard protocols, but can be turned off by setting "no-keyboard-protocols". This has downsides as a feature flag - if you use multiple terminals and one of them can't do it you'll have to disable it in all, but anything else would require us to hook this up to env-dispatch, and ensure that we turn the protocols *off* when the flag is disabled. Since this is a temporary inconvenience, this would be okay to ask zellij and Jetbrains-with-WSL users. --- doc_src/language.rst | 4 ++++ src/future_feature_flags.rs | 12 ++++++++++++ src/input_common.rs | 9 +++++++-- tests/checks/status.fish | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc_src/language.rst b/doc_src/language.rst index 2cb414c0e..898b847d3 100644 --- a/doc_src/language.rst +++ b/doc_src/language.rst @@ -2024,6 +2024,7 @@ You can see the current list of features via ``status features``:: ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separating character remove-percent-self off 4.0 %self is no longer expanded (use $fish_pid) test-require-arg off 4.0 builtin test requires an argument + keyboard-protocols on 4.0 Use keyboard protocols (kitty, xterm's modifyotherkeys Here is what they mean: @@ -2033,6 +2034,9 @@ Here is what they mean: - ``ampersand-nobg-in-token`` was introduced in fish 3.4 (and made the default in 3.5). It makes it so a ``&`` i no longer interpreted as the backgrounding operator in the middle of a token, so dealing with URLs becomes easier. Either put spaces or a semicolon after the ``&``. This is recommended formatting anyway, and ``fish_indent`` will have done it for you already. - ``remove-percent-self`` turns off the special ``%self`` expansion. It was introduced in 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable. - ``test-require-arg`` removes :doc:`builtin test `'s one-argument form (``test "string"``. It was introduced in 4.0. To test if a string is non-empty, use ``test -n "string"``. If disabled, any call to ``test`` that would change sends a :ref:`debug message ` of category "deprecated-test", so starting fish with ``fish --debug=deprecated-test`` can be used to find offending calls. +- ``keyboard-protocols`` lets fish turn on various keyboard protocols including the kitty keyboard protocol. + It was introduced in 4.0 and is on by default. + Disable it with ``no-keyboard-protocols`` to work around bugs in your terminal. These changes are introduced off by default. They can be enabled on a per session basis:: diff --git a/src/future_feature_flags.rs b/src/future_feature_flags.rs index 503da62bd..38000e38a 100644 --- a/src/future_feature_flags.rs +++ b/src/future_feature_flags.rs @@ -27,6 +27,9 @@ pub enum FeatureFlag { /// Remove `test`'s one and zero arg mode (make `test -n` return false etc) test_require_arg, + + /// Whether keyboard protocols (kitty's CSI x u, xterm's modifyOtherKeys) are used + keyboard_protocols, } struct Features { @@ -107,6 +110,14 @@ pub struct FeatureMetadata { default_value: false, read_only: false, }, + FeatureMetadata { + flag: FeatureFlag::keyboard_protocols, + name: L!("keyboard-protocols"), + groups: L!("4.0"), + description: L!("Use keyboard protocols (kitty, xterm's modifyotherkeys"), + default_value: true, + read_only: false, + }, ]; thread_local!( @@ -168,6 +179,7 @@ const fn new() -> Self { AtomicBool::new(METADATA[3].default_value), AtomicBool::new(METADATA[4].default_value), AtomicBool::new(METADATA[5].default_value), + AtomicBool::new(METADATA[6].default_value), ], } } diff --git a/src/input_common.rs b/src/input_common.rs index d8befb2a3..ddac41b1e 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -8,6 +8,7 @@ use crate::fd_readable_set::FdReadableSet; use crate::flog::FLOG; use crate::fork_exec::flog_safe::FLOG_SAFE; +use crate::future_feature_flags::{feature_test, FeatureFlag}; use crate::global_safety::RelaxedAtomicBool; use crate::key::{ self, alt, canonicalize_control_char, canonicalize_keyed_control_char, function_key, shift, @@ -482,7 +483,9 @@ pub fn terminal_protocols_enable_ifn() { return; } TERMINAL_PROTOCOLS.store(true, Ordering::Release); - let sequences = if IN_MIDNIGHT_COMMANDER_PRE_CSI_U.load() { + let sequences = if !feature_test(FeatureFlag::keyboard_protocols) + || IN_MIDNIGHT_COMMANDER_PRE_CSI_U.load() + { "\x1b[?2004h" } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004h", "\x1b[>4;1m", "\x1b[>5u", "\x1b=",) @@ -516,7 +519,9 @@ pub(crate) fn terminal_protocols_disable_ifn() { if !TERMINAL_PROTOCOLS.load(Ordering::Acquire) { return; } - let sequences = if IN_ITERM_PRE_CSI_U.load() { + let sequences = if !feature_test(FeatureFlag::keyboard_protocols) { + "\x1b[?2004l" + } else if IN_ITERM_PRE_CSI_U.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b[<1u", "\x1b>",) } else if IN_JETBRAINS.load() { concat!("\x1b[?2004l", "\x1b[>4;0m", "\x1b>",) diff --git a/tests/checks/status.fish b/tests/checks/status.fish index 3b2973268..d861611fc 100644 --- a/tests/checks/status.fish +++ b/tests/checks/status.fish @@ -59,6 +59,7 @@ status features #CHECK: ampersand-nobg-in-token on 3.4 & only backgrounds if followed by a separator #CHECK: remove-percent-self off 4.0 %self is no longer expanded (use $fish_pid) #CHECK: test-require-arg off 4.0 builtin test requires an argument +#CHECK: keyboard-protocols on 4.0 Use keyboard protocols (kitty, xterm's modifyotherkeys status test-feature stderr-nocaret echo $status #CHECK: 0 From 9c2bfec15079332ddd12b98cadb86c4642ebbadb Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Tue, 11 Feb 2025 22:23:31 +0100 Subject: [PATCH 095/113] CHANGELOG keyboard-protocols feature flag --- CHANGELOG.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b841fd923..286b33b58 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -18,6 +18,12 @@ Changes since 4.0b1 - The ``make test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. The built-in test target will run if you built fish before, but will not print output if it fails (:issue:`11116`). - :kbd:`alt-backspace`, :kbd:`alt-left` and :kbd:`alt-right` operate on words again instead of full arguments, reverting to how it was in 3.7 and before (:issue:`10926`). +- Keyboard protocols can be turned off by disabling the "keyboard-protocols" feature flag:: + + set -Ua fish_features no-keyboard-protocols + + This is a temporary measure to work around buggy terminals (:issue:`11056`), which appear to be relatively rare. + Use this if something like "=0" or "=5u" appears in your commandline mysteriously. fish 4.0.0 (released ???) ========================= From 0f346991e4950136da1d809484433030f3f4ccb3 Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 12 Feb 2025 08:41:40 +0800 Subject: [PATCH 096/113] Revert "CI: Use renamed test target" CI targets the GNUmakefile in the build root, which is probably worth keeping working. This reverts commit 3469fd25ec250d039a48a20fe9a6822f3f9af960. --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79342973a..099107700 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 fish_run_tests + make VERBOSE=1 test ubuntu-32bit-static-pcre2: @@ -57,7 +57,7 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 fish_run_tests + make VERBOSE=1 test ubuntu-asan: @@ -107,7 +107,7 @@ jobs: llvm_version=$(clang --version | awk 'NR==1 { split($NF, version, "."); print version[1] }') export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-$llvm_version export LSAN_OPTIONS="$LSAN_OPTIONS:suppressions=$PWD/build_tools/lsan_suppressions.txt" - make VERBOSE=1 fish_run_tests + make VERBOSE=1 test # Our clang++ tsan builds are not recognizing safe rust patterns (such as the fact that Drop # cannot be called while a thread is using the object in question). Rust has its own way of @@ -163,4 +163,4 @@ jobs: make VERBOSE=1 - name: make fish_run_tests run: | - make VERBOSE=1 fish_run_tests + make VERBOSE=1 test From fab273cf4dd6c3242931e2094b107522aa7dde5b Mon Sep 17 00:00:00 2001 From: David Adam Date: Wed, 12 Feb 2025 08:43:24 +0800 Subject: [PATCH 097/113] BSD/GNUmakefile: update to use new fish_run_tests target (cherry picked from commit 15ca16477376cc2ddceebcbe1c637a58edfb950f) --- BSDmakefile | 8 ++++++-- GNUmakefile | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/BSDmakefile b/BSDmakefile index 1fcc30512..447aad806 100644 --- a/BSDmakefile +++ b/BSDmakefile @@ -31,7 +31,7 @@ PREFIX?=/usr/local build/fish: build/$(BUILDFILE) $(CMAKE) --build build -# Don't split the mkdir into its own rule because that would cause CMake to regenerate the build +# Don't split the mkdir into its own rule because that would cause CMake to regenerate the build # files after each build (because it adds the mdate of the build directory into the out-of-date # calculation tree). GNUmake supports order-only dependencies, BSDmake does not seem to. build/$(BUILDFILE): @@ -48,7 +48,11 @@ clean: .PHONY: test test: build/fish - $(CMAKE) --build build --target test + $(CMAKE) --build build --target fish_run_tests + +.PHONY: fish_run_tests +fish_run_tests: build/fish + $(CMAKE) --build build --target fish_run_tests .PHONY: run run: build/fish diff --git a/GNUmakefile b/GNUmakefile index ced0ba880..1b69ab8d3 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -55,7 +55,11 @@ clean: .PHONY: test test: build/fish - $(CMAKE) --build build --target test + $(CMAKE) --build build --target fish_run_tests + +.PHONY: fish_run_tests +fish_run_tests: build/fish + $(CMAKE) --build build --target fish_run_tests .PHONY: install install: build/fish From c571b6522113926f976384c4f6c4514f02b0c16e Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Thu, 16 Jan 2025 20:38:42 -0800 Subject: [PATCH 098/113] completions: add `unbuffer` completions unbuffer is sometimes bundled with `expect` (which fish already ships completions for), and sometimes is bundled separately. It's often recommended for forcing colors to have color output. https://manpages.debian.org/bookworm/expect/unbuffer.1.en.html Ads for unbuffer: https://wiki.archlinux.org/title/Color_output_in_console#Reading_from_stdin https://jvns.ca/blog/2024/10/01/terminal-colours/ (cherry picked from commit 4208798585c47a142a946f5e8e81695d6fdd1893) --- share/completions/unbuffer.fish | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 share/completions/unbuffer.fish diff --git a/share/completions/unbuffer.fish b/share/completions/unbuffer.fish new file mode 100644 index 000000000..b1acee840 --- /dev/null +++ b/share/completions/unbuffer.fish @@ -0,0 +1,2 @@ +complete -c unbuffer -a "(__fish_complete_subcommand)" -x +complete -c unbuffer -s p -d "Read from stdin for pipeline use, exit when stdin closes" From b72dc096f9e9f30b7ccdc063ff25f795145505d3 Mon Sep 17 00:00:00 2001 From: Dmitry Gerasimov Date: Sat, 18 Jan 2025 14:08:04 +0100 Subject: [PATCH 099/113] completions/git: update supported git format options --format=reference is supported since git 2.25 --format=mboxrd is supported since git 2.27 (cherry picked from commit 9752b83e65da0543bd33ef68913d5c8d60b3bf0d) --- share/completions/git.fish | 2 ++ 1 file changed, 2 insertions(+) diff --git a/share/completions/git.fish b/share/completions/git.fish index 3bb459e5f..bbbb51d31 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -882,7 +882,9 @@ short\t / / medium\t<sha1> / <author> / <author date> / <title> / <commit msg> full\t<sha1> / <author> / <committer> / <title> / <commit msg> fuller\t<sha1> / <author> / <author date> / <committer> / <committer date> / <title> / <commit msg> +reference\t<abbrev-hash> (<title-line>, <short-author-date>) email\t<sha1> <date> / <author> / <author date> / <title> / <commit msg> +mboxrd\tLike email, but lines in the commit message starting with \"From \" are quoted with \">\" raw\tShow the entire commit exactly as stored in the commit object format:\tSpecify which information to show" end From 40b63c35ab18fa6a5a9c8530bed3f1e396c03ed7 Mon Sep 17 00:00:00 2001 From: Dmitry Gerasimov <di.gerasimov@gmail.com> Date: Sat, 18 Jan 2025 15:05:14 +0100 Subject: [PATCH 100/113] completions/git: show custom aliases for --pretty option Custom formats for --pretty/--format option can only be written in [pretty] section, thus only this section is searched. [ja: add ? to the regex] Closes #11065 (cherry picked from commit dfa77e6c197bf7027b3baf408e64661e23da6ffa) --- share/completions/git.fish | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/completions/git.fish b/share/completions/git.fish index bbbb51d31..123e0bc30 100644 --- a/share/completions/git.fish +++ b/share/completions/git.fish @@ -886,7 +886,12 @@ reference\t<abbrev-hash> (<title-line>, <short-author-date>) email\t<sha1> <date> / <author> / <author date> / <title> / <commit msg> mboxrd\tLike email, but lines in the commit message starting with \"From \" are quoted with \">\" raw\tShow the entire commit exactly as stored in the commit object -format:\tSpecify which information to show" +format:\tSpecify which information to show +" + __fish_git config -z --get-regexp '^pretty\.' 2>/dev/null | while read -lz key value + set -l name (string replace -r '^.*?\.' '' -- $key) + printf "%s\t%s\n" $name $value + end end end From df56f7155eca4855d96234097f278d9137ccd391 Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Thu, 13 Feb 2025 00:12:14 +0800 Subject: [PATCH 101/113] docs/interactive: add ctrl-n Vi mode documentation Noted missing in #11082. (cherry picked from commit b2eebbe194158270def1e7e941a7d4dd0b84a54a) --- doc_src/interactive.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index 59c3b9fca..28bc55157 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -482,6 +482,7 @@ Command mode is also known as normal mode. - :kbd:`p` pastes text from the :ref:`killring`. - :kbd:`u` undoes the most recent edit of the command line. + - :kbd:`ctrl-r` redoes the most recent edit. - :kbd:`[` and :kbd:`]` search the command history for the previous/next token containing the token under the cursor before the search was started. See the :ref:`history <history-search>` section for more information on history searching. @@ -503,6 +504,8 @@ Insert mode - :kbd:`backspace` removes one character to the left. +- :kbd:`ctrl-n` accepts the autosuggestion. + .. _vi-mode-visual: Visual mode From ebc460b9f9b05ce0d98f994c299e9ddb790b4e41 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger <aclopte@gmail.com> Date: Wed, 19 Feb 2025 09:52:36 +0100 Subject: [PATCH 102/113] Fix search field state not resetting after search field is hidden Commit 4f536d6a9b (Update commandline state snapshot lazily, 2024-04-13) add an optimization to update the search field only if necessary. The optimization accidentally prevents us from resetting the search field. Fixes #11161 (cherry picked from commit 72f2433120ffd86a8dd8c8a1d54c565541929997) --- doc_src/cmds/commandline.rst | 2 +- src/reader.rs | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc_src/cmds/commandline.rst b/doc_src/cmds/commandline.rst index 73659a587..808a0093c 100644 --- a/doc_src/cmds/commandline.rst +++ b/doc_src/cmds/commandline.rst @@ -71,7 +71,7 @@ The following options change what part of the commandline is printed or updated: Selects the current token **--search-field** - Use the pager search field instead of the command line. Returns false is the search field is not shown. + Use the pager search field instead of the command line. Returns false if the search field is not shown. The following options change the way ``commandline`` prints the current commandline buffer: diff --git a/src/reader.rs b/src/reader.rs index b2f5fb78a..ea8e4356c 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -1256,13 +1256,14 @@ fn update_commandline_state(&self) { snapshot.selection = self.get_selection(); snapshot.pager_mode = !self.pager.is_empty(); snapshot.pager_fully_disclosed = self.current_page_rendering.remaining_to_disclose == 0; - if snapshot - .search_field - .as_ref() - .is_none_or(|(text, position)| { - text != self.pager.search_field_line.text() - || *position != self.pager.search_field_line.position() - }) + if (snapshot.search_field.is_some() != self.pager.search_field_shown) + || snapshot + .search_field + .as_ref() + .is_some_and(|(text, position)| { + text != self.pager.search_field_line.text() + || *position != self.pager.search_field_line.position() + }) { snapshot.search_field = self.pager.search_field_shown.then(|| { ( From e2a0b0e2b8899f88d2c0073c9e6a1e1381522217 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger <aclopte@gmail.com> Date: Wed, 19 Feb 2025 10:17:41 +0100 Subject: [PATCH 103/113] Fix off-by-one error in new commandline --column parse_util_lineno() returns 1-based line numbers but parse_util_get_offset_from_line() expects zero based line offsets. Fixes #11162 (cherry picked from commit afbdb9f268fe369343142632013869a7e18a25d4) --- src/builtins/commandline.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builtins/commandline.rs b/src/builtins/commandline.rs index 464ead432..2a84743df 100644 --- a/src/builtins/commandline.rs +++ b/src/builtins/commandline.rs @@ -475,7 +475,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr]) rstate.cursor_pos + 1 - parse_util_get_offset_from_line( &rstate.text, - i32::try_from(parse_util_lineno(&rstate.text, rstate.cursor_pos)) + i32::try_from(parse_util_lineno(&rstate.text, rstate.cursor_pos) - 1) .unwrap(), ) .unwrap_or_default() From b5736c55357e25df89dc021ae73899f07937d31a Mon Sep 17 00:00:00 2001 From: Fabian Boehm <FHomborg@gmail.com> Date: Thu, 20 Feb 2025 17:11:08 +0100 Subject: [PATCH 104/113] Extend iTerm CSI u workaround to < 3.5.12 iTerm has a bug where it'll send Option-Left as Left instead of the proper Alt-Left. This was reported upstream and fixed in https://gitlab.com/gnachman/iterm2/-/commit/480f059bced960d5706da95126b2437e0d3c31f5 which is contained in the 3.5.12-beta2 tag, so let's assume that fixes it. Fixes #11025 (not necessary in 4.1) --- src/input_common.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input_common.rs b/src/input_common.rs index ddac41b1e..63da58fc0 100644 --- a/src/input_common.rs +++ b/src/input_common.rs @@ -448,7 +448,7 @@ pub fn terminal_protocol_hacks() { else { return false; }; - version < (3, 5, 6) + version < (3, 5, 12) }), ); IN_JETBRAINS.store( From b52173c85412e233a03c7e92132c5dd7a75834f8 Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Wed, 26 Feb 2025 21:23:40 +0800 Subject: [PATCH 105/113] docs/bind: improve description of cancel binding Closes #9644 (cherry picked from commit 8ec1a3e7b9d9e01e3a13080c355fa5bc04b3407b) --- doc_src/cmds/bind.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc_src/cmds/bind.rst b/doc_src/cmds/bind.rst index ceb4972c7..d7088f060 100644 --- a/doc_src/cmds/bind.rst +++ b/doc_src/cmds/bind.rst @@ -162,7 +162,7 @@ The following special input functions are available: start selecting text ``cancel`` - cancel the current commandline and replace it with a new empty one + close the pager if it is open, or undo the most recent completion if one was just inserted, or otherwise cancel the current commandline and replace it with a new empty one ``cancel-commandline`` cancel the current commandline and replace it with a new empty one, leaving the old one in place with a marker to show that it was cancelled From bfa1e0dafb71b38f3cf06aacaf2acf77fc58601e Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Wed, 26 Feb 2025 21:30:57 +0800 Subject: [PATCH 106/113] docs/source: document changes from #10774 (cherry picked from commit b82d0fcbcc44eb259cf2209b04f7a41c1f324e27) --- doc_src/cmds/source.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc_src/cmds/source.rst b/doc_src/cmds/source.rst index d995c6a84..24f83b1bf 100644 --- a/doc_src/cmds/source.rst +++ b/doc_src/cmds/source.rst @@ -20,7 +20,7 @@ Description fish will search the working directory to resolve relative paths but will not search :envvar:`PATH` . -If no file is specified and stdin is not the terminal, or if the file name ``-`` is used, stdin will be read. +If no file is specified and a file or pipeline is connected to standard input, or if the file name ``-`` is used, ``source`` will read from standard input. If no file is specified and there is no redirected file or pipeline on standard input, an error will be printed. The exit status of ``source`` is the exit status of the last job to execute. If something goes wrong while opening or reading the file, ``source`` exits with a non-zero status. From def40ff34dc30c4247a37e0e9b35b1213d5a88d4 Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Wed, 26 Feb 2025 21:41:58 +0800 Subject: [PATCH 107/113] CHANGELOG: work on 4.0.0 --- CHANGELOG.rst | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 286b33b58..623cb9613 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -28,7 +28,7 @@ Changes since 4.0b1 fish 4.0.0 (released ???) ========================= -.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5924 5991 6981 6996 7172 9332 9439 9440 9442 9452 9461 9469 9480 9482 9520 9536 9541 9542 9544 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9862 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10090 10101 10102 10108 10111 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10585 10588 10591 10594 10595 10596 10609 10616 10622 10623 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10664 10667 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10726 10727 10728 10731 10760 10762 10763 10767 10770 10775 10776 10778 10779 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 11086 +.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5924 5991 6981 6996 7172 9332 9439 9440 9442 9452 9461 9469 9480 9482 9520 9536 9541 9542 9544 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9862 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10078 10090 10101 10102 10108 10111 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10585 10588 10591 10594 10595 10596 10609 10615 10616 10622 10623 10625 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10663 10664 10667 10668 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10724 10726 10727 10728 10731 10738 10752 10760 10762 10763 10767 10770 10775 10776 10778 10779 10790 10800 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 11086 fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. @@ -121,6 +121,7 @@ Deprecations and removed features If this happens, you can use the ``reset`` command from ``ncurses`` to restore the terminal state. - ``fish_key_reader --verbose`` no longer shows timing information. - Terminal information is no longer read from hashed terminfo databases, or termcap databases (:issue:`10269`). The vast majority of systems use a non-hashed terminfo database, which is still supported. +- ``source`` returns an error if used without a filename or pipe/redirection (:issue:`10774`). Scripting improvements ---------------------- @@ -175,6 +176,8 @@ Interactive improvements - Prompts that use external commands will no longer produce an infinite loop if the command crashes (:issue:`9796`). - Undo (:kbd:`ctrl-z`) restores the cursor position too (:issue:`10838`). - The output of ``jobs`` shows "-" for jobs that have the same process group ID as the fish process, rather than "-2" (:issue:`10833`). +- Job expansion (``%1`` syntax) works properly for jobs that are a mixture of external commands and functions (:issue:`10832`). +- Command lines which have more lines than the terminal can be displayed and edited correctly (:issue:`10827`). - Functions that have been erased are no longer highlighted as valid commands (:issue:`10866`). - ``not``, ``time``, and variable assignments (that is ``not time a=b env``) is correctly recognized as valid syntax (:issue:`10890`). - The Web-based configuration removes old right-hand-side prompts again, fixing a regression in fish 3.4.0 (:issue:`10675`). @@ -187,9 +190,9 @@ New or improved bindings - During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager. - :kbd:`shift-delete` will also remove the currently-displayed autosuggestion from history, and remove it as a suggestion. - :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo. -- :kbd:`alt-backspace` deletes the argument (including quoted spaces) left of the cursor. -- :kbd:`alt-delete` now deletes the argument (which may contain quoted spaces) right of the cursor. -- :kbd:`alt-right` and :kbd:`alt-left` will skip over command line tokens in the command line. +- :kbd:`alt-backspace` deletes the argument (including quoted spaces) left of the cursor (:issue:`10766`). +- :kbd:`alt-delete` now deletes the argument (including quoted spaces) right of the cursor (:issue:`10766`). +- :kbd:`alt-right` and :kbd:`alt-left` will move by argument (including quoted spaces) in the command line (:issue:`10766)`. - Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor: - The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune. - Cursor position synchronization is only supported for a set of known editors, which are now also detected in aliases which use ``complete --wraps``. For example, use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``. @@ -209,7 +212,7 @@ New or improved bindings - The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept (:issue:`10608`). - Vi mode has seen some improvements but continues to suffer from the lack of people working on it. - New default cursor shapes for insert and replace mode. - - Insert-mode :kbd:`ctrl-n` accepts autosuggestions (:issue:`10339`). + - :kbd:`ctrl-n` in insert mode accepts autosuggestions (:issue:`10339`). - Outside insert mode, the cursor will no longer be placed beyond the last character on the commandline. - When the cursor is at the end of the commandline, a single :kbd:`l` will accept an autosuggestion (:issue:`10286`). - The cursor position after pasting (:kbd:`p`) has been corrected. @@ -236,6 +239,7 @@ Completions Note that this escaping is usually not necessary since the completion engine already tries to guess whether the separator is actually part of a file name. - Various new completion scripts and numerous updates to existing ones. +- Completions could hang if the ``PAGER`` environment variable was sent to certain editors on macOS, FreeBSD and some other platforms. This has been fixed (:issue:`10820`). - Generated completions are now stored in ``$XDG_CACHE_HOME/fish`` or ``~/.cache/fish`` by default (:issue:`10369`) - A regression in fish 3.1, where completing a command line could change it completely, has been fixed (:issue:`10904`). @@ -257,7 +261,9 @@ Other improvements - ``fish_indent`` now preserves the modification time of files if there were no changes (:issue:`10624`). - Performance in launching external processes has been improved for many cases (:issue:`10869`). - Performance and interactivity under Windows Subsystem for Linux has been improved, with a workaround for Windows-specific locations being appended to ``$PATH`` by default (:issue:`10506`). +- On macOS, paths from ``/etc/paths`` and ``/etc/manpaths`` containing colons are handled correctly (:issue:`10684`). - Additional filesystems such as AFS are properly detected as remote, which avoids certain hangs due to expensive filesystem locks (:issue:`10818`). +- A spurious error when launching multiple instances of fish for the first time has been removed (:issue:`10813`). .. _rust-packaging: @@ -266,7 +272,7 @@ For distributors fish has been ported to Rust. This means a significant change in dependencies, which are listed in the README. In short, Rust 1.70 or greater is required, and a C++ compiler is no longer needed (although a C compiler is still required, for some C glue code and the tests). -CMake remains the recommended build system, because of cargo's limited support for installing support files. Version 3.5 remains the minimum supported version. The Xcode generator for CMake is not supported any longer (:issue:`9924`). +CMake remains the recommended build system, because of cargo's limited support for installing support files. Version 3.5 remains the minimum supported version. The Xcode generator for CMake is not supported any longer (:issue:`9924`). CMake builds default to optimized release builds (:issue:`10799`). fish no longer depends on the ncurses library, but still uses a terminfo database. When packaging fish, please add a dependency on the package containing your terminfo database instead of curses. From ea115f859567235a9d2c8c4e606cb7ecc3d4839e Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Wed, 26 Feb 2025 22:56:15 +0800 Subject: [PATCH 108/113] CHANGELOG: fix syntax error --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 623cb9613..6d9a39a58 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -192,7 +192,7 @@ New or improved bindings - :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo. - :kbd:`alt-backspace` deletes the argument (including quoted spaces) left of the cursor (:issue:`10766`). - :kbd:`alt-delete` now deletes the argument (including quoted spaces) right of the cursor (:issue:`10766`). -- :kbd:`alt-right` and :kbd:`alt-left` will move by argument (including quoted spaces) in the command line (:issue:`10766)`. +- :kbd:`alt-right` and :kbd:`alt-left` will move by argument (including quoted spaces) in the command line (:issue:`10766`). - Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor: - The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune. - Cursor position synchronization is only supported for a set of known editors, which are now also detected in aliases which use ``complete --wraps``. For example, use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``. From d33b967196df8390f81125734b0bbaf239455637 Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Wed, 26 Feb 2025 23:55:48 +0800 Subject: [PATCH 109/113] CHANGELOG: finalise 4.0.0 / 4.0b1 release notes The majority of users will be going straight from 3.7 to 4.0. The 4.0 notes should reflect this transition, rather than the changes that were only in 4.0b1. --- CHANGELOG.rst | 58 ++++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6d9a39a58..91783a8ea 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,30 +1,3 @@ -Changes since 4.0b1 -------------------- -- :kbd:`ctrl-c` cancels builtin ``read`` again, fixing a regression in the beta. :issue:`10928` -- Fix a BSD-specific regression in the beta that caused crashes when a child process exited with a status like -1 (:issue:`10919`). -- Fix a regression in the beta where ``__fish_cancel_commandline`` caused glitches on multi-line command lines (:issue:`10935`). -- Autosuggestions are case-correcting again (:issue:`10915`). -- Self-installable builds can now also be installed to a specific location by giving a path to ``--install``, like:: - fish --install=$HOME/.local/ - In that case, the fish binary will be moved to "bin/" in that path. :issue:`10923` - -- The config directories will now be created with mode 700 again (:issue:`10962`). -- A ``status buildinfo`` command to print information on how fish was built, to help with debugging (:issue:`10896`). -- Remove the completions for ``dust`` because it conflicted with the Debian/Ubuntu package (:issue:`10922`). -- Improve the documentation style for narrow interfaces (like phones) (:issue:`10942`). -- Add debug information back to cmake builds with the "RelWithDebInfo" profile (:issue:`10959`). -- the :kbd:`ctrl-c` binding now calls a new bind function called "clear-commandline", - the old behavior that leaves a "^C" marker is available as "cancel-commandline" (:issue:`10935`) -- The ``make test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. - The built-in test target will run if you built fish before, but will not print output if it fails (:issue:`11116`). -- :kbd:`alt-backspace`, :kbd:`alt-left` and :kbd:`alt-right` operate on words again instead of full arguments, reverting to how it was in 3.7 and before (:issue:`10926`). -- Keyboard protocols can be turned off by disabling the "keyboard-protocols" feature flag:: - - set -Ua fish_features no-keyboard-protocols - - This is a temporary measure to work around buggy terminals (:issue:`11056`), which appear to be relatively rare. - Use this if something like "=0" or "=5u" appears in your commandline mysteriously. - fish 4.0.0 (released ???) ========================= @@ -40,10 +13,7 @@ Notable backwards-incompatible changes - As part of a larger binding rework, ``bind`` gained a new key notation. In most cases the old notation should keep working, but in rare cases you may have to change a ``bind`` invocation to use the new notation. See :ref:`below <changelog-new-bindings>` for details. -- Terminals that fail to ignore unrecognized OSC or CSI sequences may display garbage. We know cool-retro-term and emacs' ansi-term are affected, - most mainstream terminals are not. -- :kbd:`alt-left` and :kbd:`alt-right` will now move by one argument (which may contain quoted spaces), not just one word like :kbd:`ctrl-left` and :kbd:`ctrl-right` do. -- :kbd:`alt-backspace` will delete an entire argument, not just one word. The old word behavior has been moved to :kbd:`ctrl-backspace`. If your terminal doesn't support `ctrl-backspace`, consider using :kbd:`ctrl-w`, or :kbd:`alt-b` + :kbd:`alt-d`. +- :kbd:`ctrl-c` now calls a new bind function called ``clear-commandline``. The old behavior, which leaves a "^C" marker, is available as ``cancel-commandline`` (:issue:`10935`) - ``random`` will produce different values from previous versions of fish when used with the same seed, and will work more sensibly with small seed numbers. The seed was never guaranteed to give the same result across systems, so we do not expect this to have a large impact (:issue:`9593`). @@ -58,8 +28,9 @@ Notable backwards-incompatible changes set -Ua fish_features no-qmark-noglob The flag will eventually be made read-only, making it impossible to turn off. +- Terminals that fail to ignore unrecognized OSC or CSI sequences may display garbage. We know cool-retro-term and emacs' ansi-term are affected, but most mainstream terminals are not. - fish no longer searches directories from the Windows system/user ``$PATH`` environment variable for Linux executables. To execute Linux binaries by name (i.e. not with a relative or absolute path) from a Windows folder, make sure the ``/mnt/c/...`` path is explicitly added to ``$fish_user_paths`` and not just automatically appended to ``$PATH`` by ``wsl.exe`` (:issue:`10506`). -- Under Microsoft Windows Subsystem for Linux 1 (not WSL 2) , backgrounded jobs that have not been disowned and do not terminate on their own after a ``SIGHUP`` + ``SIGCONT`` sequence will be explicitly killed by fish on exit (after the usual prompt to close or disown them) to work around a WSL 1 deficiency that sees backgrounded processes that run into ``SIGTTOU`` remain in a suspended state indefinitely (:issue:`5263`). The workaround is to explicitly ``disown`` processes you wish to outlive the shell session. +- Under Microsoft Windows Subsystem for Linux 1 (not WSL 2), backgrounded jobs that have not been disowned and do not terminate on their own after a ``SIGHUP`` + ``SIGCONT`` sequence will be explicitly killed by fish on exit (after the usual prompt to close or disown them) to work around a WSL 1 deficiency that sees backgrounded processes that run into ``SIGTTOU`` remain in a suspended state indefinitely (:issue:`5263`). The workaround is to explicitly ``disown`` processes you wish to outlive the shell session. Notable improvements and fixes ------------------------------ @@ -76,6 +47,14 @@ Notable improvements and fixes - ``bind ctrl-x,alt-c 'do something'`` binds a sequence of two keys. Any key argument that starts with an ASCII control character (like ``\e`` or ``\cX``) or is up to 3 characters long, not a named key, and does not contain ``,`` or ``-`` will be interpreted in the old syntax to keep compatibility for the majority of bindings. + + Keyboard protocols can be turned off by disabling the "keyboard-protocols" feature flag:: + + set -Ua fish_features no-keyboard-protocols + + This is a temporary measure to work around buggy terminals (:issue:`11056`), which appear to be relatively rare. + Use this if something like "=0" or "=5u" appears in your commandline mysteriously. + - fish can now be built as a self-installing binary (:issue:`10367`). That means it can be easily built on one system and copied to another, where it can extract supporting files. To do this, run:: @@ -190,9 +169,6 @@ New or improved bindings - During up-arrow history search, :kbd:`shift-delete` will delete the current search item and move to the next older item. Previously this was only supported in the history pager. - :kbd:`shift-delete` will also remove the currently-displayed autosuggestion from history, and remove it as a suggestion. - :kbd:`ctrl-Z` (also known as :kbd:`ctrl-shift-z`) is now bound to redo. -- :kbd:`alt-backspace` deletes the argument (including quoted spaces) left of the cursor (:issue:`10766`). -- :kbd:`alt-delete` now deletes the argument (including quoted spaces) right of the cursor (:issue:`10766`). -- :kbd:`alt-right` and :kbd:`alt-left` will move by argument (including quoted spaces) in the command line (:issue:`10766`). - Some improvements to the :kbd:`alt-e` binding which edits the command line in an external editor: - The editor's cursor position is copied back to fish. This is currently supported for Vim and Kakoune. - Cursor position synchronization is only supported for a set of known editors, which are now also detected in aliases which use ``complete --wraps``. For example, use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``. @@ -257,6 +233,7 @@ Improved terminal support Other improvements ------------------ +- ``status`` gained a ``buildinfo`` subcommand, to print information on how fish was built, to help with debugging (:issue:`10896`). - ``fish_indent`` will now collapse multiple empty lines into one (:issue:`10325`). - ``fish_indent`` now preserves the modification time of files if there were no changes (:issue:`10624`). - Performance in launching external processes has been improved for many cases (:issue:`10869`). @@ -276,10 +253,21 @@ CMake remains the recommended build system, because of cargo's limited support f fish no longer depends on the ncurses library, but still uses a terminfo database. When packaging fish, please add a dependency on the package containing your terminfo database instead of curses. +The ``test`` target was removed as it can no longer be defined in new CMake versions. Use ``make fish_run_tests``. Any existing test target will not print output if it fails (:issue:`11116`). + The Web-based configuration has been rewritten to use Alpine.js (:issue:`9554`). -------------- +fish 4.0b1 (released December 17, 2024) +======================================= + +A number of improvements were included in fish 4.0.0 following the beta release of 4.0b1. These include fixes for regressions, improvements to completions and documentation, and the removal of a small number of problematic changes. + +The full list of fixed issues can be found on the `GitHub milestone page for 4.0-final <https://github.com/fish-shell/fish-shell/milestone/43>`_. + +-------------- + fish 3.7.1 (released March 19, 2024) ==================================== From 6d30751f1c1f2dd944f0b82175a105b3a0ba0d85 Mon Sep 17 00:00:00 2001 From: Fabian Boehm <FHomborg@gmail.com> Date: Fri, 7 Feb 2025 12:21:19 +0100 Subject: [PATCH 110/113] tests: Use command ls to avoid indicators This can happen if your filesystem on macOS has xattrs, so the newly created dirs will also have them and `ls` will print an "@" indicator. Fixes #11137 (cherry picked from commit 414293521ee3b32b6f462f17514d86147e10e249) --- tests/checks/create-base-directories.fish | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/checks/create-base-directories.fish b/tests/checks/create-base-directories.fish index 1dc97891d..55b435d90 100644 --- a/tests/checks/create-base-directories.fish +++ b/tests/checks/create-base-directories.fish @@ -10,7 +10,8 @@ $fish -c '' # Check that existing directories kept their permissions, and new directories # have the right permissions according to the XDG Base Directory Specification. -ls -ld $dir/old $dir/old/new $dir/old/new/fish | awk '{print $1}' +# Use command ls to turn off indicators in case of xattrs or similar. +command ls -ld $dir/old $dir/old/new $dir/old/new/fish | awk '{print $1}' # CHECK: drwxr-xr-x # CHECK: drwx------ # CHECK: drwx------ From 1c57144f8bd6015abd0bddd2c53d54ee27f84959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= <lnicola@users.noreply.github.com> Date: Wed, 26 Feb 2025 21:50:04 +0200 Subject: [PATCH 111/113] Fix `create-base-directories.fish` with SELinux (cherry picked from commit f224ff1d28dcf1e8f10b41b6cb96202521357d86) --- tests/checks/create-base-directories.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/checks/create-base-directories.fish b/tests/checks/create-base-directories.fish index 55b435d90..f6c863495 100644 --- a/tests/checks/create-base-directories.fish +++ b/tests/checks/create-base-directories.fish @@ -10,8 +10,8 @@ $fish -c '' # Check that existing directories kept their permissions, and new directories # have the right permissions according to the XDG Base Directory Specification. -# Use command ls to turn off indicators in case of xattrs or similar. -command ls -ld $dir/old $dir/old/new $dir/old/new/fish | awk '{print $1}' +# Use command ls and awk to strip off xattr or SELinux indicators. +command ls -ld $dir/old $dir/old/new $dir/old/new/fish | awk '{print substr($1, 1, 10)}' # CHECK: drwxr-xr-x # CHECK: drwx------ # CHECK: drwx------ From eb336889b7bcb88eb0e1f3dd678ae52275280186 Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Thu, 27 Feb 2025 16:00:33 +0800 Subject: [PATCH 112/113] Release 4.0.0 --- CHANGELOG.rst | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 91783a8ea..de0bbb9cf 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,11 +1,7 @@ -fish 4.0.0 (released ???) -========================= +fish 4.0.0 (released February 27, 2025) +======================================= -.. ignore: 751 2037 3017 3018 3162 3299 4770 4865 5284 5924 5991 6981 6996 7172 9332 9439 9440 9442 9452 9461 9469 9480 9482 9520 9536 9541 9542 9544 9556 9559 9561 9563 9566 9567 9568 9573 9575 9576 9579 9585 9586 9588 9589 9591 9592 9593 9594 9599 9600 9603 9607 9608 9612 9613 9615 9616 9619 9621 9625 9626 9630 9636 9637 9638 9641 9642 9643 9653 9654 9658 9661 9666 9671 9673 9688 9725 9726 9729 9735 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9797 9816 9818 9821 9839 9845 9856 9859 9861 9862 9863 9864 9867 9869 9873 9874 9879 9881 9893 9894 9896 9902 9916 9923 9925 9927 9928 9930 9947 9948 9950 9952 9962 9963 9966 9968 9980 9981 9984 9990 9991 10040 10061 10078 10090 10101 10102 10108 10111 10114 10115 10121 10128 10129 10143 10145 10146 10161 10173 10174 10175 10179 10180 10181 10182 10184 10185 10186 10188 10195 10198 10200 10201 10204 10210 10214 10219 10220 10222 10223 10227 10228 10232 10235 10237 10241 10243 10244 10245 10246 10251 10254 10260 10263 10267 10268 10270 10272 10276 10277 10278 10279 10281 10288 10290 10291 10293 10305 10306 10307 10308 10309 10316 10317 10321 10327 10328 10329 10330 10336 10338 10340 10342 10345 10346 10347 10348 10349 10353 10354 10355 10356 10357 10358 10360 10366 10368 10370 10371 10372 10373 10377 10379 10381 10388 10389 10390 10395 10398 10400 10403 10404 10407 10408 10409 10411 10412 10415 10417 10418 10427 10429 10434 10438 10439 10440 10441 10442 10443 10445 10446 10448 10450 10451 10452 10456 10457 10462 10463 10464 10466 10467 10471 10473 10474 10479 10481 10485 10486 10487 10490 10491 10492 10494 10499 10500 10503 10504 10505 10507 10508 10509 10510 10511 10512 10513 10518 10519 10520 10524 10528 10529 10530 10538 10539 10541 10542 10547 10548 10549 10555 10560 10562 10564 10565 10568 10569 10572 10573 10574 10575 10578 10580 10582 10583 10585 10588 10591 10594 10595 10596 10609 10615 10616 10622 10623 10625 10627 10628 10634 10635 10636 10637 10640 10646 10647 10649 10650 10652 10653 10654 10655 10657 10659 10662 10663 10664 10667 10668 10669 10670 10674 10679 10681 10685 10686 10687 10688 10689 10697 10698 10702 10703 10707 10708 10711 10712 10713 10716 10718 10719 10721 10724 10726 10727 10728 10731 10738 10752 10760 10762 10763 10767 10770 10775 10776 10778 10779 10790 10800 10782 10784 10787 10788 10789 10792 10795 10796 10801 10812 10817 10825 10836 10839 10844 10845 10847 10851 10854 10855 10858 10863 10864 10873 10874 10880 10885 10891 10892 10894 10896 10899 10906 10907 10909 10911 10912 10913 10915 10916 10919 10920 10922 10923 10928 10935 10936 10941 10942 10943 10944 10945 10946 10947 10949 10951 10952 10953 10958 10959 10962 10968 10971 10994 10995 10999 11002 11005 11014 11015 11016 11017 11019 11026 11034 11035 11037 11040 11041 11049 11060 11067 11074 11086 - -fish's core code has been ported from C++ to Rust (:issue:`9512`). -This means a large change in dependencies and how to build fish. -Packagers should see the :ref:`For Distributors <rust-packaging>` section at the end. +fish's core code has been ported from C++ to Rust (:issue:`9512`). This means a large change in dependencies and how to build fish. However, there should be no direct impact on users. Packagers should see the :ref:`For Distributors <rust-packaging>` section at the end. Notable backwards-incompatible changes -------------------------------------- From 1e069b0fff20b153bc7f824f9f9b820ca4117e1e Mon Sep 17 00:00:00 2001 From: David Adam <zanchey@ucc.gu.uwa.edu.au> Date: Thu, 27 Feb 2025 21:32:23 +0800 Subject: [PATCH 113/113] Cargo metadata: bump version number --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 394e7d328..bc04d893a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,7 +112,7 @@ dependencies = [ [[package]] name = "fish" -version = "4.0.0-beta.1" +version = "4.0.0" dependencies = [ "bitflags", "cc", diff --git a/Cargo.toml b/Cargo.toml index 69fc9bd02..2089531ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ debug = true [package] name = "fish" -version = "4.0.0-beta.1" +version = "4.0.0" edition.workspace = true rust-version.workspace = true default-run = "fish"