Compare commits

...

488 Commits

Author SHA1 Message Date
Johannes Altmanninger
56bbdb3f39 Release 4.0.9
Created by ./build_tools/release.sh 4.0.9
2025-09-27 20:24:24 +02:00
Johannes Altmanninger
ce4aa7669d Release workflow fixups 2025-09-27 20:20:44 +02:00
Johannes Altmanninger
af8d8d3d1b release-notes.sh: add stats, round off committer list
Instead of adding these to the Markdown directly, add it to the
fake CHANGELOG.rst source, which makes escaping easier, and allows
generating other formats than Markdown in future.

(cherry picked from commit 06bbac8ed6)
2025-09-27 14:23:25 +02:00
Johannes Altmanninger
fecd0b4bf1 Revert "Only load sphinx_markdown_builder extension if it's used"
sphinx-build fails with

	sphinx.errors.SphinxError: Builder name markdown not registered or available through entry point

Apparently this issue was hidden locally by caching, and not checked
in CI because of this error causing
tests/checks/sphinx-markdown-changelog.fish to be skipped.

	sphinx-build 7.2.6
	runner@runnervm3ublj:~/work/fish-shell/fish-shell$ python -c 'import sphinx_markdown_builder'
	Traceback (most recent call last):
	  File "<string>", line 1, in <module>
	  File "/home/runner/.local/lib/python3.12/site-packages/sphinx_markdown_builder/__init__.py", line 6, in <module>
	    from sphinx.util.typing import ExtensionMetadata
	ImportError: cannot import name 'ExtensionMetadata' from 'sphinx.util.typing' (/usr/lib/python3/dist-packages/sphinx/util/typing.py)

This reverts commit 7b495497d7.

While at it, fail the test earlier if something went wrong, because the
remaining check will likely also fail and confuse.

(cherry picked from commit aab22a453b)
2025-09-27 14:23:25 +02:00
Johannes Altmanninger
2d4a43302a release-notes.sh: remove line breaks from generated Markdown, for GitHub
GitHub-flavored Markdown translates line breaks to <br/>, which does
not match our intent. Work around that by joining lines when producing
Markdown output.

(cherry picked from commit 4cc2d2ec30)
2025-09-27 14:23:25 +02:00
Johannes Altmanninger
5a4a913220 Enable sphinx parallelism also when building markdown release notes
We get a warning about sphinx_markdown_builder not being
parallelizable. Fix that.

Ref: https://github.com/liran-funaro/sphinx-markdown-builder/pull/38
(cherry picked from commit e6541c5c93)
2025-09-27 06:03:16 +02:00
Johannes Altmanninger
904ceba858 Only load sphinx_markdown_builder extension if it's used
As is, building man pages or HTML docs while sphinx_markdown_builder
is installed, will result in unrelated warnings.  Remove those by
removing it from the extensions config.  Markdown building (only used
for changelog) seems to work without this just fine.

(cherry picked from commit 7b495497d7)
2025-09-27 06:03:16 +02:00
Johannes Altmanninger
3c2adfbd4b Fix markdown changelog generation test
System tests typically run outside the workspace directory, but they
still have read-only access to the workspace; fix it accordingly.
This test only works on git checkouts, not in tarballs, so skip it
if .git doesn't exist.

(cherry picked from commit 6e90d9bd6f)
2025-09-27 06:03:16 +02:00
Johannes Altmanninger
9e4850b40a Disable sphinx-markdown-builder in tests again for now
Somehow I didn't realize this breaks the tests/checks/sphinx-* tests.

(cherry picked from commit b37b57781b)
2025-09-27 06:03:16 +02:00
Johannes Altmanninger
211b3f6670 release workflow: credit contributors in release notes
While at it, do a 's/^--$/^---/' to fix Markdown syntax for horizontal
line for CommonMark-based parsers.

(cherry picked from commit 22ffc31b71)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
d530e127f5 Test markdown changelog creation in CI
Extract a github action to install the same version used in the release
workflow.  In future we should probably migrate to requirements.txt
or similar.

(cherry picked from commit 127c02992d)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
a6698098db release workflow: resolve relative references in changelog properly
Instead of having sphinx-build only build CHANGELOG.rst, build the
entire thing, so relative references (":doc:", ":ref:") can be resolved
properly.  Replace our sed-based hacks with 'markdown_http_base'.

(cherry picked from commit 765ca54d59)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
f73b260a3a release workflow: extract script for generating markdown release notes
(cherry picked from commit 1519ea74be)
2025-09-24 15:58:42 +02:00
Daniel Rainer
ffa7abd6ff Fix release workflow syntax
The previous version results in an immediate workflow failure due to a
syntax error in the YAML. `workflow_dispatch` should be a dictionary
key, with its value being another dictionary (whose only key is `inputs`
at the moment).

(cherry picked from commit c8f31ceedb)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
b87ef689fa github release workflow: fix structure
(cherry picked from commit b1d1ef1b6e)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
4fe70f6965 github release workflow: only run on explicit dispatch
Release automation can be tested on any GitHub fork, using

	build_tools/release.sh $version $repository_owner $git_remote

which should work perfectly except for macOS packages (which fail
unless provided GitHub secrets).

People might push tags to their forks, both non-release tags (which
would trigger an early failure in "is-release-tag") or replicas of
our actual release tags (which would create a draft release etc. and
only fail when building macOS packages).

Run on explicit workflow dispatch to make sure it's not triggered by
accident like that.

This means that we'll use the .github/workflows/release.yml from
the default branch (i.e. master), so try to make sure it matches the
version in the release, to prevent accidents.

Closes #11816

(cherry picked from commit 01361b9217)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
7001abca9f github release workflow: use github context only if needed
(cherry picked from commit dab8df1a18)
2025-09-24 15:58:42 +02:00
Johannes Altmanninger
199316f1a3 build_tools/make_macos_pkg.sh: fix inconsistent version computation
make_tarball.sh and others do it differently.

(cherry picked from commit c771ff06d4)
2025-09-24 15:58:42 +02:00
David Adam
78c9ab29cd debian packaging: don't remove Cargo.toml.orig files
Newer versions of cargo include the Cargo.toml.orig file when vendoring,
but dh_clean removes those by default. Try to disable this to fix the
package builds again.

(cherry picked from commit 67e8657109)
2025-09-21 10:41:44 +08:00
David Adam
91c9dbdd89 debian packaging: use the correct test target
(cherry picked from commit 5e2ddaace9)
2025-09-21 10:41:44 +08:00
David Adam
e737ad1f0f debian packaging: fix typo 2025-09-20 22:11:10 +08:00
Johannes Altmanninger
6f536c6304 Fix new job control test; changelog 2025-09-20 14:57:49 +02:00
Piotr Kubaj
a1b4b391b2 path.rs: fix build on ARM / POWER
error[E0308]: mismatched types
   --> src/path.rs:749:13
    |
748 |         let remoteness = remoteness_via_statfs(
    |                          --------------------- arguments to this function are incorrect
749 |             libc::statfs,
    |             ^^^^^^^^^^^^ expected fn pointer, found fn item
    |
    = note: expected fn pointer `unsafe extern "C" fn(*const i8, _) -> _`
                  found fn item `unsafe extern "C" fn(*const u8, _) -> _ {libc::statfs}`
note: function defined here
   --> src/path.rs:712:12
    |
712 |         fn remoteness_via_statfs<StatFS, Flags>(
    |            ^^^^^^^^^^^^^^^^^^^^^
713 |             statfn: unsafe extern "C" fn(*const i8, *mut StatFS) -> libc::c_int,
    |             -------------------------------------------------------------------

error[E0308]: mismatched types
   --> src/path.rs:725:34
    |
725 |             if unsafe { (statfn)(path.as_ptr(), buf.as_mut_ptr()) } < 0 {
    |                         -------- ^^^^^^^^^^^^^ expected `*const i8`, found `*const u8`
    |                         |
    |                         arguments to this function are incorrect
    |
    = note: expected raw pointer `*const i8`
               found raw pointer `*const u8`

For more information about this error, try `rustc --explain E0308`.
error: could not compile `fish` (lib) due to 2 previous errors

(cherry picked from commit 91ee45b0e1)
2025-09-20 14:32:55 +02:00
Johannes Altmanninger
a27f615350 Fix crash on "bg" of non-job-controlled job
fish -c 'sleep 1 & bg %1' is supposed to fail because the job is not
under job control.

When we try to print the failure, we accidentally still
hold a borrow of the job list.  This blows up because we use
"builtin_print_help_error()" to print the failure message; that
function runs "job_reap()" which wants an exclusive borrow of the
job list. Let's drop our job list earlier.

(cherry picked from commit 26116b477e)
2025-09-20 14:03:49 +02:00
Johannes Altmanninger
46ce8a1d2f Fix regression breaking self-insert of kitty shifted codepoint
Commit 50a6e486a5 (Allow explicit shift modifier for non-ASCII
letters, fix capslock behavior, 2025-03-30) delayed handling of kitty
keyboard protocol's shifted codepoints.  It does handle shifted
codepoints when matching keys to mappings; but it fails to handle
them in the self-insert code paths where we want to insert the text
represented by CharEvent::Key.
Fix it by resolving the shifted key.

Fixes #11813

(cherry picked from commit bb916f8d73)
2025-09-20 14:03:38 +02:00
Johannes Altmanninger
03ccc88868 Move key codepoint computation to key event
For the next commit.

(cherry picked from commit 8d12dfe065)
2025-09-20 14:02:30 +02:00
Johannes Altmanninger
79cf4c3e0b build_tools/release.sh: approve macos-codesign 2025-09-19 09:53:02 +02:00
Johannes Altmanninger
701e1a3b02 github release workflow: make sure that last changelog entry isn't given spurious markup
(cherry picked from commit ff633bd744)
2025-09-18 10:46:40 +02:00
Johannes Altmanninger
b1ec703ceb Release 4.0.8
Created by ./build_tools/release.sh 4.0.8
2025-09-18 10:00:03 +02:00
Johannes Altmanninger
553612f74a github release workflow: work around trailing "---"-line in changelog
The extracted release notes trigger a sphinx warning

	/tmp/tmp.V6RGP92nc2/src/index.rst:6:Document may not end with a transition.

which we don't seem to get on the full CHANGELOG.rst.
Let's work around that for now.

(cherry picked from commit 0d46c26988)
2025-09-18 09:58:55 +02:00
Johannes Altmanninger
861decb003 build_tools/release.sh: relax assertion about changelog title
I'd like to move to a process where everything goes into master first,
and then flows downstream to any release branches (i.e. no merging
of Integration_* branches back into master).

The only thing we need to change for that is to add release notes for
patch releases eagerly on master.  That implies that we want to use
the actual version instead of ???.  (Only if something goes wrong
in the release process, we need to change this on both branches,
but that should happen too often.)

(cherry picked from commit 1840df96a2)
2025-09-18 09:38:30 +02:00
Johannes Altmanninger
3b8780aa6c build_tools/release.sh: push to the integration branch when all goes well
Also, ignore any "sendemail.to" Git config, and remove a temporary
statement in release notes.

(cherry picked from commit 3456b33050)
2025-09-18 09:32:37 +02:00
Johannes Altmanninger
7783505bee Fix new-style bindings shadowing raw escape sequence bindings
Given

	bind up "echo user up, new notation"
	bind \e\[A "echo user up, legacy notation"

prior to b9d9e7edc6 (Match bindings with explicit shift
first, 2025-05-24), we prioritized the legacy notation because
input_mapping_insert_sorted() makes us try longer sequences first --
and "up" is only one key compared to the three-key legacy sequence.

This prioritization was broken in b9d9e7edc6, causing plugins that
update to the "bind up" notation to break users who haven't (#11803).

Even worse, it caused preset bindings to shadow user ones:

	bind --preset up "echo preset up, new notation"
	bind \e\[A "echo user up, legacy notation"

Restore backwards compatibility by treating matches against legacy
notation like exact matches again.

(cherry picked from commit 9a04c15894)
2025-09-18 09:29:45 +02:00
Johannes Altmanninger
23c25ffe43 build_tools/release.sh: fixes for updating fish-site
Also check that "cd fish-site && make && make new-release" doesn't
leave behind untracked files we're not aware of.  This implies that
this script ought to refuse to run if there are untracked files,
at least in fish-site.

(cherry picked from commit 529f722d2f)
2025-09-13 11:13:17 +02:00
Johannes Altmanninger
7619fa316c Release 4.0.6
Created by ./build_tools/release.sh 4.0.6
2025-09-12 11:47:41 +02:00
Johannes Altmanninger
e2005c64b3 Backport release-script related changes from master
Will commit these to master momentarily (#10449).
2025-09-12 11:47:01 +02:00
Johannes Altmanninger
9ada3e6c16 Group changelog entries 2025-09-12 11:14:52 +02:00
Johannes Altmanninger
bdba2c227d CHANGELOG: update 2025-09-11 13:55:30 +02:00
Johannes Altmanninger
201882e72a CHANGELOG: fix inline literal RST syntax 2025-09-09 07:46:31 +02:00
Johannes Altmanninger
1db0ff9f77 Allow overriding __fish_update_cwd_osc to work around terminal bugs
See #11777

While at it, pull in the TERM=dumb check from master.

(cherry picked from commit 898cc3242b)
2025-09-05 09:39:57 +02:00
Johannes Altmanninger
9258275fe6 config_paths: fix compiled-in locale dir for installed, non-embed builds
Commit bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30) broke the locale path.

Commit c3740b85be (config_paths: fix compiled-in locale dir,
2025-06-12) fixed what it calls "case 4", but "case 2" is also
affected; fix that. Before/after:

	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/fish/locale
	$ ~/.local/opt/fish/bin/fish -d config
	paths.locale: /home/johannes/.local/opt/fish/share/locale

See https://github.com/fish-shell/fish-shell/issues/11683#issuecomment-3218190662

(cherry picked from commit 21a07f08a3)
2025-08-29 19:29:03 +02:00
Johannes Altmanninger
6900b89c82 Add mark-prompt feature flag
So far, terminals that fail to parse OSC sequences are the only reason
for wanting to turn off OSC 133.  Let's allow to work around it by
adding a feature flag (which is implied to be temporary).

To use it, run this once, and restart fish:

    set -Ua fish_features no-mark-prompt

Tested with

    fish -i | string escape | grep 133 &&
    ! fish_features=no-mark-prompt fish -i | string escape | grep 133

See #11749
Also #11609
2025-08-27 09:17:35 +02:00
Johannes Altmanninger
9c0086b7af Backport default alt-delete binding
This is standard on macOS and in chrome/firefox.

On master, this was sneakily added in
2bb5cbc959 (Default bindings for token movements v2, 2025-03-04)
and before that in
6af96a81a8 (Default bindings for token movement commands, 2024-10-05)

Ref: https://lobste.rs/s/ndlwoh/wizard_his_shell#c_qvhnvd
2025-08-02 09:53:22 +02:00
Johannes Altmanninger
e200abe39c __fish_seen_subcommand_from: fix regression causing false negatives given multiple arguments
Fixes 2bfa7db7bc (Restructure __fish_seen_subcommand_from, 2024-07-07)
Fixes #11685

(cherry picked from commit 4412164fd4)
2025-07-26 20:36:53 +02:00
Johannes Altmanninger
0c8f1f4220 Fix async-signal safety in SIGTERM handler
Cherry-picked from
- 941701da3d (Restore some async-signal discipline to SIGTERM, 2025-06-15)
- 81d45caa76e (Restore terminal state on SIGTERM again, 2025-06-21)

Also, be more careful in terminal_protocols_disable_ifn about accessing
reader_current_data(), as pointed out in 65a4cb5245 (Revert "Restore terminal
state on SIGTERM again", 2025-07-19).

See #11597
2025-07-26 13:09:18 +02:00
Johannes Altmanninger
e593da1c2e Increase timeout when reading escape sequences inside paste/kitty kbd
Historically, fish has treated input bytes [0x1b, 'b'] as alt-b (rather than
"escape,b") if the second byte arrives within 30ms of the first.

Since we made builtin bind match key events instead of raw byte sequences,
we have another place where we do similar disambiguation: when we read keys
such as alt-left ("\e[1;3D"), we only consider bytes to be part of this
sequence if stdin is immediately readable (actually "readable after a 1ms
timeout" since e1be842 (Work around torn byte sequences in qemu kbd input
with 1ms timeout, 2025-03-04)).

This is technically wrong but has worked in practice (for Kakoune etc.).

Issue #11668 reports two issues on some Windows terminals feeding a remote
fish shell:
- the "bracketed paste finished" sequence may be split into multiple packets,
  which causes a delay of > 1ms between individual bytes being readable.
- AutoHotKey scripts simulating seven "left" keys result in sequence tearing
  as well.

Try to fix the paste case by increasing the timeout when parsing escape
sequences.

Also increase the timeout for terminals that support the kitty keyboard
protocol.  The user should only notice this new delay after pressing one of
escape,O, escape,P, escape,[, or escape,] **while the kitty keyboard protocol
is disabled** (e.g. while an external command is running).  In this case,
the fish_escape_delay_ms is also virtually increased; hopefully this edge
case is not ever relevant.

Part of #11668

(cherry picked from commit 30ff3710a0)
2025-07-25 18:29:19 +02:00
Johannes Altmanninger
6666c8f1cd Block interrupts and uvar events while decoding key
readb() has only one caller that passes blocking=false: try_readb().
This function is used while decoding keys; anything but a successful read
is treated as "end of input sequence".

This means that key input sequences such as \e[1;3D
can be torn apart by
- signals (EINTR) which is more likely since e1be842 (Work around torn byte
  sequences in qemu kbd input with 1ms timeout, 2025-03-04).
- universal variable notifications (from other fish processes)

Fix this by blocking signals and not listening on the uvar fd.  We do something
similar when matching key sequences against bindings, so extract a function
and use it for key decoding too.

Ref: https://github.com/fish-shell/fish-shell/issues/11668#issuecomment-3101341081
(cherry picked from commit da96172739)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
3e61036911 Revert "Change readch() into try_readch()"
try_readch() was added to help a fuzzing harness, specifically to avoid a
call to `unreachable!()` in the NothingToRead case.  I don't know much about
that but it seems like we should find a better way to tell the fuzzer that
this can't happen.

Fortunately the next commit will get rid of readb()'s "blocking" argument,
along the NothingToRead enum variant. So we'll no longer need this.

This reverts commit b92830cb17.

(cherry picked from commit fb7ee0db74)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
f23a479b81 Reduce MaybeUninit lifetime
(cherry picked from commit 137f220225)
2025-07-25 18:21:27 +02:00
王宇逸
e274ff41d0 Use uninit instead of zeroed (src/input_common.rs)
(cherry picked from commit 7c2c7f5874)
2025-07-25 18:21:27 +02:00
Johannes Altmanninger
d2af306f3d Fix some unused-ControlFlow warnings 2025-07-25 18:11:04 +02:00
Johannes Altmanninger
0e7c7f1745 Remove unused import
(cherry picked from commit 07ff4e7df0)
2025-07-25 11:57:21 +02:00
Johannes Altmanninger
3fada80553 Fix regression causing \e[ to be interpreted as ctrl-[
Fixes 3201cb9f01 (Stop parsing invalid CSI/SS3 sequences as alt-[/alt-o,
2024-12-30).

(cherry picked from commit 43d583d991)
2025-07-25 11:49:07 +02:00
Johannes Altmanninger
c7d4acbef8 Update changelog 2025-06-29 16:01:44 +02:00
Johannes Altmanninger
e204a4c126 Add ctrl-alt-h compatibility binding
Historically, ctrl-i sends the same code as tab, ctrl-h sends backspace and
ctrl-j and ctrl-m behave like enter.

Even for terminals that send unambiguous encodings (via the kitty keyboard
protocol), we have kept bindings like ctrl-h, to support existing habits.

We forgot that pressing alt-ctrl-h would behave like alt-backspace (and can
be easier to reach) so maybe we should add that as well.

Don't add ctrl-shift-i because at least on Linux, that's usually intercepted
by the terminal emulator.

Technically there are some more such as "ctrl-2" (which used to do the same as
"ctrl-space") but I don't think anyone uses that over "ctrl-space".

Closes #https://github.com/fish-shell/fish-shell/discussions/11548

(cherry picked from commit 4d67ca7c58)
2025-06-28 14:20:03 +02:00
Johannes Altmanninger
9af33802ec Use statvfs on NetBSD again to fix build
From commit ba00d721f4 (Correct statvfs call to statfs, 2025-06-19):

> This was missed in the Rust port

To elaborate:

- ec176dc07e (Port path.h, 2023-04-09) didn't change this (as before,
 `statvfs` used `ST_LOCAL` and `statfs` used `MNT_LOCAL`)
- 6877773fdd (Fix build on NetBSD (#10270), 2024-01-28) changed the `statvfs`
  call to `statfs`, presumably due to the libc-wrapper for
  `statvfs` being missing on NetBSD.  This change happens
  to work fine on NetBSD because they do [`#define ST_LOCAL
  MNT_LOCAL`](https://github.com/fish-shell/fish-shell/pull/11486#discussion_r2092408952)
  But it was wrong on others like macOS and FreeBSD, which was fixed by
  ba00d721f4 (but that broke the build on NetBSD).
- 7228cb15bf (Include sys/statvfs.h for the definition of ST_LOCAL (Rust
  port regression), 2025-05-16)
  fixed a code clone left behind by the above commit (incorrectly assuming
  that the clone had always existed.)

Fix the NetBSD build specifically by using statfs on that platform.

Note that this still doesn't make the behavior equivalent to commit LastC++11.
That one used ST_LOCAL if defined, and otherwise MNT_LOCAL if defined.

If we want perfect equivalence, we could detect both flags in `src/build.rs`.
Then we would also build on operating systems that define neither. Not sure.

Closes #11596

(cherry picked from commit 6644cc9b0e)
2025-06-28 11:46:25 +02:00
王宇逸
eecf0814a1 Use uninit instead of zeroed (cherry-pikcked only the change to src/path.rs)
(cherry picked from commit 7c2c7f5874)
2025-06-28 11:46:25 +02:00
Johannes Altmanninger
1ceebdf580 Fix some CSI commands being sent to old midnight commander
Commit 97581ed20f (Do send bracketed paste inside midnight commander,
2024-10-12) accidentally started sending CSI commands such as "CSI >5;0m",
which we intentionally didn't do for some old versions of Midnight Commander,
which fail to parse them. Fix that.

Fixes #11617
2025-06-25 13:36:03 +02:00
Johannes Altmanninger
335f91babd completions/git: fix spurious error when no subcommand is in $PATH
Systems like NixOS might not have "git-receive-pack" or any other "git-*"
executable in in $PATH -- instead they patch git to use absolute paths.
This is weird. But no reason for us to fail. Silence the error.

Fixes #11590

(cherry picked from commit 4f46d369c4)
2025-06-24 11:59:57 +08:00
Johannes Altmanninger
ec66749369 __fish_complete_list: only unescape "$(commandline -t)"
Commit cd3da62d24 (fix(completion): unescape strings for __fish_complete_list,
2024-09-17) bravely addressed an issue that exists in a lot of completions.
It did so only for __fish_complete_list. Fair enough.

Unfortunately it unescaped more than just "$(commandline -t)".

This causes the problem described at
https://github.com/fish-shell/fish-shell/issues/11508#issuecomment-2889088934
where completion descriptions containing a backslash followed by "n" are
interpreted as newlines, breaking the completion parser.  Fix that.

(cherry picked from commit 60881f1195)
2025-06-21 18:58:33 +02:00
Johannes Altmanninger
6e9e33d81d __fish_complete_list: strip "--foo=" prefix from replacing completions
Given a command line like

	foo --foo=bar=baz=qux\=argument

(the behavior is the same if '=' is substituted with ':').

fish completes arguments starting from the last unescaped separator, i.e.

	foo --foo=bar=baz=qux\=argument
			 ^
__fish_complete_list provides completions like

	printf %s\n (commandline -t)(printf %s\n choice1 choice2 ...)

This means that completions include the "--foo=bar=baz=" prefix.

This is wrong. This wasn't a problem until commit f9febba (Fix replacing
completions with a -foo prefix, 2024-12-14), because prior to that, replacing
completions would replace the entire token.
This made it too hard to writ ecompletions like

	complete -c foo -s s -l long -xa "hello-world goodbye-friend"

that would work with "foo --long fri" as well as "foo --long=frie".
Replacing the entire token would only work if the completion included that
prefix, but the above command is supposed to just work.
So f9febba made us replace only the part after the separator.

Unfortunately that caused the earlier problem.  Work around this.  The change
is not pretty, but it's a compromise until we have a better way of telling
which character fish considers to be the separator.

Fixes #11508

(cherry picked from commit 320ebb6859)
2025-06-21 18:58:17 +02:00
Peter Ammon
f3ebc68d5d Correct statvfs call to statfs
This was missed in the Rust port - C++ had statfs for MNT_LOCAL and not statvfs.
The effect of this is that fish never thought its filesystem was local on macOS
or BSDs (Linux was OK). This caused history race tests to fail, and also could
in rare cases result in history items being dropped with multiple concurrent
sessions.

This fixes the history race tests under macOS and FreeBSD - we weren't locking
because we thought the history was a remote file.

Cherry-picked from ba00d721f4
2025-06-19 15:36:19 -07:00
Johannes Altmanninger
4be17bfefb fixup! Extract config path module. NFC
Fix cargo (non-cmake) build.
2025-06-13 12:17:10 +02:00
Johannes Altmanninger
6fd0025f38 Make LOCALEDIR relocatable as well
As explained in c3740b85be (config_paths: fix compiled-in locale dir,
2025-06-12), fish is "relocatable", i.e. "mv /usr/ /usr2/" will leave
"/usr2/bin/fish" fully functional.

There is one exception: for LOCALEDIR we always use the path determined at
compile time.
This seems wrong; let's use the same relocatable-logic as for other paths.

Inspired by bf65b9e3a7 (Change `gettext` paths to be relocatable (#11195),
2025-03-30).
2025-06-13 11:52:46 +02:00
Johannes Altmanninger
052fc18db9 Extract config path module. NFC
This is the "code movement" part of bf65b9e3 ("Change `gettext` paths to be
relocatable (#11195)").

While at it, fix some warnings.
2025-06-13 11:52:46 +02:00
Integral
63a08e53e5 Replace some PathBuf with Path avoid unnecessary heap allocation (#10929)
(cherry picked from commit b19a467ea6)
2025-06-11 11:38:53 +02:00
Erick Howard
62ac23453e Code cleanup in src/bin/fish.rs to make it more idiomatic (#10975)
Code cleanup in `src/bin/fish.rs` to make it more idiomatic

(cherry picked from commit 967c4b2272)
2025-06-11 11:31:05 +02:00
Johannes Altmanninger
c052beb4dd Fix build on Rust 1.70 2025-06-10 17:56:21 +02:00
Johannes Altmanninger
e0cabacdaa kitty keyboard protocol: fall back to base layout key
On terminals that do not implement the kitty keyboard protocol "ctrl-ц" on
a Russian keyboard layout generally sends the same byte as "ctrl-w". This
is because historically there was no standard way to encode "ctrl-ц",
and the "ц" letter happens to be in the same position as "w" on the PC-101
keyboard layout.

Users have gotten used to this, probably because many of them are switching
between a Russian (or Greek etc.) and an English layout.

Vim/Emacs allow opting in to this behavior by setting the "input method"
(which probably means "keyboard layout").

Match key events that have the base layout key set against bindings for
that key.

Closes #11520

---

Alternatively, we could add the relevant preset bindings (for "ctrl-ц" etc.)
but
1. this will be wrong if there is a disagreement on the placement of "ц" between two layouts
2. there are a lot of them
3. it won't work for user bindings (for better or worse)

(cherry picked from commit 7a79728df3)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
59b9f57802 fish_key_reader: unopinionated description for bind notation variants
As explained in the parent commit, "alt-+" is usually preferred over
"alt-shift-=" but both have their moments. We communicate this via a comment
saying "# recommended notation". This is not always true and not super helpful,
especially as we add a third variant for #11520 (physical key), which is
the recommended one for users who switch between English and Cyrillic layouts.

Only explain what each variant does. Based on this the user may figure out
which one to use.

(cherry picked from commit 4cbd1b83f1)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
65fc2b539c Fix some invalid assertions parsing keys
For example the terminal sending « CSI 55296 ; 5 u » would crash fish.

(cherry picked from commit c7391d1026)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
3f1add9e21 Sanitize some inputs in CSI parser
This was copied from C++ code but we have overflow checks, which
forces us to actually handle errors.

While at it, add some basic error logging.

Fixes #11092

(cherry picked from commit 4c28a7771e)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
68d2cafa6e input: remove unnecessary check in bracketed paste code path
When "self.paste_is_buffering()" is true, "parse_escape_sequence()" explicitly
returns "None" instead of "Some(Escape)".  This is irrelevant because this
return value is never read, as long as "self.paste_is_buffering()" remains
true until "parse_escape_sequence()" returns, because the caller will return
early in that case. Paste buffering only ends if we actually read a complete
escape sequence (for ending bracketed paste).

Remove this extra branch.

(cherry picked from commit e5fdd77b09)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
b9d9e7edc6 Match bindings with explicit shift first
The new key notation canonicalizes aggressively, e.g.  these two bindings
clash:

	bind ctrl-shift-a something
	bind shift-ctrl-a something else

This means that key events generally match at most one active binding that
uses the new syntax.

The exception -- two coexisting new-syntax binds that match the same key
event -- was added by commit 50a6e486a5 (Allow explicit shift modifier for
non-ASCII letters, fix capslock behavior, 2025-03-30):

	bind ctrl-A 'echo A'
	bind ctrl-shift-a 'echo shift-a'

The precedence was determined by definition order.
This doesn't seem very useful.

A following patch wants to resolve #11520 by matching "ctrl-ц" events against
"ctrl-w" bindings. It would be surprising if a "ctrl-w" binding shadowed a
"ctrl-ц" one based on something as subtle as definition order.  Additionally,
definition order semantics (which is an unintended cause of the implementation)
is not really obvious.  Reverse definition order would make more sense.

Remove the ambiguity by always giving precedence to bindings that use
explicit shift.

Unrelated to this, as established in 50a6e486a5, explicit shift is still
recommended for bicameral letters but not typically for others -- e.g. alt-+
is typically preferred over alt-shift-= because the former also works on a
German keyboard.

See #11520

(cherry picked from commit 08c8afcb12)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
6b17ec7dae Allow explicit shift modifier for non-ASCII letters, fix capslock behavior
We canonicalize "ctrl-shift-i" to "ctrl-I".
Both when deciphering this notation (as given to builtin bind),
and when receiving it as a key event ("\e[105;73;6u")

This has problems:

A. Our bind notation canonicalization only works for 26 English letters.
   For example, "ctrl-shift-ä" is not supported -- only "ctrl-Ä" is.
   We could try to fix that but this depends on the keyboard layout.
   For example "bind alt-shift-=" and "bind alt-+" are equivalent on a "us"
   layout but not on a "de" layout.
B. While capslock is on, the key event won't include a shifted key ("73" here).
   This is due a quirk in the kitty keyboard protocol[^1].  This means that
   fish_key_reader's canonicalization doesn't work (unless we call toupper()
   ourselves).

I think we want to support both notations.

It's recommended to match all of these (in this order) when pressing
"ctrl-shift-i".

	1. bind ctrl-shift-i do-something
	2. bind ctrl-shift-I do-something
	3. bind ctrl-I do-something
	4. bind ctrl-i do-something

Support 1 and 3 for now, allowing both bindings to coexist. No priorities
for now. This solves problem A, and -- if we take care to use the explicit
shift notation -- problem B.

For keys that are not affected by capslock, problem B does not apply.  In this
case, recommend the shifted notation ("alt-+" instead of "alt-shift-=")
since that seems more intuitive.
Though if we prioritized "alt-shift-=" over "alt-+" as per the recommendation,
that's an argument against the shifted key.

Example output for some key events:

	$ fish_key_reader -cV
	# decoded from: \e\[61:43\;4u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'
	# decoded from: \e\[61:43\;68u
	bind alt-+ 'do something' # recommended notation
	bind alt-shift-= 'do something'

	# decoded from: \e\[105:73\;6u
	bind ctrl-I 'do something'
	bind ctrl-shift-i 'do something' # recommended notation
	# decoded from: \e\[105\;70u
	bind ctrl-shift-i 'do something'

Due to the capslock quirk, the last one has only one matching representation
since there is no shifted key.  We could decide to match ctrl-shift-i events
(that don't have a shifted key) to ctrl-I bindings (for ASCII letters), as
before this patch. But that case is very rare, it should only happen when
capslock is on, so it's probably not even a breaking change.

The other way round is supported -- we do match ctrl-I events (typically
with shifted key) to ctrl-shift-i bindings (but only for ASCII letters).
This is mainly for backwards compatibility.

Also note that, bindings without other modifiers currently need to use the
shifted key (like "Ä", not "shift-ä"), since we still get a legacy encoding,
until we request "Report all keys as escape codes".

[^1]: <https://github.com/kovidgoyal/kitty/issues/8493>

(cherry picked from commit 50a6e486a5)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
08d796890a Stop accepting "bind shift-A"
This notation doesn't make sense, use either A or shift-a.  We accept it
for ASCII letters only -- things like "bind shift-!" or "bind shift-Ä"
do not work as of today, we don't tolerate extra shift modifiers yet.
So let's remove it for consistency.

Note that the next commit will allow the shift-A notation again, but it will
not match shift-a events.

(cherry picked from commit 7f25d865a9)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
4f98ef36f6 Extract KeyEvent type
The be used in the grandchild commit.

(cherry picked from commit 855a1f702e)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
a09c78491f Extract function for creating key event with modifiers
(cherry picked from commit fabbbba037)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
02932d6b8c Extract constant for the number of function keys
Switch to fish_wcstoul because we want the constant to be unsigned.
It's u32 because most callers of function_key() want that.

(cherry picked from commit e9d1cdfe87)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
7cca98bda2 Fix regression decoding function keys
Commit 109ef88831 (Add menu and printscreen keys, 2025-01-01)
accidentally broke an assumption by inverting f1..f12.  Fix that.

Fixes #11098

(cherry picked from commit d2b2c5286a)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
b77fc28692 Add menu and printscreen keys
These aren't typically used in the terminal but they are present on
many keyboards.

Also reorganize the named key constants a bit.  Between F500 and
ENCODE_DIRECT_BASE (F600) we have space for 256 named keys.

(cherry picked from commit 109ef88831)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
3475531ef7 Also ignore invalid recursive escape sequences
We parse "\e\e[x" as alt-modified "Invalid" key.  Due to this extra
modifier, we accidentally add it to the input queue, instead of
dropping this invalid key.

We don't really want to try to extract some valid keys from this
invalid sequence, see also the parent commit.

This allows us to remove misplaced validation that was added by
e8e91c97a6 (fish_key_reader: ignore sentinel key, 2024-04-02) but
later obsoleted by 66c6e89f98 (Don't add collateral sentinel key to
input queue, 2024-04-03).

(cherry picked from commit 84f19a931d)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
8222ed891b Stop parsing invalid CSI/SS3 sequences as alt-[/alt-o
This situation can be triggered in practice inside a terminal like tmux
3.5 by running

	tmux new-session fish -C 'sleep 2' -d reader -o log-file

and typing "alt-escape x"

The log shows that we drop treat this as alt-[ and drop  the x on the floor.

	reader: Read char alt-\[ -- Key { modifiers: Modifiers { ctrl: false,
	alt: true, shift: false }, codepoint: '[' } -- [27, 91, 120]

This input ("\e[x") is ambiguous.

It looks like it could mean "alt-[,x".  However that conflicts with a
potential future CSI code, so it makes no sense to try to support this.

Returning "None" from parse_csi() causes this weird behavior of
returning "alt-[" and dropping the rest of the parsed sequence.
This is too easy; it has even crept into a bunch of places
where the input sequence is actually valid like "VT200 button released"
but where we definitely don't want to report any key.

Fix the default: report no key for all unknown sequences and
intentionally-suppressed sequences.  Treat it at "alt-[" only when
there is no input byte available, which is more or less unambiguous,
hence a strong enough signal that this is a actually "alt-[".

(cherry picked from commit 3201cb9f01)
2025-06-10 16:50:00 +02:00
Johannes Altmanninger
f787e6858c Fix tests/checks/autoload.fish
Apparently this test runs with "build/tests" as CWD when run with cmake.
2025-06-10 16:50:00 +02:00
Fabian Boehm
a014166795 completions/nmcli: Complete at runtime
This used to get all the interfaces and ssids when the completions
were loaded. That's obviously wrong, given that ssids especially can, you know, change

(cherry picked from commit 9116c61736)

cherry-picking since this easy to trigger
(seen again in https://github.com/fish-shell/fish-shell/pull/11549)
2025-06-06 11:52:17 +02:00
Johannes Altmanninger
f7e639504a completions/git: improve idempotency in case of double load
As mentioned in the previous few commits and in #11535, running
"set fish_complete_path ..."  and "complete -C 'git ...'"  may result in
"share/completions/git.fish" being loaded multiple times.

This is usually fine because fish internally erases all cached completions
whenever fish_complete_path changes.

Unfortunately there is at least global variable that grows each time git.fish
is sourced. This doesn't make a functional difference but it does slow
down completions.  Fix that by resetting the variable at load time.

(cherry picked from commit 4b5650ee4f)
2025-05-29 18:01:22 +02:00
Johannes Altmanninger
028b60cad6 Fix "set fish_complete_path" accidentally disabling autoloading
Commit 5918bca1eb (Make "complete -e" prevent completion autoloading,
2024-08-24) makes "complete -e foo" add a tombstone for "foo", meaning we
will never again load completions for "foo".

Due to an oversight, the same tombstone is added when we clear cached
completions after changing "fish_complete_path", preventing completions from
being loaded in that case.  Fix this by restoring the old behavior unless
the user actually used "complete -e".

(cherry picked from commit a7c04890c9)
2025-05-29 18:01:04 +02:00
Johannes Altmanninger
b11e22d905 Fix uvar file mtime force-update (Rust port regression)
When two fish processes rewrite the uvar file concurrent, they rely on the
uvar file's mtime (queried after taking a lock, if locking is supported) to
tell us whether their view of the uvar file is still up-to-date.  If it is,
they proceed to move it into place atomically via rename().

Since the observable mtime only updates on every OS clock tick, we call
futimens() manually to force-update that, to make sure that -- unless both
fish conincide on the same *nanosecond* -- other fish will notice that the
file changed.

Unfortunately, commit 77aeb6a2a8 (Port execution, 2023-10-08) accidentally
made us call futimens() only if clock_gettime() failed, instead of when
it succeeded. This means that we need to wait for the next clock tick to
observe a change in mtime.
Any resulting false negatives might have caused us to drop universal variable updates.

Reported in https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2098948362

See #10300

(cherry picked from commit 8617964d4d)
2025-05-23 08:50:17 +02:00
Johannes Altmanninger
33f8415785 Fixup history file EINTR loop to actually loop
Fixes d84e68dd4f (Retry history file flock() on EINTR, 2025-05-20).

(cherry picked from commit 3867163193)
2025-05-20 17:19:12 +02:00
Johannes Altmanninger
5ccd155177 Retry history file flock() on EINTR
When locking the uvar file, we retry whenever flock() fails with EINTR
(e.g. due to ctrl-c).

But not when locking the history file.  This seems wrong; all other libc
functions in the "history_file" code path do retry.

Fix that. In future we should extract a function.

Note that there are other inconsistencies; flock_uvar_file() does not
shy away from remote file systems and does not respect ABANDONED_LOCKING.
This means that empirically probably neither are necessary; let's make things
consistent in future.

See https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2095096200
Might help #10300

(cherry picked from commit 4d84e68dd4)
2025-05-20 15:32:56 +02:00
Johannes Altmanninger
0f8d3a5174 Revert "Temporarily enable history_file debug category by default"
Commit f906a949cf (Temporarily enable history_file debug category by default,
2024-10-09) enabled the "history_file" debug category by default to gather
more data.

Judging from
https://github.com/fish-shell/fish-shell/issues/10300#issuecomment-2876718382
the logs didn't help, or were at least not visible when logging to stderr
(due to reboot).

Let's disable "history_file" logs again to remove potential
noise if the file system is read-only, disk is full etc., see
https://github.com/fish-shell/fish-shell/pull/11492#discussion_r2094781120

See #10300

(cherry picked from commit 285a810814)
2025-05-20 15:31:57 +02:00
Johannes Altmanninger
c4a26cb2b1 builtin status: remove spurious newline from current-command (Rust port regression)
WHen "status current-command" is called outside a function it always returns
"fish". An extra newline crept in, fix that.

Fixes 77aeb6a2a8 (Port execution, 2023-10-08).
Fixes #11503

(cherry picked from commit e26b585ce5)
2025-05-20 12:33:01 +02:00
Johannes Altmanninger
7228cb15bf Include sys/statvfs.h for the definition of ST_LOCAL (Rust port regression)
See https://man.netbsd.org/statvfs.5.
According to https://github.com/NetBSD/src/blob/trunk/sys/sys/statvfs.h#L135,
NetBSD has "#define ST_LOCAL MNT_LOCAL".  So this commit likely makes no
difference on existing systems.

While at it
- comment include statements
- remove a code clone

See #11486

(cherry picked from commit d68f8bdd3b)
2025-05-16 08:21:56 +02:00
Alan Somers
d5b46d6535 Fix remote filesystem detection on FreeBSD
Need an extra include to get the definition of MNT_LOCAL

Fixes #11483

(cherry picked from commit 7f4998ad9b)
2025-05-16 08:21:25 +02:00
Johannes Altmanninger
d4b4d44f14 Fix Vi mode glitch when replacing at last character
Another regression from d51f669647 (Vi mode: avoid placing cursor beyond last
character, 2024-02-14) "Unfortunately Vi mode sometimes needs to temporarily
select past end". So do the replace_one mode bindings which were forgotten.

Fix this.

This surfaces a tricky problem: when we use something like

	bind '' self-insert some-command

When key event "x" matches this generic binding, we insert both "self-insert"
and "some-command" at the front of the queue, and do *not* consume "x",
since the binding is empty.

Since there is a command (that might call "exit"), we insert a check-exit
event too, after "self-insert some-command" but _before_ "x".

The check-exit event makes "self-insert" do nothing. I don't think there's a
good reason for this; self-insert can only be triggered by a key event that
maps to self-insert; so there must always be a real key available for it to
consume. A "commandline -f self-insert" is a nop. Skip check-exit here.

Fixes #11484

(cherry picked from commit 107e4d11de)
2025-05-13 00:31:22 +02:00
Johannes Altmanninger
b8cfd6d12b Fix typo causing wrong cursor position after Vi mode paste
Regressed in d51f669647 (Vi mode: avoid placing cursor beyond last character,
2024-02-14).

(cherry picked from commit 50500ec5b9)
2025-05-13 00:31:09 +02:00
Johannes Altmanninger
6fb22a4fd1 Fix regression causing crash indenting commandline with "$()"
Commit b00899179f (Don't indent multi-line quoted strings; do indent inside
(), 2024-04-28) changed how we compute indents for string tokens with command
substitutions:

	echo "begin
	not indented
	end $(
	begin
	    indented
	end)"(
	begin
	    indented
	end
	)

For the leading quoted part of the string, we compute indentation only for
the first character (the opening quote), see 4c43819d32 (Fix crash indenting
quoted suffix after command substitution, 2024-09-28).

The command substitutions, we do indent as usual.

To implement the above, we need to separate quoted from non-quoted
parts. This logic crashes when indent_string_part() is wrongly passed
is_double_quoted=true.

This is because, given the string "$()"$(), parse_util_locate_cmdsub calls
quote_end() at index 4 (the second quote). This is wrong because that function
should only be called at opening quotes; this is a closing quote. The opening
quote is virtual here. Hack around this.

Fixes #11444

(cherry picked from commit 48704dc612)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
35849c57dc Explicit type for "$()" hack in parse_util_locate_cmdsub
(cherry picked from commit 8abab0e2cc)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
27504658ce Remove code clone in parse_util_locate_cmdsub
(cherry picked from commit bd178c8ba8)
2025-05-12 21:41:10 +02:00
Johannes Altmanninger
db323348c7 Set transient command line in custom completions (Rust port regression)
Commit df3b0bd89f (Fix commandline state for custom completions with variable
overrides, 2022-01-26) made us push a transient command line for custom
completions based on a tautological null-pointer check ("var_assignments").

Commit 77aeb6a2a8 (Port execution, 2023-10-08) turned the null pointer into
a reference and replaced the check with "!ad.var_assignments.is_empty()".
This broke scenarios that relied on the transient commandline.  In particular
the attached test cases rely on the transient commandline implicitly placing
the cursor at the end, irrespective of the cursor in the actual commandline.

I'm not sure if there is an easy way to identify these scenarios.

Let's restore historical behavior by always pushing the transient command line.

Fixes #11423

(cherry picked from commit 97641c7bf6)
2025-05-12 21:39:42 +02:00
Johannes Altmanninger
edb1b5f333 Share alt-{b,f} with Vi mode, to work around Terminal.app/Ghostty more
Commit f4503af037 (Make alt-{b,f} move in directory history if commandline is
empty, 2025-01-06) had the intentional side effect of making alt-{left,right}
(move in directory history) work in Terminal.app and Ghostty without other,
less reliable workarounds.
That commit says "that [workaround] alone should not be the reason for
this change."; maybe this was wrong.

Extend the workaround to Vi mode.  The intention here is to provide
alt-{left,right} in Vi mode.  This also adds alt-{b,f} which is odd but
mostly harmless (?) because those don't do anything else in Vi mode.
It might be confusing when studying "bind" output but that one already has
almost 400 lines for Vi mode.

Closes #11479

(cherry picked from commit 3081d0157b)
2025-05-12 21:35:47 +02:00
Daniel Rainer
2d8d377ddc Make printf unicode-aware
Specifically, the width and precision format specifiers are interpreted as
referring to the width of the grapheme clusters rather than the byte count of
the string. Note that grapheme clusters can differ in width.

If a precision is specified for a string, meaning its "maximum number of
characters", we consider this to limit the width displayed.
If there is a grapheme cluster whose width is greater than 1,
it might not be possible to get precisely the desired width.
In such cases, this last grapheme cluster is excluded from the output.

Note that the definitions used here are not consistent with the `string length`
builtin at the moment, but this has already been the case.

(cherry picked from commit 09eae92888)
2025-05-12 21:33:40 +02:00
Peter Ammon
057dd930b4 Changelog fix for #11354 2025-05-08 18:42:57 -07:00
Cuichen Li
25b944e3e6 Revert "Work around $PATH issues under WSL (#10506)"
This reverts commit 3374692b91.
2025-05-08 18:41:02 -07:00
David Adam
f1456f9707 Release 4.0.2 2025-04-20 21:11:52 +08:00
David Adam
c88e6827b7 CHANGELOG: work on 4.0.2 2025-04-19 00:06:31 +08:00
Johannes Altmanninger
bc3e3ae029 builtin read: always handle out-of-range codepoints (Rust port regression)
As mentioned in
https://github.com/fish-shell/fish-shell/pull/9688#discussion_r1155089596,
commit b77d1d0e2b (Stop crashing on invalid Unicode input, 2024-02-27), Rust's
char type doesn't support arbitrary 32-bit values.  Out-of-range Unicode
codepoints would cause crashes.  That commit addressed this by converting
the encoded bytes (e.g. UTF-8) to special private-use-area characters that
fish knows about.  It didn't bother to update the code path in builtin read
that relies on mbrtowc as well.

Fix that. Move and rename parse_codepoint() and rename/reorder its input/output
parameters.

Fixes #11383

(cherry picked from commit d9ba27f58f)
2025-04-16 11:33:15 +02:00
Johannes Altmanninger
3191ac13e5 Reduce parse_codepoint responsibilities, fixing alt in single-byte locale?
This also changes the single-byte locale code path to treat keyboard input
like "\x1ba" as alt-a instead of "escape,a".  I can't off-hand reproduce
a problem with "LC_ALL=C fish_key_reader", I guess we always use a UTF-8
locale if available?

(cherry picked from commit b061178606)
2025-04-16 11:28:28 +02:00
Johannes Altmanninger
4f810809c8 Fix builtin test assigning wrong range to "! -d /" (Rust port regression)
Fixes #11387

(cherry picked from commit c740c656a8)
2025-04-16 11:25:35 +02:00
Johannes Altmanninger
d622949d26 Fix kill-selection crash when selection start is out-of-bounds
This part of the code could use some love; when we happen to clear the
selected text, we should end the selection.

But that's not how it works today. This is fine for Vi mode, because Vi
mode never deletes in visual mode.

Let's fix the crash for now.

Fixes #11367

(cherry picked from commit af3b49bf9c)
2025-04-11 19:31:09 +02:00
Fabian Boehm
d95b662542 docs: Fix string-match glob examples
`?` no longer is a wildcard.

See #11361

(cherry picked from commit eb4a0b2560)
2025-04-08 17:14:12 +02:00
Johannes Altmanninger
d88d3122c8 Fix crash when history pager is closed before search
With

	bind ctrl-r 'sleep 1' history-pager

typing ctrl-r,escape crashes fish in the history pager completion callback,
because the history pager has already been closed.

Prior to 55fd43d86c (Port reader, 2023-12-22), the completion callback
would not crash open a pager -- which causes weird races with the
user input.

Apparently this crash as been triggered by running "playwright",
and -- while that's running typing ctrl-r ligh escape.
Those key strokes were received while the kitty keyboard protocol
was active, possibly a race.

Fixes #11355

(cherry picked from commit c94e30293a)
2025-04-04 14:37:03 +02:00
Fabian Boehm
a7f717c59c CHANGELOG for 4.0.2 2025-04-02 17:06:55 +02:00
Fabian Boehm
ba49981f17 tests: Just check that the version starts with a digit
Our versions look like

4.0.0
4.0b1
4.0.1-535-abfef-dirty

But packagers may want to add more information here, and we don't
really care. Note that we no longer ever set the version to "unknown"
since 5abd0e46f5.

Supersedes #11173

(cherry picked from commit 411a396fa9)
2025-04-02 17:03:57 +02:00
Farhood Etaati
05ae55b172 Adds git subtree completion
Closes #11063

(cherry picked from commit 48306409ef)
2025-04-02 17:03:57 +02:00
Ilya Grigoriev
b5877ebe44 jj completions: use dynamic completions by default, also fix
This uses jj's dynamic completions when possible.

This avoids an annoying problem. After 04a4e5c4, jj's dynamic
completions (see the second paragraph of
<https://jj-vcs.github.io/jj/latest/install-and-setup/#command-line-completion>)
do not work very well in fish if the user puts `COMPLETE=fish jj |
source` in their `~/.config/fish/config.fish`. When the user types `jj
<TAB>`, they are instead overridden by fish's built-in non-dynamic
completions.

The difference is subtle. One problem I saw is that `jj new <TAB>` works
as expected (and shows revisions) while `jj new -A <TAB>` becomes broken
(and shows files).

If the user puts `COMPLETE=fish jj | source` in
`~/.config/fish/completions/jj.fish` there is no problem. However, users
might be confused if they run `COMPLETE=fish jj | source` or put it in
their config and it works in a broken fashion. I certainly was.

Meanwhile, I checked that if the user has `jj completion fish | source`
in their `config.fish`, executing `COMPLETE=fish jj
__this_command_does_not_exist | source` afterwards still works
correctly.

Let me know if there's a better approach to this problem.

(cherry picked from commit 932010cd04)
2025-04-02 17:03:57 +02:00
Clément Martinez
f9a03215b8 Add wlr-randr completions
(cherry picked from commit ea8e122fad)
2025-04-02 17:03:57 +02:00
memchr
ff0980c4c1 completions/systemd-analyze: add new options and subcommands
options:
- instance
- image
- image-policy
- tldr
- unit
- table
- no-legend
- detailed
- scale-svg
- malloc

subcommands:
- filesystems
- compare-versions
- inspect-elf
- fdstore
- has-tpm2
- pcrs
- srk
- architectures
- smbios11

fix a typo in timespan completion

Signed-off-by: memchr <memchr@proton.me>
(cherry picked from commit 3744c02a01)
2025-04-02 17:03:57 +02:00
memchr
1a58d3f08b completions/cryptsetup: complete device mapping names
The commands 'close', 'resize', and 'status' each take 'name' as their solo argument.

Signed-off-by: memchr <memchr@proton.me>
(cherry picked from commit 5012bcb976)
2025-04-02 17:03:57 +02:00
memchr
b71027f622 completions/git: add --filter option
supported subcommands:
- clone
- fetch
- submodule update
- rev-list

(cherry picked from commit 795d6b6c40)
2025-04-02 17:03:57 +02:00
Jonathan Palardy
84c03c6f26 completions/git: Added autostash option to git merge
(cherry picked from commit 269ed5ddf4)
2025-04-02 17:03:57 +02:00
memchr
bf455bc316 completions/btrfs: add new options and commands
Also add completion for balance filters

(cherry picked from commit 95b93c6bff)
2025-04-02 17:03:57 +02:00
Johannes Altmanninger
6af0378916 Don't insert text from keys like super-i
While at it, use declaration order for modifiers.

(cherry picked from commit 35ae0bf1f2)
2025-04-02 17:03:57 +02:00
Fabian Boehm
de154065fe fish_print_hg_root: Don't break if $PWD includes newlines
Fixes #11348

(cherry picked from commit 5e25cdaa6f)
2025-04-02 17:01:25 +02:00
Fabian Boehm
459e9b7847 completions/cargo: Speed up
This does two things:

- it stops completing cargo- tools because `cargo --list` already
includes them. This speeds up loading especially with a long $PATH
- it stops using `cargo search` for `cargo add` and install.
  this removes a network call, which may be unexpected and can take a
  long time

Fixes #11347

(cherry picked from commit 18371fbd4e)
2025-04-02 17:00:30 +02:00
Johannes Altmanninger
f127323c33 Prevent commandline modification inside abbreviation callbacks
Consider command line modifications triggered from fish script via abbreviation
expansion:

	function my-abbr-func
	    commandline -r ""
	    echo expanded
	end
	abbr -a foo --function my-abbr-func

Prior to commit 8386088b3d (Update commandline state changes eagerly as well,
2024-04-11), we'd silently ignore the command line modification.
This is because the abbreviation machinery runs something similar to

	if my-abbr-func
	    commandline -rt expanded
	end

except without running "apply_commandline_state_changes()" after
"my-abbr-func", so the «commandline -r ""» update is lost.

Commit 8386088b3d applies the commandline change immediately in the abbrevation
function callback, invalidating abbrevation-expansion state.

The abbreviation design does not tell us what should happen here.  Let's ignore
commandline modifications for now. This mostly matches historical behavior.

Unlike historical behavior we also ignore modifications if the callback fails:

	function my-abbr-func
	    commandline -r ""
	    false
	end

Remove the resulting dead code in editable_line.

See #11324

(cherry picked from commit 11c7310f17)
2025-03-28 13:05:22 +01:00
Fabian Boehm
3fc245d829 docs: Readd bind -k to the docs
Fixes #11329

(cherry picked from commit d88f5ddbaf)
2025-03-28 12:59:44 +01:00
Johannes Altmanninger
542793a534 completions/git: fix arg completion for third-party git commands, again
Commit 50e595503e (completions/git: fix completions for third-party git
commands, 2025-03-03) wasn't quite right, as we can see in the linked
reproduction:

	$ fish_trace=1 complete -C 'git machete add --onto '
	----> complete -C git-machete\ add\n--onto\

The recursive completion invocation contains a spurious newline, which means
that "--onto" is the command name.  The newline is produced by "string escape
-- add --onto" inside a command substitution.

Fix this by interpreting newlines as list separators, and then joining
by spaces.

Fixes #11319

(cherry picked from commit 360cfdb7ae)
2025-03-25 11:16:38 +01:00
Johannes Altmanninger
18c231de29 Fix concurrent setlocale() in string escape tests
In our C++ implementation, these tests were run serially.  As pointed out in
https://github.com/fish-shell/fish-shell/issues/11254#issuecomment-2735623229
we run them in parallel now, which means that one test could be changing
the global locale used by another.

In theory this could be fine because all tests are setting setting the
global locale to the same thing but the existence of a lock suggests that
setlocale() is not guaranteed to be atomic, so it's possible that another
thread uses a temporarily-invalid locale.

Fixes #11254

(cherry picked from commit 1d78c8bd42)
2025-03-19 09:46:12 +01:00
Johannes Altmanninger
8e78857836 Fix Vi mode delete key bindings while numlock is active
Commit 8bf8b10f68 (Extended & human-friendly keys, 2024-03-30)
add bindings that obsolete the  terminfo-based `bind -k` invocations.

The `bind -k` variants were still left around[^*]. Unfortunately it forgot to
add the new syntax for some special keys in Vi mode.  This leads to issues if
a terminal that supports the kitty keyboard protocol sends an encoding that
differs from the traditional one.  As far as I can tell, this happens when
capslock or numlock is active.  Let's add the new key names and consistently
mark `bind -k` invocations as deprecated.

Fixes #11303

[^*]: Support for `bind -k` will probably be removed in a future release -
it leads to issues like https://github.com/fish-shell/fish-shell/issues/11278
where it's better to fail early.

(cherry picked from commit 733f704267)
2025-03-19 09:27:29 +01:00
Fabian Boehm
c7efbf590e function: Also error for read-only var in positional arg
We have this hack where any positional arguments are taken as argument
names if "--argument-names" is given, and that didn't check for
read-only variables.

Fixes #11295

(cherry picked from commit d203ee4d53)
2025-03-17 19:55:25 +01:00
Fabian Boehm
5771085280 CHANGELOG 2025-03-16 19:15:28 +01:00
Fabian Boehm
76d2419228 Downgrade $TERM warnings to a term-support flog
The chances that xterm-256color breaks anything are miniscule.

In the features we use, there are basically no differences,
especially when you consider that we decode keys independently.

E.g. tmux-256color has differences, but they are either just taste
questions (xterm's clear_screen will also clear scrollback),
or they're just... not actually different?

Terminfo will claim that it uses a different cursor_up and
exit_attribute_mode, but it also understands the xterm ones,
and it sends a different key_home,
but we decode that even with TERM=xterm-256color.

In some cases, terminfo is also just outright *wrong* and will claim
something does not support italics when it does.

So, since the differences are very likely to simply not matter,
throwing a warning is more confusing than it is helpful.

(cherry picked from commit 642ec399ca)
2025-03-16 18:50:46 +01:00
Johannes Altmanninger
ffbf957fa3 Quote only unique completions, use backslashes for ambiguous ones
Commit 29dc307111 (Insert some completions with quotes instead of backslashes,
2024-04-13) breaks some workflows. Given

	touch '[test] file1'
	touch '[test] file2'
	ls tes<Tab>

we insert completions quoted, which is inconvenient when using globs.

This implicit quoting feature is somewhat minor. But quotes look nicer,
so let's try to keep them.  Either way, users can ask for it by starting a
token with «"».

Use quoting only when we insert unique completions.

Closes #11271

(cherry picked from commit 9f79fe17fc)
2025-03-16 12:12:03 +01:00
Fabian Boehm
ae3532e9ec screen: Fix crash if prompt contains backspace
fish_wcwidth_visible can return -1, so usize::try_from fails.

Fixes #11280

(cherry picked from commit c03de2086a)
2025-03-14 20:19:49 +01:00
Fabian Boehm
5cd2ef903a key: Add super modifier
Fixes #11217

(cherry picked from commit 9f5e1736a8)
2025-03-14 20:19:49 +01:00
David Adam
67b6afffd4 Release 4.0.1 2025-03-13 11:16:55 +08:00
David Adam
6df88e1a9f CHANGELOG: work on 4.0.1 2025-03-13 10:59:58 +08:00
Johannes Altmanninger
61884bda36 Fix GitHub Actions build now that images come with ninja
Looks like the github actions image now has ninja installed.
This causes a failure; we effectively do

	$ (
		mkdir build && cd build
		cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
	  )
	$ make VERBOSE=1
	[...]
	cd build; cmake .. -G "Ninja" \
		-DCMAKE_INSTALL_PREFIX="/usr/local" -DCMAKE_EXPORT_COMPILE_COMMANDS=1
	Re-run cmake no build system arguments
	CMake Error: Error: generator : Ninja
	Does not match the generator used previously: Unix Makefiles
	Either remove the CMakeCache.txt file and CMakeFiles directory or choose a different binary directory.

"make" fails because it runs from top-level, with GNUMakefile's logic to
use -GNinja if available.  This is at odds with the direct cmake invocation,
which defaults to -G'Unix Makefiles'.

We shouldn't mix direct cmake invocation and the top-level Makefiles, so
run make from the build directory instead.

While at it, update some test invocations missed in 8d6fdfd9de
(Remove cmake "test" target, 2025-02-02).  This should
help avoid missing test failure output in CI, see
https://github.com/fish-shell/fish-shell/issues/11116#issuecomment-2629406479

(cherry picked from commit b0be53ed6a)
2025-03-13 10:36:28 +08:00
David Adam
66584dadcc CHANGELOG: work on 4.0.1 2025-03-12 23:28:29 +08:00
David Adam
5944518e6e docs/fish_title: add example on disabling title changing
Work on #11241.

(cherry picked from commit 3c8e058b75)
2025-03-12 14:39:33 +08:00
Johannes Altmanninger
19502ff9e7 Add hack to fix off-by-one error in Vi-mode cancel-commandline
The new cursor-end-mode "inclusive" (which is active in Vi mode) is causing
many issues.

One of them is because cancel-commandline wants to move to the end of the
command line before printing "^C".  Since "inclusive" cursor mode prevents
the cursor from moving past the last character, that one will be overwritten
with a "^".  Hack around this.

Closes #11261

(cherry picked from commit b08ff33291)
2025-03-11 20:24:04 +01:00
Johannes Altmanninger
e37e1b8f78 Fix regression causing glitches when prompt has control character
Since commit 0627c9d9af (Render control characters as Unicode Control Pictures,
2020-08-29), we render control character in the commandline as "␇" etc.
They can be inserted via either history search, or bindings such as

	bind ctrl-g "commandline -i \a"

That commit incorrectly assumes that the prompt is rendered the same way as
the command line (which goes through "ScreenData" etc).
This is wrong -- prompt text is written to stdout as-is, and a prompt that
outputs \t (tab) or \a (BEL) is valid.  The wrong assumption means that we
overestimate the width of prompts containing control characters.

(For some reason, after switching from Vi insert to Vi normal mode, we seem
to get the width right which means the command line jumps around)

Let's revert to the old width computation for any prompt text.

Closes #11252

(cherry picked from commit 4d81cf8af4)
2025-03-11 00:03:34 +01:00
Johannes Altmanninger
5d31be1c3e Fix regression causing crash on empty paste in Vi-mode
Fixes d51f669647 (Vi mode: avoid placing cursor beyond last character,
2024-02-14).

Closes #11256

(cherry picked from commit 2b4f150883)
2025-03-10 22:38:38 +01:00
metamuffin
7a959723ef Print newline on path warnings to stderr instead of stdout (Rust port regression)
(cherry picked from commit 4227f534b4)
2025-03-09 14:13:44 +01:00
Johannes Altmanninger
ad7631093d Remove assertion about history items
For unknown reasons this assertion fails.  This means that 1b9b893169 (After
reading corrupted history entry, keep reading older entries, 2024-10-06)
is not fully working.  Go back to historical behavior for now.

Closes #11236

(cherry picked from commit 4f80e5cb54)
2025-03-08 13:14:44 +01:00
Johannes Altmanninger
bd8d268255 Extend midnight commander workaround for when numlock/capslock is active
Midnight Commander 4.8.33 knows how to read the CSI u encoding of ctrl-o
(which is the only key it reads while the shell is in control).  But it fails
to when numlock or capslock is active.  Let's disable the kitty keyboard
protocol again until mc indicates that this is fixed.

Closes #10640

The other issue talked about in that issue is an unrelated mc issue, see
https://github.com/MidnightCommander/mc/issues/4597#issuecomment-2705900024
2025-03-07 12:14:56 +01:00
Peter Ammon
83f29ed09c Drag FindRust.cmake back into the land of the living
rustup has changed its output for 'rustup toolchain list --verbose`.
Teach FindRust.cmake about it, so that it may shamble on.

Cherry-picked from b38551dde9
2025-03-06 10:05:54 -08:00
Fabian Boehm
aca6836103 CHANGELOG add links 2025-03-06 11:37:19 +01:00
Peter Ammon
c9f1979b05 Revert "On undo after execute, restore the cursor position"
This reverts commit 815bc054e7.

This is too ambitious for a patch release, given that it affects how every
typed-in command runs.
2025-03-05 15:54:20 -08:00
Peter Ammon
4a35c48ce5 Changelog fix for 11221 2025-03-05 14:11:17 -08:00
Gabriel de Perthuis
f336cf5624 Fix dirent->d_name usage
Closes https://github.com/fish-shell/fish-shell/issues/11221

(cherry picked from commit a0dada5618)
2025-03-05 22:35:01 +01:00
Johannes Altmanninger
1504731d53 Backout new assertion to support old Rust
error[E0015]: cannot call non-const fn `zeroed::<libc::statfs>` in constants
	   --> src/path.rs:712:35
	    |
	712 |             let f_type = unsafe { mem::zeroed::<libc::statfs>() }.f_type;
	    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	    |
	    = note: calls in constants are limited to constant functions, tuple structs and tuple variants

	error: `std::mem::size_of_val` is not yet stable as a const fn
	   --> src/path.rs:713:13
	    |
	713 |             mem::size_of_val(&f_type) <= mem::size_of::<usize>()
	    |             ^^^^^^^^^^^^^^^^^^^^^^^^^

(cherry picked from commit 54f9778003)
2025-03-05 13:02:53 +01:00
Johannes Altmanninger
9dce68fab4 Fix crash on negative stat f_type (Rust-port regression)
Fixes #11219

(cherry picked from commit e5852a6100)
2025-03-05 12:34:59 +01:00
Johannes Altmanninger
815bc054e7 On undo after execute, restore the cursor position
Ever since 149594f974 (Initial revision, 2005-09-20), we move the
cursor to the end of the commandline just before executing it.

This is so we can move the cursor to the line below the command line,
so moving the cursor is relevant if one presses enter on say, the
first line of a multi-line commandline.

As mentioned in #10838 and others, it can be useful to restore the
cursor position when recalling commandline from history. Make undo
restore the position where enter was pressed, instead of implicitly
moving the cursor to the end. This allows to quickly correct small
mistakes in large commandlines that failed recently.

This requires a new way of moving the cursor below the command line.
Test changes include unrelated cleanup of history.py.

(cherry picked from commit 610338cc70)
(cherry picked from commit 0e512f8033)
2025-03-04 10:00:33 +01:00
Johannes Altmanninger
b8af4b20c2 Work around torn byte sequences in qemu kbd input with 1ms timeout
As reported on gitter, fish running inside a qemu console randomly fails to
recognize multi-byte sequences like "\e[D" (right); it sometimes recognizes
the first two bytes as "alt-[" and the last byte as the "D" key.

This because 8bf8b10f68 (Extended & human-friendly keys, 2024-03-30) changed
our approach to reading multi-byte key sequences.  Previously, we'd wait
forever (or rather fish_sequence_key_delay_ms) for the "D" byte.

As of  8bf8b10f68, we assume the entire sequence is already present in the
input buffer; and stop parsing the sequence if stdin is not readable.

It would be more technically correct to implement the VT state machine but
then we'd probably want to to figure out a timeout or a reset key, in case
of transport or terminal issues.

Returning early is also what we have historically done for multi-byte code
points.  Also, other terminal programs have been using it for many years
without problems.

I don't know why this happens in qemu but it seems we can work around by
setting a 1ms timeout.  This timeout should be small enough two keys "escape"
and "[" typed by a human will still be seen separate.

Refs:
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$Cfi9wL8FGLAI6_VAQWG2mG_VxsADUPvdPB46P41Jdbs
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$O_-LZ1W7Dk6L_4Rj0MyCry6GtO2JQlEas8fH9PrSYT8

(cherry picked from commit e1be842167)
2025-03-04 10:00:33 +01:00
Johannes Altmanninger
c06830ccf2 Orphan background tasks to work around terminals being sensitive to unreaped processes
When a command like "long-running-command &" exits, the resulting SIGCHLD
is queued in the topic monitor. We do not process this signal immediately
but only after e.g. the next command has finished. Only then do we reap the
child process.

Some terminals, such as Terminal.app, refuse to close when there are unreaped
processes associated with the terminal -- as in, having the same session ID,
see setsid(3).

In future, we might want to reap proactively.

For now, apply an isolated workaround: instead of taking care of a child
process, double-fork to create an orphaned process. Since the orphan will
be reaped by PID 1, we can eventually close Terminal.app without it asking
for confirmation.

	/bin/sh -c '( "$@" ) >/dev/null 2>&1 &' -- cmd arg1 arg2

This fix confines the problem to the period during which a background process
is running. To complete the fix, we would need to call setsid to detach the
background process from a controlling terminal. That seems to be desirable
however macOS does provide a setsid utility.

	setsid cmd arg1 arg2 >/dev/null 2>&1

Fixes #11181

(cherry picked from commit e015956de7)
2025-03-04 09:18:18 +01:00
Fabian Boehm
f96b9c53ce CHANGELOG for 4.0.1 2025-03-03 21:27:38 +01:00
Johannes Altmanninger
12527d1522 Add back legacy bindings to address modifyOtherKeys regressions in iTerm2<3.5.12
As of 303af07, iTerm2 3.5.11 on two different machines has two different
behaviors. For unknown reasons, when pressing alt-right fish_key_reader
shows "\e\[1\;9C" on one machine and "\e\[1\;3C" on another.

Feels like iTerm2 interprets modifyOtherKeys differently, depending on
configuration.

We don't want to risk asking for the kitty
keyboard protocol until iTerm2 3.5.12 (see
https://github.com/fish-shell/fish-shell/issues/11004#issuecomment-2571494782).

So let's work around around this weirdness by adding back the legacy
bindings removed in c0bcd817ba (Remove obsolete bindings, 2024-04-28) and
plan to remove them in a few years.

Note that fish_key_reader still reports this as "left", which already has
a different binding, but it looks like literal matches of legacy sequences
have precedence.

Fixes the problem described in
https://github.com/fish-shell/fish-shell/issues/11192#issuecomment-2692247060

Closes #11192

(cherry picked from commit 44d5abdc05)
2025-03-03 14:44:49 +01:00
Johannes Altmanninger
46422b6a16 completions/git: fix completions for third-party git commands
Before 798527d79a (completions: fix double evaluation of tokenized commandline, 2024-01-06)
git-foo completions did something like

	set -l subcommand_args (commandline -opc)
	complete -C "git-foo $subcommand_args "

As mentioned in 368017905e (builtin commandline: -x for expanded tokens,
supplanting -o, 2024-01-06), the "-o" option is bad
because it produces a weird intermediate, half-expanded state.

The immediate goal of 798527d79a was to make sure we do not do any
more expansion on top of this.  To that end, it changed the above to
"\$subcommand_args".  The meaning is more or less the same[^*] but crucially,
the recursive completion invocation does not see through the variable,
which breaks some completions.

Fix this with the same approach as in 6b5ad163d3 (Fix double expansion of
tokenized command line, 2025-01-19).

[^*]: It wasn't semantically correct before or after -- this was later
corrected by 29f35d6cdf (completion: adopt commandline -x replacing deprecated
-o, 2024-01-22)).

Closes #11205

(cherry picked from commit 50e595503e)
2025-03-03 14:44:49 +01:00
Johannes Altmanninger
97f0809b62 Add the commandline to the OSC 133 command start
Given

	$ cat ~/.config/kitty/kitty.conf
	notify_on_cmd_finish unfocused 0.1 command notify-send "job finished with status: %s" %c

kitty will send a notification whenever a long-running (>.1s) foreground
command finishes while kitty is not focused.

The %c placeholder will be replaced by the commandline.

This is passed via the OSC 133 command start marker, kitty's fish shell
integration.

That integration has been disabled for fish 4.0.0 because it's no longer
necessary since fish already prints OSC 133. But we missed the parameter for
the command string. Fix it.  (It's debatable whether the shell or the terminal
should provide this feature but I think we should fix this regression?)

Closes #11203

See https://github.com/kovidgoyal/kitty/issues/8385#issuecomment-2692659161

(cherry picked from commit 4378e73fc7)
2025-03-03 11:49:43 +01:00
Johannes Altmanninger
d30a2c5240 Try to reduce write(3) calls for OSC 133 prompt markers
Something like

	write!(f, "foo{}bar", ...)

seems to call f.write_str() thrice.

Splitting a single OSC 133 command into three calls to write(3) might result in
odd situations if one of them fails. Let's try to do it in one in most cases.

Add a new buffered output type that can be used with write!(). This is
somewhat redundant given that we have scoped_buffer().  While at it, remove
the confused error handling.  This doesn't fail unless we are OOM (and this
new type makes that more obvious).

(cherry picked from commit e5e932e970)
2025-03-03 11:48:48 +01:00
Johannes Altmanninger
7ee6d91ba0 Work around keyboard-layout related bugs in WezTerm's modifyOtherKeys
modifyOtherKeys with non-English or other non-default keyboard layouts will
cause wrong keys to be sent by WezTerm. Let's try to disable it for now.

Proposed upstream fix: https://github.com/wezterm/wezterm/pull/6748

Closes #11204
2025-03-03 10:13:37 +01:00
Johannes Altmanninger
a94c4e96ab Split /etc/{,man}path by colons too
I don't know how /etc/manpath ends up containing lines like
"path1:path2".  But path_helper splits them so we should do too.

4ea11424b8/path_helper/path_helper.c (L149)

Fixes #10684

(cherry picked from commit 95d61ea0fb)
2025-03-02 22:21:03 +01:00
Fabian Boehm
e767bb623f completions/wine: Complete files
wine can be used, and is usually used for things like `wine
setup.exe`,
so it should allow for regular file completion.

Fixes #11202

(cherry picked from commit 86e531b848)
2025-03-02 13:09:57 +01:00
Fabian Boehm
e925eccad2 sample_prompts/acidhub: Use the same branch logic as fish_git_prompt
This was broken for 4.0 because it used `{}` command grouping.

Instead just do one of the things the fish_git_prompt does.

(the default isn't usable here because it gets the sha from elsewhere)
2025-03-02 12:30:29 +01:00
Johannes Altmanninger
200eeffeee sample_prompts/acidhub: fix regression showing all branches
Fix the accidental "git branch" output leaking while making sure we support:
1. unborn branch, where HEAD does not exist (`git init`)
2. detached head (`git checkout --detach`)

Notably computing the branch name should be independent of computing
a diff against HEAD.
In scenario 1 there is a branch but no HEAD,
while in scenario 2 it's the other way round.

Hence we need a separate check to see if we're in a git repo.
"git rev-parse" seems to work. Not sure what's best pracitce.

Also remove the ahead/behind logic, it was broken because it misspelled
@{upstream}.

Fixes #11179

(cherry picked from commit 7b7e744353)
2025-03-02 11:48:17 +01:00
Jay
0d453039ac fix unknown command __fish_diskutil_volumes
Signed-off-by: Jay <BusyJay@users.noreply.github.com>
(cherry picked from commit c790b1051d)
2025-03-02 11:04:16 +01:00
Johannes Altmanninger
044afefc5c Fix regression causing cursor shape commands to leak into noninteractive shell
As reported in
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$CLuoHTdvcRj_8-HBBq0p-lmGWeix5khEtKEDxN2Ulfo

Running

	fish -C '
		fzf_key_bindings
		echo fish_vi_key_bindings >>~/.config/fish/config.fish
		fzf-history-widget
	'

and pressing "enter" will add escape sequences like "[2 q" (cursor shape)
to fish's command line.

This is because fzf-history-widget binds "enter" to a filter
that happens to be a fish script:

	set -lx FZF_DEFAULT_OPTS \
		... \
		"--bind='enter:become:string replace -a -- \n\t \n {2..} | string collect'" \
		'--with-shell='(status fish-path)\\ -c)

The above ~/.config/fish/config.fish (redundantly) runs "fish_vi_key_bindings"
even in *noninteractive* shells, then "fish_vi_cursor" will print cursor
sequences in its "fish_exit" handler.  The sequence is not printed to the
terminal but to fzf which doesn't parse CSI commands.

This is a regression introduced by a5dfa84f73 (fish_vi_cursor: skip if stdin
is not a tty, 2023-11-14). That commit wanted "fish -c read" to be able to
use Vi cursor.  This is a noninteractive shell, but inside "read" we are
"effectively interactive".  However "status is-interactive" does not tell
us that.

Let's use a more contained fix to make sure that we print escape sequences only
if either fish is interactive, or if we are evaluating an interactive read.

In general, "fish -c read" is prone to configuration errors, since we
recommend gating configuration (for bind etc) on "status is-interactive"
which will not run here.

(cherry picked from commit 495083249b)
2025-03-02 09:34:51 +01:00
Johannes Altmanninger
5cce0918a9 completions/status: break up long line, add buildinfo
(cherry picked from commit 5278686f55)
2025-03-02 09:34:51 +01:00
Johannes Altmanninger
3a673aff63 Apply fish_color_search_match foreground only if explicit
Historically, up-arrow search matches have been highlighted by

1. using the usual foreground (from syntax highlighting)
2. using the background from $fish_color_search_match

Commit 9af6a64fd2 (Fix bad contrast in search match highlighting, 2024-04-15)
broke this by also applying the foreground from $fish_color_search_match.

As reported on gitter, there is a meaningful scenario where the foreground
from syntax highlighting should not be overwritten:

	set fish_color_search_match --reverse

this copies the foreground from syntax highlighting to the background.

Since commit 9af6a64fd2 overwrites the foreground highlight, the resulting
background will be monocolored (black in my case) instead of whatever is
the syntax-colored foreground.

FWIW the reversed foreground will always be monocolored, because we have
always done 2.

Let's unbreak this scenario by using the foreground from
fish_color_search_match only if it's explicitly set (like we do since
9af6a64fd2).

This is hacky because an empty color is normally the same as "normal", but
it gets us closer to historical behavior. In future we should try to come
up with a better approach to color blending/transparency.

(cherry picked from commit b6269438e9)
2025-03-02 07:09:44 +01:00
Johannes Altmanninger
880aa479bf Work around Konsole not recognizing file:://$hostname/path as local
(This regressed in version 4 which sends OSC 7 to all terminals)

Konsole has a bug: it does not recognize file:://$hostname/path as directory.
When we send that via OSC 7, that breaks Konsole's "Open Folder With"
context menu entry.

OSC 7 producers are strongly encouraged to set a non-empty hostname, but
it's not clear if consumers are supposed to accept an empty hostname (see
https://gitlab.freedesktop.org/terminal-wg/specifications/-/issues/20).
I think it should be fine; implementations should treat it as local path.

Let's work around the Konsole bug by omitting the hostname for now. This
may not be fully correct when using a remote desktop tool to access a
system running Konsole but I guess that's unlikely and understandable.
We're using KONSOLE_VERSION, so it the workaround should not leak into SSH
sessions where a hostname component is important.

Closes #11198

Proposed upstream fix https://invent.kde.org/frameworks/kio/-/merge_requests/1820

(cherry picked from commit c926a87bdb)
2025-03-02 05:47:00 +01:00
Fabian Boehm
303af078f3 Actually disable CSI u in iTerm < 3.5.12
Fixes #11192
2025-02-28 21:15:44 +01:00
David Adam
1e069b0fff Cargo metadata: bump version number 2025-02-27 21:32:23 +08:00
David Adam
eb336889b7 Release 4.0.0 2025-02-27 16:00:33 +08:00
Laurențiu Nicola
1c57144f8b Fix create-base-directories.fish with SELinux
(cherry picked from commit f224ff1d28)
2025-02-27 11:37:17 +08:00
Fabian Boehm
6d30751f1c 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 414293521e)
2025-02-27 11:37:17 +08:00
David Adam
d33b967196 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.
2025-02-26 23:55:49 +08:00
David Adam
ea115f8595 CHANGELOG: fix syntax error 2025-02-26 22:56:15 +08:00
David Adam
def40ff34d CHANGELOG: work on 4.0.0 2025-02-26 21:41:58 +08:00
David Adam
bfa1e0dafb docs/source: document changes from #10774
(cherry picked from commit b82d0fcbcc)
2025-02-26 21:31:33 +08:00
David Adam
b52173c854 docs/bind: improve description of cancel binding
Closes #9644

(cherry picked from commit 8ec1a3e7b9)
2025-02-26 21:31:33 +08:00
Fabian Boehm
b5736c5535 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

480f059bce

which is contained in the 3.5.12-beta2 tag, so let's assume that fixes
it.

Fixes #11025

(not necessary in 4.1)
2025-02-20 17:11:08 +01:00
Johannes Altmanninger
e2a0b0e2b8 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 afbdb9f268)
2025-02-19 10:47:28 +01:00
Johannes Altmanninger
ebc460b9f9 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 72f2433120)
2025-02-19 10:47:21 +01:00
David Adam
df56f7155e docs/interactive: add ctrl-n Vi mode documentation
Noted missing in #11082.

(cherry picked from commit b2eebbe194)
2025-02-13 00:13:11 +08:00
Dmitry Gerasimov
40b63c35ab 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 dfa77e6c19)
2025-02-13 00:02:13 +08:00
Dmitry Gerasimov
b72dc096f9 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 9752b83e65)
2025-02-13 00:02:13 +08:00
Ilya Grigoriev
c571b65221 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 4208798585)
2025-02-13 00:01:07 +08:00
David Adam
fab273cf4d BSD/GNUmakefile: update to use new fish_run_tests target
(cherry picked from commit 15ca164773)
2025-02-12 12:09:00 +08:00
David Adam
0f346991e4 Revert "CI: Use renamed test target"
CI targets the GNUmakefile in the build root, which is probably worth keeping
working.

This reverts commit 3469fd25ec.
2025-02-12 12:09:00 +08:00
Fabian Boehm
9c2bfec150 CHANGELOG keyboard-protocols feature flag 2025-02-11 22:23:31 +01:00
Fabian Boehm
9c40f72643 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.
2025-02-11 22:22:08 +01:00
David Adam
774ad16404 CHANGELOG: work on 4.0.0 2025-02-11 23:28:07 +08:00
idealseal
6d7a7c2254 feat(comp): update to systemd 257
(cherry picked from commit 7accf4ffa1)
2025-02-11 22:53:09 +08:00
Max Jacobson
e1349b9c4a 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 d47a4899b4)
2025-02-11 22:51:24 +08:00
Ilya Grigoriev
0677c03689 completions/tmux: replace embedded tabs with \t
(cherry picked from commit 5dd6759d01)
2025-02-11 22:32:22 +08:00
David Adam
1b6e107131 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 2849cd11ae)
2025-02-11 22:29:03 +08:00
Kemel Zaidan
7ea368b6d3 adds completion for the default Elm cli tool
(cherry picked from commit df6bd36e82)
2025-02-11 22:29:03 +08:00
Roland Fredenhagen
00b2009851 Complete entries for bootctl
Uses `jq` to parse and doesn't add these extra completions if not available.

(cherry picked from commit d862e7bf26)
2025-02-11 22:29:03 +08:00
Fabian Boehm
47d3189614 abbr: Print optional set-cursor arg correctly
Allows the output to round-trip.

Fixes #11141

(cherry picked from commit b50c832a35)
2025-02-07 12:40:33 +01:00
Johannes Altmanninger
65ac71edcc 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 f4503af037.

Closes #11105
2025-02-06 19:15:03 +01:00
Fabian Boehm
a11b9e5af7 CHANGELOG: Fix some formatting 2025-02-05 22:13:17 +01:00
Fabian Boehm
db244e0492 reader: Only maintain cursor position in non-empty prefix search
Otherwise this would always move the cursor to the beginning.

Fixes #11133
2025-02-05 22:13:14 +01:00
Fabian Boehm
3469fd25ec 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
2025-02-05 19:22:26 +01:00
Fabian Boehm
378f452eaa 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 6af96a81a8.

Fixes #10926
See #11107
2025-02-05 19:06:37 +01:00
Fabian Boehm
04151d758b 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 8d6fdfd9de)
2025-02-03 13:39:22 +01:00
phanium
bf91da5979 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`
2025-02-02 16:21:12 -08:00
Fabian Boehm
2f2ea729a7 completions/csvlens: Fix missing option
(cherry picked from commit bba15c6d14)
2025-01-31 19:34:51 +01:00
Fabian Boehm
db48cd547b Reset read_limit back to default
Regression introduced in 6638c78b30

Reintroduces #9129

It's unclear why the tests didn't fail

(cherry picked from commit 6d8f1aeb27)
2025-01-31 16:31:55 +01:00
kerty
acadf00718 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).
2025-01-31 13:41:02 +01:00
Fabian Boehm
93ac5d0eb3 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 43e2d7b48c (Port pager.cpp)

(cherry picked from commit 6c4d658c15)
2025-01-30 16:27:31 +01:00
David Adam
5aec9e3b47 docs/fish: minor style/proofing edits
(cherry picked from commit be48d73599)
2025-01-29 22:47:06 +08:00
David Adam
d7fb0308a7 docs/language: update target release for feature flags from 3.8 to 4.0
see also 24abbb6de7

(cherry picked from commit 1cf71656ef)
2025-01-29 22:47:05 +08:00
Ilya Grigoriev
fa5de3ece8 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 064d867873)
2025-01-29 22:46:29 +08:00
Johannes Altmanninger
29e69bd113 Fix broken completions for "mount -ouid="
Cherry-picked from b46417c77b (Fix broken completions for "mount
-ouid=", 2024-11-21).
2025-01-29 10:33:20 +01:00
Johannes Altmanninger
4d6544591e 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)
2025-01-29 10:32:24 +01:00
David Adam
bfbee7a7ff CHANGELOG: work on 4.0.0 2025-01-28 23:32:38 +08:00
David Adam
3400844f9a completions/acpi: correct the -c option as cooling
Closes #11068.

(cherry picked from commit 2184aaf9b4)
2025-01-28 21:56:54 +08:00
Ilya Grigoriev
f1bb4e02fe 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 f241187c4a)
2025-01-28 21:42:24 +08:00
Ilya Grigoriev
9385a25c22 completions/tmux: complete commands inside tmux lscm
Make `tmux lscm <tab>` work.

(cherry picked from commit 77406ddd11)
2025-01-28 21:42:14 +08:00
Ilya Grigoriev
323bddcce6 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 183e20cc3a)
2025-01-28 21:42:06 +08:00
Ilya Grigoriev
d29d63d930 completions/tmux: complete all subcommands when tmux lscm works
For example, `tmux shell<tab>` now completes to `if-shell` and
`run-shell`, though no additional information is provided.

(cherry picked from commit 27e5ed7456)
2025-01-28 21:41:43 +08:00
Ilya Grigoriev
a62bae9e8f tmux completions: complete shell commands
(cherry picked from commit bcc69da569)
2025-01-28 21:41:32 +08:00
Johannes Altmanninger
28d4fc33d8 fixup missing function 2025-01-27 06:59:18 +01:00
Johannes Altmanninger
7dc046b959 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
2025-01-27 06:34:35 +01:00
Johannes Altmanninger
9882849fda Fix regression causing builtin commandline to report wrong relative cursor
Regressed in 55fd43d86c (Port reader, 2023-12-22).

Cherry-picked from c651a79c
2025-01-26 15:55:35 +01:00
Johannes Altmanninger
92582d5b1f Back out "Escape : and = in file completions"
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<tab>
	$ 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 b6c249be0c)
2025-01-23 09:03:07 +08:00
Johannes Altmanninger
8eb5e36aa6 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 0cfc95993a)
2025-01-23 09:03:07 +08:00
Fabian Boehm
fd3ed7cfa5 functions/__fish_cancel_commandline: Follow rename of bind function
See #10935
2025-01-22 17:44:28 +01:00
David Adam
4c9dfcc5d7 CHANGELOG: work on 4.0.0 2025-01-21 00:06:40 +08:00
Johannes Altmanninger
4024d82412 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 <g.kabakov@inbox.ru>
2025-01-19 19:08:38 +01:00
Fabian Boehm
1c11055241 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.
2025-01-17 10:02:32 +01:00
Fabian Boehm
28fb5b5207 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
2025-01-17 09:52:53 +01:00
Fabian Boehm
45439f07d7 Update tests and docs for 4.0 target 2025-01-16 13:38:26 +01:00
David Adam
452aa6c614 feature_flags: update target release for 3.8 flags to 4.0
(cherry picked from commit 24abbb6de7)
2025-01-15 22:12:22 +08:00
Daniel Fleischer
8c92ea1642 Add lazygit completions (#11019)
(cherry picked from commit 29c45100fa)
2025-01-15 21:08:12 +08:00
Fabian Boehm
d2bfb51611 Workaround Kitty spamming the log for ModifyOtherKeys
Fixes #11040
2025-01-14 20:10:33 +01:00
Fabian Boehm
806734cc56 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
2025-01-14 20:00:31 +01:00
Branch Vincent
8e141070b2 completions: add fish-lsp (#11017)
(cherry picked from commit 7970ca55af)
2025-01-14 23:48:48 +08:00
David Adam
b009c0d480 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 54fef433e9)
2025-01-12 21:21:50 +08:00
Klaus Hipp
b3aa79e9aa Fix completion typos
(cherry picked from commit 5c25d3c3b1)
2025-01-09 16:51:39 +01:00
phanium
fbf9ac8046 Fix missing of builtin token description
(cherry picked from commit ef7aa793c6)
2025-01-09 16:49:38 +01:00
Fabian Boehm
fb6d3c3669 type: Do not translate the type "builtin"
This is a functional string, it should not be translated.

And we do not translate the others.
2025-01-09 16:41:44 +01:00
César Sagaert
d6dccc3c88 DNF5 completion support (#11035)
* dnf5 completions

* address comments

(cherry picked from commit 00c7baf68c)
2025-01-09 16:36:23 +01:00
Klaus Hipp
f36a7262db Revert "Fix typo in npm completions: isntall -> install" (#11014)
* Revert "Fix typo in npm completions: isntall -> install"

This reverts commit f4b01bb638.

* Add comments about typos in `npm` completions

(cherry picked from commit 4def0ac616)
2025-01-08 08:53:33 +08:00
Fabian Boehm
8a5b1ccc17 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 4decacb933.

See #10994
2025-01-07 20:28:24 +01:00
Steve Walker
52a2bed38c fix python completion #10943
(cherry picked from commit b574a5e4f6)
2025-01-07 23:30:56 +08:00
Klaus Hipp
cbfbac2198 Fix completion typos for apt-build, htop and wget (#11016)
(cherry picked from commit ea4e4a4279)
2025-01-07 21:48:23 +08:00
Klaus Hipp
a9b7dd1a9b Fix typos in docs (#11015)
(cherry picked from commit 9b67b2ae07)
2025-01-07 21:32:23 +08:00
Johannes Altmanninger
4decacb933 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)
2025-01-06 11:20:10 +01:00
Johannes Altmanninger
620eed466b Retry writing some escape sequences on EINTR
Cherry-picked from bc26481558.
2025-01-06 11:20:10 +01:00
Lzu Tao
33fe575112 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 f9b79926f1)
2025-01-05 23:00:55 +08:00
David Adam
13f7e6d0a5 docs/interactive: update key bindings added for 4.0
(cherry picked from commit 6c3150aa05)
2025-01-05 22:28:45 +08:00
cornmander
44a8344da1 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 d842a6560e)
2025-01-05 15:25:23 +08:00
David Adam
92919effc5 CHANGELOG: work on 4.0.0 2025-01-04 21:53:32 +08:00
Lzu Tao
046cadb53a Add completion for gem-fetch
(cherry picked from commit 7eb254f2ba)
2025-01-04 21:26:26 +08:00
idealseal
a5f99afa47 feat(comp): Update completions for resolvectl
(cherry picked from commit 2e12a2b6c4)
2025-01-04 20:42:44 +08:00
idealseal
24397c71cd feat(comp): Update completion for md5sum
(cherry picked from commit a780e4da15)
2025-01-04 20:39:56 +08:00
Johannes Altmanninger
566ff38fee Mention lack of support for ctrl-backspace and alternatives
Closes #10936

(cherry picked from commit cde503b0a8)
2025-01-04 20:32:06 +08:00
Thayne McCombs
7ea2ab4ebb fix[completions]: Add set-timeout to bootctl
(cherry picked from commit 33dd823f45)
2025-01-04 20:18:12 +08:00
Johannes Altmanninger
e6e647092d 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 <taolzu@gmail.com>

(cherry picked from commit 69f0d960cf)
2025-01-04 20:17:32 +08:00
Fabian Boehm
5845a3f7ad __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 d5efef1cc5)
2025-01-03 19:35:14 +01:00
Alexei Mikhailov
ff8a879e80 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 9b26fff278)
2025-01-02 21:57:57 +08:00
Klaus Hipp
6749a44d0f Update code completions
(cherry picked from commit 2b46d97c68)
2025-01-02 14:12:00 +08:00
EmilyGraceSeville7cf
550a076fa3 feat(completion) support batsh command
(cherry picked from commit 1bda6043c8)
2025-01-02 09:16:26 +08:00
EmilyGraceSeville7cf
c28659a045 feat(completion): support folderify command
(cherry picked from commit d8d5913159)
2025-01-02 09:16:26 +08:00
Benjamin Kellermann
d2608588fc add completion for btrbk (#10752)
* add completion for btrbk

completions for btrbk https://github.com/digint/btrbk/

* change indent + spaces

(cherry picked from commit 2ac1523e54)
2025-01-02 09:16:26 +08:00
Ilya Grigoriev
dd333cdc82 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<tab> 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 b1064ac3a0)
2025-01-02 09:14:37 +08:00
Fabian Boehm
57a7920e15 CHANGELOG since 4.0b1 2024-12-31 14:35:55 +01:00
Grant Hutchins
2f99a82700 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.
2024-12-29 13:49:05 -08:00
Fabian Boehm
5f76fc3e41 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 6f9ca42a30)
2024-12-29 13:37:29 +01:00
Joan Bruguera Micó
c0a2b55efd 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
2024-12-28 12:14:14 -08:00
Fabian Boehm
f75912d205 Create release-with-debug cargo profile, hook it up with cmake
Fixes #10959

(cherry picked from commit 66b80041cc)
2024-12-28 16:04:18 +01:00
Kid
701853fdd3 docs: Distinguish documents in sidebar
(cherry picked from commit a579abb81b)
2024-12-28 08:42:59 +01:00
Dmitry Gerasimov
ea2c53ca85 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.
2024-12-26 12:02:22 -08:00
phanium
06105e9207 Fix alt-e cursor position restore on Vim <= 8 (#10946)
Cherry-picked from commit 94dfe1b053
2024-12-26 06:40:41 +01:00
David Adam
e858322749 Debian packaging: add some missing runtime dependencies
(cherry picked from commit eade6a5672)
2024-12-26 13:37:30 +08:00
David Adam
bd2ddda9a4 update CMake requirement
find_rust uses LIST(POP_BACK), which was added in 3.15.

(cherry picked from commit 044cea1bf3)
2024-12-26 13:37:30 +08:00
David Adam
6db110916b Debian packaging: reformat dependencies
(cherry picked from commit 74b1247461)
2024-12-26 13:37:30 +08:00
Fabian Boehm
d707a516d2 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 9b8793a2df)
2024-12-25 14:50:29 +01:00
Fabian Boehm
aed52049ab 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
2024-12-23 17:01:04 +01:00
Johannes Altmanninger
5fed900b94 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 c1b460525c
2024-12-23 14:43:37 +01:00
Johannes Altmanninger
70ba81e5b3 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 5de6f4bb3d
2024-12-23 14:43:33 +01:00
Johannes Altmanninger
f237fb7b9f 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.
2024-12-23 14:32:30 +01:00
Fabian Boehm
7069f3fe40 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
2024-12-22 18:13:29 +01:00
Johannes Altmanninger
1e7de063bd Fix regression of builtin read not exiting on ctrl-c
Commit 8bf8b10f68 (Extended & human-friendly keys, 2024-03-30) stopped
ctrl-c from exiting without a motivation. Unfortunately this was
only noticeable on terminals that speak the kitty keyboard protocol,
which is probably no one had noticed so far.

Closes #10928
2024-12-21 05:54:52 +01:00
David Adam
541f8b47bf Revert "Add completions for dust"
This reverts commit 27c7578760.

dust generates its own completions (which are shipped in the wrong spot
in the Debian packages, but which are also more up-to-date).

Closes #10922.
2024-12-19 19:49:01 +08:00
David Adam
6eec2db292 fish.spec: update dependencies for the terminfo database
RH/Fedora and openSUSE use different package names.

Closes #10920.
2024-12-19 14:48:01 +08:00
Johannes Altmanninger
039011bc81 Make full autosuggestions case-correcting again
Fixes ca21872d14 (Clean up the accept-autosuggestion code path a
little bit, 2024-11-14).
Fixes #10915
2024-12-18 19:02:27 +01:00
metamuffin
9abec243a4 Completions for mksquashfs (#10909) 2024-12-18 10:36:30 -06:00
Fabian Boehm
f89e26b06e installable: Reword $HOME error 2024-12-18 17:26:25 +01:00
David Adam
80d53b129f macOS codesigning: use stable Rust
The apple-codesign crate has a fairly aggressive MSRV policy, and the
compiler itself still targets 10.12 which is well below the minimum
version of macOS for aarch64. Just use stable.
2024-12-18 23:38:13 +08:00
Ilya Grigoriev
7162822486 rclone.fish: assume a recent version if the version cannot be parsed
The version of rclone is set during compilation and could be any crazy string depending on the packager, whether it's a dev build, etc. If it cannot be parsed, let's assume a recent version.

Follows up on cc8fa0f7
2024-12-18 15:31:51 +01:00
David Adam
7c2a379674 RPM/Debian packaging: add find dependency
Closes #10913
2024-12-18 11:04:41 +08:00
Klaus Hipp
25534bf657 Add tex-fmt completions 2024-12-18 02:21:57 +08:00
David Adam
687001f8b7 Merge branch 'Integration_4.0.0'
This merge throws away a commit from master which was a duplicate of one on
Integration_4.0.0, and just allows the history to remain mostly-linear.
2024-12-17 23:54:00 +08:00
David Adam
e6fea730e2 Update Cargo.lock with version number bump from Cargo.toml 2024-12-17 23:48:48 +08:00
Fabian Boehm
b56bb80a14 tests/version: Update for "-beta"
We used to call our beta versions "...b1", but cargo doesn't like
that.

So we need to adjust the regex here.
2024-12-17 16:44:34 +01:00
Fabian Boehm
5fc47f37a6 Update Cargo.lock
This includes the crate version, so any build would otherwise claim
it's "dirty"
2024-12-17 16:44:10 +01:00
David Adam
8557c3c48c Release 4.0b1 2024-12-17 22:51:11 +08:00
David Adam
c54dfa12c1 CHANGELOG: work on 4.0.0 2024-12-17 22:23:32 +08:00
Klaus Hipp
67fa71a94d Update zed completions (#10907)
Add uninstall option.
2024-12-16 19:42:57 -06:00
Johannes Altmanninger
0275c5e803 Swap variable overrides and time in not statement
This is allowed

	time a=b echo 123

but -- due to an oversight in 3de95038b0 (Make "time" a job prefix,
2019-12-21) -- this is not allowed:

	not time a=b echo 123

Instead, this one one works:

	not a=b time echo 123

which is weird because without the "not" this would run "/bin/time".

It seems wrong that "not" is not like the others. Swap the order
for consistency.

Note that unlike "not", "time" currently needs to come before variable
assignments, so "a=b time true" is disallowed. This matches zsh. POSIX
shells call "/bin/time" here. Since it's ambiguous, erroring out seems
fine. It's weird that we're inconsistent with not here but I guess
"command not" is not expected to have subtly different behavior.

Closes #10890
2024-12-16 06:33:47 +01:00
Johannes Altmanninger
8fd0399ed3 Remove runaway kw_builtin in not statement definition
This was added accidentally in 971d257e67 (Port AST to Rust,
2023-04-02).  It does not seem to be causing an observable effect
(although I didn't try hard).
2024-12-16 06:33:47 +01:00
Johannes Altmanninger
ac951427af Fix alt-l on multiline tokens
This would invoke test with extra arguments.
2024-12-16 06:33:47 +01:00
Fabian Boehm
95f4c9c07e One more FreeBSD-only-in-CI 2024-12-15 17:38:37 +01:00
Fabian Boehm
8add30e3bf pexpects: Disable exit on CI Darwin/FreeBSD 2024-12-15 17:33:12 +01:00
Fabian Boehm
cb3fbd3a5c pexpects: Disable 2 only on CI
As the comment says
2024-12-15 17:32:47 +01:00
Fabian Boehm
9b9663ea44 CHANGELOG: We need a C compiler even for the main binary
Not just libc.c, but also the rsconf tests.
2024-12-15 17:15:35 +01:00
David Adam
a23cd62ec7 RPM/Debian packaging: update dependencies to match reality 2024-12-15 23:53:55 +08:00
David Adam
489d6b9dd8 CHANGELOG: work on 4.0.0 2024-12-15 23:52:30 +08:00
Fabian Boehm
10ac98e2ea installable: Only panic without sphinx if FISH_BUILD_DOCS=1
It's pretty annoying that this panics without sphinx, because the
install itself would be *working*.

So instead we tell the user that they need to clean or set
$FISH_BUILD_DOCS if they want to try again.
2024-12-15 09:00:16 +01:00
Fabian Boehm
46ce01223b staticbuilds: Fix aarch64 cross-compile
We get "undefined reference to `__memmove_chk'" when compiling
pcre2 (via pcre2-sys) on newer Ubuntu.

That one is used with higher fortify_source levels, and Ubuntu 24.04
defaults to 3, while my arch system (where I cannot reproduce)
defaults to 2.
2024-12-14 13:39:20 +01:00
Fabian Boehm
50c737fa55 CHANGELOG 2024-12-14 12:14:55 +01:00
Fabian Boehm
a98997fab0 curses: Just use our hardcoded xterm-256color entry as the fallback
The values we would try are:

xterm-256color, xterm, ansi, dumb

This is a pretty useless list, because systems without
"xterm-256color" but with "ansi" basically don't exist,
and it is very likely that the actual terminal is more
xterm-compatible than it is ansi.

So instead we just use our xterm-256color definition, which has a high
likelihood of being basically correct.
2024-12-14 12:10:34 +01:00
Fabian Boehm
cc8fa0f780 completions/rclone: Make version check more lenient
This has been observed to be "rclone 1.68.2" instead of "rclone
v1.68.2", missing the "v".
2024-12-14 11:20:29 +01:00
Fabian Boehm
378e9b236a Silence time_t deprecation
This is not something that affects us or we can do anything about.
2024-12-14 09:34:52 +01:00
Johannes Altmanninger
0a145cff3c Fix clippy lints 2024-12-14 09:31:20 +01:00
Johannes Altmanninger
f9febba2b0 Fix replacing completions with a -foo prefix
Fixes #10904
2024-12-14 09:31:20 +01:00
Fabian Boehm
84d8655677 fmt! 2024-12-13 21:57:07 +01:00
Fabian Boehm
abc1a45ea1 Shorten error for broken $TERM 2024-12-13 21:46:17 +01:00
Fabian Boehm
be16eeef69 Make --install install without confirmation, and not exit 2024-12-13 19:19:26 +01:00
Fabian Boehm
6d28845c2b Automatically attempt to install
This is fairly subtle.

When installable, and we either can't find the version file or it is
outdated, we ask the user to confirm installation (just like `--install`).

We do that only if we are really truly interactive (with a tty!) to
avoid `fish -c` running into problems.
This check could be tightened even more, because currently:

```fish
fish -ic 'echo foo'
```

asks, while

```fish
fish -ic 'echo foo' < /dev/null
```

does not.

`fish -c` will still error out if it can't find the config, but it
will just run if it is out of date.
2024-12-13 19:19:26 +01:00
Fabian Boehm
99fa8aaaa7 Really hide install() from clippy 2024-12-11 17:21:34 +01:00
Fabian Boehm
fa298c41e0 Hide install() from clippy
Not checkable because it would require sphinx
2024-12-11 17:18:34 +01:00
Fabian Boehm
327aa964e9 Disable default features for cargo test
Unfortunately it does not appear like #[cfg(test)] works for build.rs?

Investigating a better solution, but this is a good idea anyway (or `make
test` would generate man pages via build.rs!)
2024-12-11 17:05:38 +01:00
Fabian Boehm
6c852655dd Disable man page building in clippy
This would otherwise break any clippy run if you didn't have sphinx installed.
2024-12-11 16:56:14 +01:00
Fabian Boehm
0e0d56d805 format 2024-12-11 16:51:25 +01:00
Fabian Boehm
2d2f18c159 installable builds: Fail when building man pages fails
This is unfortunately necessary, because otherwise it would not rerun
the build script just because you installed sphinx.

Because we use the man pages for --help output, they're pretty
necessary.

To override it, you can set $FISH_BUILD_DOCS=0, like

```fish
FISH_BUILD_DOCS=0 cargo install --path .
```
2024-12-11 16:49:49 +01:00
David Adam
c58313fb2b README: minor formatting update 2024-12-11 08:04:52 +08:00
David Adam
662607fb2a README: minor formatting update 2024-12-11 08:04:15 +08:00
David Adam
6ae887383c README: improve instructions on building from source
Closes #10894.
2024-12-11 08:04:00 +08:00
David Adam
1b33e4b9a6 CHANGELOG: work on 4.0.0 2024-12-11 08:03:26 +08:00
Fabian Boehm
0083192fcb Read git SHA ourselves if it is unavailable
`git describe` *may* fail e.g. for `sudo make install`,
so we just read the SHA ourselves.
2024-12-09 16:57:47 +01:00
Peter Ammon
5c8b6adc2c Fix infinite prompt loop if status message is printed in prompt
fish will print messages for some jobs when they exit abnormally, such as
with SIGABRT. If a job exits abnormally inside the prompt, then (prior to
this commit) fish would print the message and re-trigger the prompt, which
could result in an infinite loop. This has existed for a very long time.

Fix it by reaping jobs after running the prompt, and NOT triggering a
redraw based on that reaping. We still print the message but the prompt is
not executed.

Add a test.

Fixes #9796
2024-12-08 18:12:59 -08:00
Peter Ammon
c97b1a992c Remove some unused code from the tests 2024-12-08 13:57:10 -08:00
Fabian Boehm
56a1403350 Revert "Enable gettext without the _nl_msg_cat_cntr gnuism"
This built on my test system, might be version differences.

(it's also not enough to make it *work*, but a necessary step)

This reverts commit 6fded249cd.
2024-12-08 22:04:59 +01:00
Fabian Boehm
6fded249cd Enable gettext without the _nl_msg_cat_cntr gnuism
This should allow e.g. musl to be translated.
2024-12-08 21:53:20 +01:00
Johannes Altmanninger
421ce13be6 Fix replacing completions spuriously quoting ~
Commit 29dc30711 (Insert some completions with quotes instead of
backslashes, 2024-04-13) wrongly copmletes

	$ cat ~/space

to

	$ cat '~/path with spaces'

Today completions can be either replacing or appending.  We never quote
(but backslash-escape) appending completions (unless they "append"
to an empty token).  We always quote replacing completions. The
assumption in this part of the code is that replacing completions
can be quoted without changing meaning.

This assumption is wrong for tildes.  For the backslash-escaping code
path, we take care of this edge case via a special DONT_ESCAPE_TILDES
flag. However that flag does not take effect when using quotes for
escaping. Fix that.

Unfortunately, e97a4fab7 (Escape : and = in file completions,
2024-04-19) introduced a (hopefully temporary) code clone in
escape_separators, which made added an extra step to debugging here.
2024-12-08 15:27:08 +01:00
Fabian Boehm
99b5e6e0e7 completions/cargo: Complete packages to uninstall 2024-12-08 09:13:20 +01:00
Fabian Boehm
004953a3b2 Revert "BuiltinData to use const constructor function"
Unfortunately, this does not work with rust 1.70.

This reverts commit 7e516925e9.
2024-12-08 07:52:57 +01:00
Peter Ammon
7e516925e9 BuiltinData to use const constructor function
This makes the list of builtins one line per builtin. No functional change.
2024-12-07 10:37:53 -08:00
Peter Ammon
0b68fbfd85 Clean up some stale comments 2024-12-07 10:37:53 -08:00
Fabian Boehm
fcf8ed0628 Clarify docs on self-installing builds 2024-12-07 13:13:18 +01:00
Fabian Boehm
210d687b2b CHANGELOG installable fish 2024-12-06 22:13:34 +01:00
Fabian Boehm
74e0436c3c Document installable builds 2024-12-06 22:12:26 +01:00
Fabian Boehm
3360dcbebc Make static builds on Github Actions
For x86_64 and cross-compiled for aarch64, manually triggered

It *seems* to work, but I had to explicitly disable gettext for it (which is AFAICT currently non-functional under musl anyway).

Also it will create one .zip containing two .tar.xzs. It is about 8MB, which should be fine, tbh.
2024-12-06 22:12:26 +01:00
Fabian Boehm
1599293796 Build man pages into installable fish
This calls sphinx-build from build.rs to include the man pages in the binary.

We don't abort if sphinx doesn't exist, but we do if it failed.
2024-12-06 22:12:26 +01:00
Fabian Boehm
2343a6b1f1 docs: Read version from the version file
Makes it possible to generate the man pages without fish_indent
available.

(not the html docs because they highlight via fish_indent!)
2024-12-06 22:12:26 +01:00
Fabian Boehm
7c73c5fec0 Make fish installable
When built with the default "installable" feature, the data files (share/) are
included in the fish binary itself.

Run `fish --install` or `fish --install=noconfirm` (for
non-interactive use) to install fish's data files into ~/.local/share/fish/install

To figure out if the data files are out of date, we write the current version
to a file on install, and read it on start.

CMake disables the default features so nothing changes for that, but this allows installing via `cargo install`,
and even making a static binary that you can then just upload and have extract itself.

We set $__fish_help_dir to empty for installable builds, because we do not have
a way to generate html docs (because we need fish_indent for highlighting).
The man pages are found via $__fish_data_dir/man
2024-12-06 22:12:26 +01:00
Fabian Boehm
7827a8e533 Make bin path an Option
It is possible we cannot acquire this
2024-12-06 22:12:26 +01:00
Fabian Boehm
aa30b4db4b Set crate version to 4.0.0-alpha1
The next version is gonna be 4.0.0
2024-12-06 22:12:26 +01:00
Fabian Boehm
378dc9123a git_version_gen: Just print the version
This was needed because we #included it in C++, but now it's easier to
have just the version in there
2024-12-06 22:12:26 +01:00
Fabian Boehm
5abd0e46f5 build.rs: Panic if version could not be found
We don't want "fish --version" to print "unknown" or any other fake version
2024-12-06 22:12:26 +01:00
Fabian Boehm
e24823dd6c Signals: Compute signal set once on startup
Really the only thing we're looking for here is if we're started with
HUP ignored or not.

Saves a syscall per external process.

Continuation of #10869
2024-12-04 20:18:16 +01:00
Ambrose Bonnaire-Sergeant
3012020af3 doc: expand &| reference to full example (#10885)
* doc: expand &| reference to full example

* feedback
2024-12-04 20:13:00 +01:00
Fabian Boehm
7b2cc9dca2 CI: Disable cargo-deny again
I am not a fan of CI tools that make the checks fail for reasons
unrelated to the patch at hand.
2024-12-04 18:42:20 +01:00
Himadri Bhattacharjee
d124c31958 refactor: remove unnecessary copied() for Utf32Str reference 2024-12-02 19:12:39 +01:00
Fabian Boehm
b2e6609367 builtin random: Be less strict about arguments
This now allows:

- Same argument (`random 5 5`)
- Swapped ends (`random 10 2`)
- One possibility (`random 0 5 4`)

This makes it easier to use with numbers generated elsewhere instead
of hard-coded, so you don't need to check as much before running it.

Fixes #10879
2024-12-02 19:06:14 +01:00
Fabian Boehm
1cad9898d6 Refactor some more .unwrap/asserts
No use in asserting and then unwrapping, just .expect()
2024-11-30 23:11:04 +01:00
Fabian Boehm
4859606e0c posix_spawn: Unconditionally default all signals (except HUP)
We don't really care if the process has a custom handler installed, we
can just set it to default.

The one we check is SIGHUP, which may be given to us via `nohup`.

This saves ~30 syscalls *per process* we spawn, so:

```fish
for f in (seq 1000)
    command true
end
```

has ~30000 fewer rt_sigaction calls. These take up about ~30% of the
total time spent in syscalls according to strace.

We could also compute this set once at startup and then reuse it.
2024-11-30 23:00:44 +01:00
Peter Ammon
5d10bc6a02 Fix/suppress some clippies
needless_lifetimes is annoying; supress that. Fix some spacing that clippy was
complaining about.
2024-11-30 12:21:30 -08:00
Fabian Boehm
eee44b7469 ulimit: Fix multiplication overflow 2024-11-30 15:40:48 +01:00
Fabian Boehm
8736d9b1e7 CI: Add cargo-deny 2024-11-29 18:17:11 +01:00
Fabian Boehm
f5e71063d7 Add cargo-deny configuration 2024-11-29 18:17:00 +01:00
Fabian Boehm
2d1ad1c3cc Mostly Revert "cmake: Remove code to resolve rustup toolchains"
Apparently needed on our FreeBSD CI setup.

This reverts commit 281df5daad.
2024-11-28 20:00:34 +01:00
Fabian Boehm
8b464d96af Remove reference to static mut
This is what UnsafeCell is for: Providing interior mutability.

The docs at https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html
give an example just like this - `&mut *ptr.get()`

Without, rustc may complain - https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html
2024-11-28 19:36:50 +01:00
Fabian Boehm
281df5daad cmake: Remove code to resolve rustup toolchains
We turned it off, but for some reason (cmake version?) that stopped working on my system.

So instead we just remove all the code that does it.

To be honest I do not know why this exists anyway.
2024-11-27 22:29:13 +01:00
Johannes Altmanninger
3ed031c149 Update Kakoune completions 2024-11-27 08:44:36 +01:00
Johannes Altmanninger
644171fac6 fix: check whether a function is tombstoned during highlight
exists_no_autoload() wrongly thinks that tombstoned functions can be
autoloaded; fix that.

While at-it replace the use of get_props() with something simpler.

Co-authored-by: Himadri Bhattacharjee

Closes #10873
2024-11-27 08:44:36 +01:00
Fabian Boehm
c625a324ba docs/string-trim: Double down on the set of chars vs string thing 2024-11-25 17:53:14 +01:00
Fabian Boehm
4101bb30bf Remove unused variables
Never set since the introduction in 61686aff34
2024-11-25 16:29:00 +01:00
Johannes Altmanninger
b89619330b Disable terminal protocols before cancellable operations
The [disambiguate flag](https://sw.kovidgoyal.net/kitty/keyboard-protocol/#disambiguate) means that:

> In particular, ctrl+c will no longer generate the SIGINT signal,
> but instead be delivered as a CSI u escape code.

so cancellation only works while we turn off disambiguation.

Today we turn it off while running external commands that want to
claim the TTY.  Also we do it (only as a workaround for this issue)
while expanding wildcards or while running builtin wait.

However there are other cases where we don't have a workaround,
like in trivial infinite loops or when opening a fifo.

Before we run "while true; end", we put the terminal back in ICANON
mode. This means it's line-buffered, so we won't be able to detect
if the user pressed ctrl-c.

Commit 8164855b7 (Disable terminal protocols throughout evaluation,
2024-04-02) had the right solution: simply disable terminal protocols
whenever we do computations that might take a long time.
eval_node() covers most of that; there are a few others.

As pointed out in #10494, the logic was fairly unsophisticated then:
it toggled terminal protocols many times.  The fix in 29f2da8d1
(Toggle terminal protocols lazily, 2024-05-16) went to the extreme
other end of only toggling protocols when absolutely necessary.

Back out part of that commit by toggling in eval_node() again,
fixing cancellation.  Fortunately, we can keep most of the benefits
of the lazy approach from 29f2da8d1: we toggle only 2 times instead
of 8 times for an empty prompt.

There are only two places left where we call signal_check_cancel()
without necessarily disabling the disambiguate flag
1. open_cloexec() we assume that the files we open outside eval_node()
   are never blocking fifos.
2. fire_delayed(). Judging by commit history, this check is not
   relevant for interactive sessions; we'll soon end up calling
   eval_node() anyway.

In future, we can leave bracketed paste, modifyOtherKeys and
application keypad mode turned on again, until we actually run an
external command.  We really only want to turn off the disambiguate
flag.

Since this is approach is overly complex, I plan to go with either
of these two alternatives in future:
- extend the kitty keyboard protocol to optionally support VINTR,
  VSTOP and friends.  Then we can drop most of these changes.
- poll stdin for ctrl-c. This promises a great simplification,
  because it implies that terminal ownership (term_steal/term_donate)
  will be perfectly synced with us enabling kitty keyboard protocol.
  This is because polling requires us to turn off ICANON.
  I started working on this change; I'm convinced it must work,
  but it's not finished yet. Note that this will also want to
  add stdin polling to builtin wait.

Closes #10864
2024-11-24 16:11:57 +01:00
Fabian Boehm
f0a5f8738b Silence clippy lints 2024-11-24 11:17:34 +01:00
Mahmoud Al-Qudsi
1347df898e Add ascii fast path for fish_wcswidth(&wstrw)
chars.all(|c| c.is_ascii()) is autovectorizable but this outperforms even when
it's not vectorized.
2024-11-22 21:35:39 -06:00
Mahmoud Al-Qudsi
2fd51355c3 Speed up wcscasecmp by approximately 30-40%
Moving the "make empty ToLowercase iterator" logic to within the
`unwrap_or_else()` instead of always generating it brings most of the speedup;
unrolling the recursive call brings in the rest.
2024-11-22 21:34:25 -06:00
Mahmoud Al-Qudsi
8c8da78cf8 Speed up get_case_fold() 5x
Using `c.is_uppercase()` instead of getting the iterator and checking if the
first (and only) lowercase letter of the sequence is the same as the original
input is 5-8x faster (measured via criterion against `/usr/share/dict/words`).

(Additional benefit of forcibly inlining the now iterator-based comparison not
taken into account; this necessitated changing from a closure to a local
function as the inline attribute on closures is not yet supported with the
stable compiler toolchain.)
2024-11-22 16:30:10 -06:00
Mahmoud Al-Qudsi
b949497bc1 Use idiomatic names for CaseSensitivity and ContainType 2024-11-22 16:28:33 -06:00
Mahmoud Al-Qudsi
b570c7f6a6 Reduce allocations when deduping completions in place
This is still suboptimal because we are allocating a vector of indices to be
removed (but allocation-free in the normal case of no duplicates) but
significantly better than the previous version of the code that duplicated the
strings (which are larger and spread out all over the heap).

The ideal code (similar to what we had in the C++ version, iirc) would look like
this, but it's not allowed because the borrow checker hates you:

```
fn unique_in_place_illegal(comps: &mut Vec<Completion>) {
    let mut seen = HashSet::with_capacity(comps.len());
    let mut idx = 0;
    while idx < comps.len() {
        if !seen.insert(&comps[idx].completion) {
            comps.remove(idx);
            continue;
        }
        idx += 1;
    }
}
```
2024-11-22 14:11:01 -06:00
Fabian Boehm
36c5ee045c fixup! filter control sequences 2024-11-21 21:20:35 +01:00
Fabian Boehm
2d07aa2686 tests: Move control sequences filtering to fish directly
This was an sh-script that just invoked fish again.

I can see how we could implement it in another language to avoid the
fish under test corrupting the results, but it literally invoked the
fish under test anyway.
2024-11-21 21:08:56 +01:00
Fabian Boehm
8dcde27e0b functions/history: Put back some checks for clear{,-session}
Mostly we pass on the options - otherwise they would be ignored.

For `clear`, we do need the full checks, because that will
prompt *before* running the builtin.

But this makes it easier to eventually move that logic into the builtin
2024-11-21 18:55:03 +01:00
Fabian Boehm
212dd6ec37 builtins/history: Use the enum nicer
Name it so it's not SHOUTY CASE, make a `panic!` unrepresentable

No functional change
2024-11-21 18:33:32 +01:00
Fabian Boehm
fcab68c591 docs/faq: Fix some broken keys 2024-11-21 18:28:43 +01:00
Fabian Boehm
6fe192606a functions/history: Set variables in function-scope explicitly
```fish
set -g LESS foo

history search bar
```

changes the global $LESS and exports it.
2024-11-21 18:27:10 +01:00
Fabian Boehm
11f11e27a1 functions/history: Remove unnecessary code
These things are all handled in the builtin
2024-11-21 18:26:47 +01:00
Kid
31b15405e9 Add completion for path basename -E/--no-extension (#10863) 2024-11-20 15:06:53 -06:00
Mahmoud Al-Qudsi
edd82be58d Fix crash on invalid CSI parameters
If a semicolon-delimited list of CSI parameters contained an (invalid) long
sequence of ascii numeric characters, the original code would keep multiplying
by ten and adding the most recent ones field until the `params[count][subcount]`
u32 value overflowed.

This was found via automated fuzz testing of the `try_readch()` routine against
a corpus of some proper/valid CSI escapes.
2024-11-20 15:01:34 -06:00
Mahmoud Al-Qudsi
b92830cb17 Change readch() into try_readch()
This lets us call into the entirety of the prior `readch()` with an exhaustible
input stream without panicking on the `unreachable!()` call. The previous
functionality is kept under the old name by calling `try_readch()` with the
`blocking` parameter set to `true` (100% same behavior as before).

While the `try_readch(false)` entrypoint isn't used directly by the current fish
codebase, it is required in order to automate input reader tests without the
overhead and complexity of running the test harness in a tty emulator emulator
like pexpect or tmux, which moreover necessitates out-of-process testing – which
is incompatible with most perf-guided testing harnesses.

I hope to be able to upstream harness integrations using this entry point in the
near future.
2024-11-20 14:53:07 -06:00
Fabian Boehm
b3108c0cee CHANGELOG 2024-11-19 21:12:44 +01:00
Fabian Boehm
7a667b4f6d Add basic completions for firejail
These are pretty basic, but get us roughly up to the level of the
official completions (that are also incomplete and offer disabled
options).

Fixes #10858
2024-11-18 16:16:07 +01:00
Peter Ammon
c4bc6b6f09 Clean up print_help
`print_help` is a hacky-wacky function used to support the `--help` command
of `fish_key_reader` and others. The Rust version panics on an error; fix
that and make it print more useful help messages.
2024-11-17 17:03:34 -08:00
Unbelievable Mystery
262e2d5fe6 Update completions for: wine (#10789)
* feat(function): move cmd completion function to a separate file

* feat(completion): support wine cmd subcommand

* feat(completion): support wine control subcommand

* feat(completion): support wine eject subcommand

* feat(completion): support wine explorer subcommand

* feat(completion): support wine explorer subcommand for desktops

* feat(completion): support wine start subcommand

* feat(completion): support wine winemenubuilder subcommand

* feat(completion): support wine winepath subcommand

* fix(function): rename function for cmd argument completion

* feat(function): implement function to complete registry keys

* feat(completion): support wine regedit subcommand

* feat(function): add top-level key descriptions

* fix(completion): remove redundant comment

* feat(completion): support wine msiexec subcommand

* refactor(completion): group code into functions

* feat(completion): enhance subcommand descriptions
2024-11-17 14:58:21 -08:00
Unbelievable Mystery
93aa5a9376 Add completions for: guile, guild (#10792)
* feat(completion): support guile command

* feat(completion): support guild command

* feat(completion): support guild subcommand

* feat(completion): squeeze code
2024-11-17 14:08:19 -08:00
Peter Ammon
642eff9e1f Fix some clippies and remove some dead code 2024-11-17 12:37:45 -08:00
Next Alone
723e5a8417 completions(ollama): ollama need no files as i know (#10851)
Closes #10851.

Signed-off-by: Next Alone <12210746+NextAlone@users.noreply.github.com>
2024-11-17 10:05:42 -06:00
David Adam
0e6171b63e CHANGELOG: work on 4.0.0 2024-11-17 23:12:46 +08:00
David Adam
98fcb1c6ba completions/diskutil: list all volumes, not just the writeable ones
Discussion in #10574.
2024-11-17 22:06:54 +08:00
Xiretza
421e27b1bf Add completions for iftop 2024-11-17 21:59:08 +08:00
Johannes Altmanninger
13f0c9b0c6 Remove accidentally added file 2024-11-17 05:20:35 +01:00
Johannes Altmanninger
2d8fcbcdcd Fix regression causing mbrtowc(argv) to be called before setlocale()
Fixes #10847
2024-11-16 20:46:06 +01:00
Mahmoud Al-Qudsi
68b9f96f84 Add completions for simonw/llm 2024-11-16 13:27:29 -06:00
Johannes Altmanninger
913860bd1c Fix regression causing alt-right to stop at autosuggestion
Fixes #10839
2024-11-16 13:05:44 +01:00
Johannes Altmanninger
ca21872d14 Clean up the accept-autosuggestion code path a little bit
It's still a bit too complex unfortunately.
2024-11-16 13:05:44 +01:00
vp2177
2b19e1a09b completion(apt-mark): Add missing minimize-manual command & --color options (#10825)
* Update apt-mark.fish
2024-11-14 16:01:54 -06:00
Mahmoud Al-Qudsi
cdeb3977c3 Re-enable tmux-prompt test under FreeBSD
It passes now that we have uvar notifications working under BSD.
2024-11-14 13:44:49 -06:00
Mahmoud Al-Qudsi
fea1e3aee5 Use iterators to clean up disown logic 2024-11-14 13:25:25 -06:00
Mahmoud Al-Qudsi
c1acbf2845 Deduplicate jobs passed to disown builtin
I'm guessing this was missed in the port because there were comments referencing
using a hash set to perform the deduplication but there was no hashset. (The
TODO was added later.)
2024-11-14 13:24:55 -06:00
Fabian Boehm
366c1b7210 Refuse to search history pager if no new results exist
This prevents searching further and collapsing results into one.

Now I need to figure out how to get it to flash.
2024-11-14 20:02:49 +01:00
Mahmoud Al-Qudsi
4061ef7137 Remove unnecessary Pid::get() calls 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
fc47d9fa1d Use strongly typed Pid for job control 2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
2cf4b12d41 Use strongly typed Option<Pid> for event handler
This caught an incorrect description for process/job exit handlers for ANY_PID
(now removed) which has been replaced with a message stating the handler is for
any process exit event.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
95ac51101e Use Option<Pid> instead of Option<pid_t>
Statically assert that the interior value is both positive and non-zero.
2024-11-14 13:02:03 -06:00
Mahmoud Al-Qudsi
3307672998 Use type safety for pid values
The previous approach of "treat this field as an `Option<NonZeroU32>` and
remember to check `p.has_pid()` before accessing it" was a mix of C++ and rust
conventions and led to some bugs or incorrect behaviors.

* `jobs -p` would previously print both the (correct) external pid and the
  (incorrect) internal value of `0` if a backgrounded command contained a
  fish function (e.g. `function foo; end; cat | foo &; jobs`)
* Updating/calculating job cpu time and usage was incorrectly including all of
  fish's cpu usage/time for each function/builtin member of the job pipeline.

Closes #10832
2024-11-14 13:02:03 -06:00
Fabian Boehm
080e40aac0 Fix crash in history pager
ctrl-r ctrl-s ctrl-s

Attemps to go before the beginning and asserts out. Instead refuse to
do that.

(there's some weirdness where it can reduce the pager to the first
entry if you keep pressing, which I haven't found yet, but that's better than *crashing*)
2024-11-14 16:36:40 +01:00
Fabian Boehm
7846a232a9 cmake: Add some new version gunk
CMake Warning (dev) at cmake/Tests.cmake:56 (add_custom_command):
  Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.  Assuming
  POST_BUILD to preserve backward compatibility.

  Policy CMP0175 is not set: add_custom_command() rejects invalid arguments.
  Run "cmake --help-policy CMP0175" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

So we just keep it the same.
2024-11-13 17:48:15 +01:00
Fabian Boehm
6d76b938c7 bind: Remove "c-" and "a-" shortcut notation
These are another way to spell the same thing that doesn't match what
`bind` would print.

They're also not documented and tested thoroughly.

Since they are just small shortcuts and unreleased we can just remove
them.

Fixes #10845
2024-11-13 17:48:15 +01:00
Mahmoud Al-Qudsi
14a5c0ca44 Disable tmux-multiline-prompt under macOS CI 2024-11-12 17:13:18 -06:00
Mahmoud Al-Qudsi
bb57f2391f Fix a bad comment and clarify delta behavior
s/fish/delta/ and provide a better explanation.
2024-11-12 09:59:10 -06:00
Mahmoud Al-Qudsi
d33cbfd1a3 Prevent delta completions from complain with old version 2024-11-11 16:51:27 -06:00
Mahmoud Al-Qudsi
4e3dc51bc4 Prevent test suite from hanging on panic 2024-11-11 16:45:13 -06:00
Fabian Boehm
960415db3f function: Error out for read-only variables
This will refuse to define the function instead of defining it with an
unusable argument.

Fixes #10842
2024-11-11 17:56:57 +01:00
Fabian Boehm
0ef811c86e dir_iter: Remove duplicate NUL-removal
This goes over the d_name twice.

Filenames already cannot contain NUL (the C-api cannot express it!), so we don't need to scan them.
2024-11-11 17:56:57 +01:00
Mahmoud Al-Qudsi
f0a3a5708f git: complete git diff src/ to show modified files before unmodified ones
This has the side effect of changing the order of completions for a bare `git
diff` to show modified files before revisions; previously they came at the very
end after all revisions, stashes, local branches, remote branches, and tags.
That seems sensible to me?

As I understand the completions file, it seems to me that the intention was for
`git diff src/` to only show modified files to begin with ­ it
previously/currently shows them all, so we might want to add a `-n 'not ...'`
condition for `git diff` to prevent that.
2024-11-10 12:55:32 -06:00
Peter Ammon
dff454b1c7 Rework git detection for macOS
fish by default shows a git-aware prompt. Recall that on macOS, there are
two hazards we must avoid:

1. The command `/usr/bin/git` is installed by default. This command is not
actually git; instead it's a stub which pops open a dialog proposing to
install Xcode command line tools. Not a good experience.
2. Even after installing these tools, the first run of any `git` or other
command may be quite slow, because it's now a stub which invokes `xcrun`
which needs to populate a cache on a fresh boot. Another bad experience.

We previously attempted to fix this by having `xcrun` print out its cache
path and check if there's a file there. This worked because `xcrun` only
lazily created that file. However, this no longer works: `xcrun` now
eagerly creates the file, and only lazily populates it. Thus we think git
is ready, when it is not.

(This can be reproduced by running `xcrun --kill-cache` and then running
the default fish shell prompt - it will be slow).

Change the fix in the following way: using sh, run `/usr/bin/git --version;
touch /tmp/__fish_git_ready` in the background. Then detect the presence of
/tmp/__fish_git_ready as a mark that git is ready.

Fixes #10535
2024-11-09 12:46:06 -08:00
Johannes Altmanninger
2543b8198d Fix crash when sprintf width argument overflows u64
Given "printf %18446744073709551616s", we parse the number only in
the printf crate, which tells us that we overflowed somwhere (but
not where exactly).
2024-11-09 08:16:08 +01:00
Mahmoud Al-Qudsi
9fddc3e887 Emit only sane pgid value for jobs output (#10833)
We were previously printing the internal `INVALID_PID` value (since removed),
which was a meaningless `-2` constant, when there was no pgid associated with a
job.

This PR changes that to `-` to indicate no pgid available, which I prefer over
something like `0` or `-1`, but will cause problems for code that is hardcoded
to convert this field to an integral value.
2024-11-08 10:33:30 -06:00
David Adam
2279b47178 CHANGELOG: work on 4.0.0 2024-11-07 23:52:29 +08:00
Dezhi Wu
5405833822 feat(completion): Add kops.fish completion
[kOps] is a set of tools for installing, operating, and deleting Kubernetes
clusters.

[kOps]: https://github.com/kubernetes/kops/
2024-11-07 23:13:09 +08:00
Johannes Altmanninger
5e3fdf3320 Fix regression causing crash when we should clamp negative wcwidth
Fixes c41dbe455 (Also use control pictures for pager prefix,
2024-10-19).

Fixes #10836
2024-11-07 07:36:36 +01:00
Fabian Boehm
373c5b1e14 fixup! Cursor visible sequence
Whoops, picked the wrong part of cnorm
2024-11-06 19:03:50 +01:00
Fabian Boehm
56718c31b1 reader: Comment the OSC 133 marker sequences 2024-11-06 19:01:17 +01:00
Fabian Boehm
c1fbe237c9 Make cursor visible after commands
Just like we already fix terminal modes if a command left them broken,
having an invisible cursor makes the terminal hard to use and so we
fix it.

We can't really use cnorm/cursor_normal because that often includes
other gunk like making the cursor blink, but it turns out every
terminfo entry agrees on the sequence to make the cursor visible, so
we hardcode it.

Fixes #10834
2024-11-06 19:01:17 +01:00
Fabian Boehm
bfc68345c9 Disable CSI u in Jetbrains terminals
Note: This may not be sent in WSL.

Fixes #10829
2024-11-06 19:01:04 +01:00
Fabian Boehm
4b24fe7daf docs/export: Add a bit on PATH=$PATH:... 2024-11-06 18:50:41 +01:00
Fabian Boehm
0979b9a98b help: Print external URL if no browser was found
This is nicer when you use fish over ssh, and that system does not
have a browser. But the system where your terminal is has one, and so
now you can just click the link.
2024-11-06 18:48:57 +01:00
David Adam
018659bf66 CHANGELOG: work on 4.0.0 2024-11-07 01:09:11 +08:00
David Adam
0d9ad0f23b docs: add short documentation for export
Work on #10541.
2024-11-06 23:47:31 +08:00
David Adam
767ae87191 CONTRIBUTING.rst: update for Rust 2024-11-06 23:27:04 +08:00
David Adam
7f29f09d25 README: updates for Rust / 4.0 2024-11-06 23:22:26 +08:00
Johannes Altmanninger
7debdb75af Fix regression causing fish_cursor_external to be ignored
Regressed in 0e97b876e (Simplify fish_vi_cursor, 2024-10-25).
2024-11-06 07:24:00 +01:00
Mahmoud Al-Qudsi
24a077f804 Silence GPG warnings about directory permissions 2024-11-04 16:35:24 -06:00
Mahmoud Al-Qudsi
d7f4ad7ab8 Silence gh warnings re unable to read plugins dir
Unlike the errors, these *do* get printed to stderr.
2024-11-04 16:33:30 -06:00
Mahmoud Al-Qudsi
33a170d614 Replace INVALID_PID constant with Option<NonZeroU32>
If we end up using this in more places, we can create a `Pid` newtype.
Note that while the constant is no longer used in code, its previous value of -2
is still printed by `jobs` when no pgid is associated with a job. I will open a
PR to change this to something else, likely either `0` or `-`.
2024-11-04 16:19:22 -06:00
Mahmoud Al-Qudsi
d1a2923d72 Fix doc comments for CancelBehavior 2024-11-04 15:49:33 -06:00
Mahmoud Al-Qudsi
8aed929f5e Fix broken changelog formatting 2024-11-03 13:53:42 -06:00
David Adam
e5040cbbaf CHANGELOG: work on 4.0.0 2024-11-03 22:43:25 +08:00
Peter Ammon
23941ea9ca Don't try locking the history file if mmap returns ENODEV
If we try to memory map the history file, and we get back ENODEV meaning that
the underlying device does not support memory mapping, then treat that as a hint
that the filesystem is remote and disable history locking.
2024-11-02 12:09:51 -07:00
Peter Ammon
344b072e82 Further expand the list of filesystems considered remote
Incorporate additional file systems from
https://github.com/coreutils/gnulib/blob/master/lib/mountlist.c#L237-L253
by hunting down their magic numbers.

In the future we could consider switching to f_fstypename.
2024-11-02 11:59:34 -07:00
Johannes Altmanninger
cfcf415db7 Render overflown commandline in entirety just before executing
As of 04c913427 (Limit command line rendering to $LINES lines,
2024-10-25), we only render a part of the command line.  This removes
valuable information from scrollback.
The reasons for the limit were
1. to enable redrawing the commandline (can't do that if part of it
   is off-screen).
2. if the cursor is at the beginning of the command-line, we can't
   really render the off-screen suffix (unless we can tell the terminal
   to scroll back after doing that).

Fortunately these don't matter for the very last rendering of a
command line.  Let's render the entire command just before executing,
fixing the scrollback for executed commands.

In future, we should fix it also for pre-execution renderings. This
needs a terminal command to clear part of the scrollback.  Can't find
anything on https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
There is "Erase Saved Lines" but that deletes the entire scrollback.

See the discussion in #10827
2024-11-02 10:25:58 +01:00
Johannes Altmanninger
04d97e936a Remove redundant cursor position invariant check
Since f89909ae3 (Also handle overflown screens if editing pager search
field, 2024-10-27), cursor_arr is never None after the loop.
Assert that by unwrapping.

qa.sh
2024-11-02 10:16:45 +01:00
Johannes Altmanninger
f42beec42e Fix typo in comment 2024-11-02 10:13:37 +01:00
Johannes Altmanninger
85404bf7a9 edit_command_buffer: speed up setting cursor position by line/column
alt-e restores the cursor position received from the editor, moving by
one character at a time.  This can be super slow on large commandlines,
even on release builds.  Let's fix that by setting the coordinates
directly.
2024-11-01 20:09:55 +01:00
Johannes Altmanninger
6525e3d11a edit_command_buffer: silence error when editor reports out-of-bounds line number
This happens when using alt-e to edit the command buffer,
adding some lines, leaving the cursor at the end
and quitting the editor without saving.

Let's avoid the noisy error that has sort of bad rendering (would
need __fish_echo).
2024-11-01 20:09:55 +01:00
Johannes Altmanninger
3710e98d65 Suppress spurious error when config dir creation fails due to TOCTOU
Our recursive create_dir() first calls stat() to check if the directory
already exists and then mkdir() trying to create it. If another (fish)
process creates the same directory after our stat() but before our
mkdir(), then our mkdir() fails with EEXIST. This error is spurious
if there is already a directory at this path (and permissions are
correct).

Let's switch to the stdlib version, which promises to solve this issue.
They currently do it by running mkdir() first and ask stat() later.

This implies that they will only return success even if we don't have
any of rwx permissions on the directory, but that was already a problem
before this change. We silently don't write history in that case..

Fixes #10813
2024-10-31 08:01:31 +01:00
Josef Litoš
9e01981bb9 completions/adb: local files first when pushing 2024-10-31 01:05:44 +01:00
Johannes Altmanninger
cd3b6f9124 commandline --showing-suggestion to ignore single-space autosuggestion
All-whitespace autocompletions are invisible, no matter the cursor
shape.  We do offer such autosuggestions after typing a command name
such as "fish". Since the autosuggestion is invisible it's probably
not useful. It also does no harm except when using a binding like

	bind ctrl-g '
	    if commandline --showing-suggestion
	        commandline -f accept-autosuggestion
	    else
	        up-or-search
	    end'

where typing "fish<ctrl-g>" surprisingly does not perform a history
search.  Fix this by detecting this specific case. In future we
could probably stop showing autosuggestions whenever they only
contain whitespace.
2024-10-30 06:25:27 +01:00
Johannes Altmanninger
ec939fb22f Work around BSD man calling pager when stdout is not a TTY
With BSD man, "PAGER=vim man man | cat" hangs because
[man](https://cgit.freebsd.org/src/tree/usr.bin/man/man.sh) wrongly
calls the pager even though stdout is not a terminal.

This hang manifests in places where we call apropos in a subshell,
such as in "complete -Ccar".

Let's work around this I guess. This should really be fixed upstream
because it's a problem in every app that wants to display man pages
but doesn't emulate a complete terminal.

Weirdly, the Apple derivative of man.sh uses WHATISPAGER instead
of MANPAGER.

Closes #10820
2024-10-30 04:58:50 +01:00
Johannes Altmanninger
31d7f197b1 Switch default build type back to RelWithDebInfo for now
A release build is recommended to most users (to avoid occasional slowness)
whereas developers may prefer debug builds for shorter build times and more
accurate debug information.

There are more users of "make install" than developers, so I think the
default should be optimized for users, i.e. an optimized build. I think
that's in line with what most of our peer projects do.

Even if developers don't know about the -DCMAKE_BUILD_TYPE=Debug
trick, they will likely be able to iterate quickly by using "cargo
{build,check,clippy,test}" and rust-analyzer, all of which use a debug
configuration by default, irrespective of cmake. Granted, users will need
to use cmake to run system tests. If a task needs a lot of iterations,
one can always convert the system test to a script that can be run with
target/build/fish. For building & running all system tests, the release
build takes 30% longer, so not that much.

Here are my build/test times and binary sizes; with debug:

    $ time ninja -C build-Debug/
    ________________________________________________________
    Executed in   25.30 secs    fish           external
       usr time   68.33 secs  676.00 micros   68.32 secs
       sys time   11.34 secs   41.00 micros   11.34 secs
    $ du -h build-Debug/fish
    43M	    build-Debug/fish
    $ time ninja -C build-Debug/ test
    ________________________________________________________
    Executed in  193.96 secs    fish           external
       usr time  182.84 secs    1.53 millis  182.83 secs
       sys time   30.97 secs    0.00 millis   30.97 secs

with release

    $ time ninja -C build-RelWithDebInfo/
    ________________________________________________________
    Executed in  106.80 secs    fish           external
       usr time  164.98 secs  631.00 micros  164.98 secs
       sys time   11.62 secs   41.00 micros   11.62 secs
    $ du -h build-RelWithDebInfo/fish
    4.6M	build-RelWithDebInfo/fish
    $ time ninja -C build-RelWithDebInfo/ test
    ________________________________________________________
    Executed in  249.87 secs    fish           external
       usr time  260.25 secs    1.43 millis  260.25 secs
       sys time   29.86 secs    0.00 millis   29.86 secs

Tangentially related, the numbers with "lto = true" deleted.  This seems
like a nice compromise for a default but I don't know much about the other
benefits of lto.

    $ time ninja -C build-RelWithDebInfo-thin-lto/
    ________________________________________________________
    Executed in   35.50 secs    fish           external
       usr time  196.93 secs    0.00 micros  196.93 secs
       sys time   13.00 secs  969.00 micros   13.00 secs
    $ du -h build-RelWithDebInfo-thin-lto/fish
    5.5M	build-RelWithDebInfo-thin-lto/fish
    $ time ninja -C build-RelWithDebInfo-thin-lto/ test
    ________________________________________________________
    Executed in  178.62 secs    fish           external
       usr time  287.48 secs  976.00 micros  287.48 secs
       sys time   28.75 secs  115.00 micros   28.75 secs

Alternative solution: have no default at all, and error out until the user
chooses a build type.
2024-10-28 14:26:57 +01:00
Johannes Altmanninger
dccc3349f0 Update build type recommendation to match our previous default
Currently the only difference between RelWithDebInfo and Release is that
the former adds -g (aka debuginfo=2) though it doesn't seem to make a lot
of difference in my testing.

Since build_tools/make_pkg.sh and debian/rules use RelWithDebInfo, let's be
consistent with those.
2024-10-28 14:26:57 +01:00
Peter Ammon
fa72d1faa1 Changelog fix for filesystem remote detection
Add note about #10818
2024-10-27 21:30:29 -07:00
Peter Ammon
e322d3addc Expand the set of filesystems considered remote on Linux
Some background: fish has some files which should be updated atomically:
specifically the history file and the universal variables file. If two fish
processes modified these in-place at the same time, then that could result
in interleaved writes and corrupted files.

To prevent this, fish uses the write-to-adjacent-file-then-rename to
atomically swap in a new file (history is slightly more complicated than
this, for performance, but this remains true). This avoids corruption.

However if two fish processes attempt this at the same time, then one
process will win the race and the data from the other process will be lost.
To prevent this, fish attempts to take an (advisory) lock on the target
file before beginning this process. This prevents data loss because only
one fish instance can replace the target file at once. (fish checks to
ensure it's locked the right file).

However some filesystems, particularly remote file systems, may have locks
which hang for a long time, preventing the user from using their shell.
This is far more serious than data loss, which is not catastrophic: losing
a history item or variable is not a major deal. So fish just attempts to
skip locks on remote filesystems.

Unfortunately Linux does not have a good API for checking if a filesystem
is remote: the best you can do is check the file system's magic number
against a hard-coded list. Today, the list is NFS_SUPER_MAGIC,
SMB_SUPER_MAGIC, SMB2_MAGIC_NUMBER, and CIFS_MAGIC_NUMBER.

Expand it to AFS_SUPER_MAGIC, CODA_SUPER_MAGIC, NCP_SUPER_MAGIC,
NFS_SUPER_MAGIC, OCFS2_SUPER_MAGIC, SMB_SUPER_MAGIC, SMB2_MAGIC_NUMBER,
CIFS_MAGIC_NUMBER, V9FS_MAGIC which is believed to be exhaustive.

ALSO include FUSE_SUPER_MAGIC: if the user's home directory is some FUSE
filesystem, that's kind of sus and the fewer tricks we try to pull, the
better.
2024-10-27 21:10:45 -07:00
Peter Ammon
3e3aa08c28 Fix some dumb clippies 2024-10-27 18:20:49 -07:00
Nihaal Sangha
5ee51492be Add tailscale completion 2024-10-27 16:49:00 -07:00
Giorgio Gallo
677e53f06a fix documentation for path normalize 2024-10-27 08:32:05 +00:00
Johannes Altmanninger
f89909ae31 Also handle overflown screens if editing pager search field
As mentioned in 04c913427 (Limit command line rendering to $LINES
lines, 2024-10-25) our rendering breaks when the command line overflows
the screen and we have a pager search field.

Let's also apply the overflow logic in this case.

Note that the search field still works, it's just not visible.

In future we should maybe show a small search field (~4 lines) in
this case (removing 4 screen lines worth of command line).  But again,
this is not really important.
2024-10-27 08:17:56 +01:00
Johannes Altmanninger
adfa87d141 Fix glitch rendering commandline that overflows screen size
If the first physical line in the command line overflows the screen,
the cursor will be wrong and we'll fail to clear the prompt without
a manual ctrl-l.  Let's fix that, and also don't print the OSC 133
marker in this case.

Currently, when we are scrolled, the first line on the screen still
gets an indentation that would normally be filled by the prompt.
This happens even for soft-wrapped lines, so they might be
torn apart in weird ways here.

In future, we might paint the prompt here.  If not, the current
behavior for soft-wrapped lines is debatable but its' not super
important to fix. The main goal is to first get rid of glitches in
these edge cases.
2024-10-27 07:16:30 +01:00
Johannes Altmanninger
c155acd004 Fix tmux-multiline-prompt test with EDITOR=vim
This test does "isolated-tmux send-keys Escape" to exit copy mode. When
EDITOR contains "vi", tmux will use Vi keybindings where Escape does
something else ("q" would exit copy mode).

Tests want to have predictable behavior so let's declare the default
emacs key bindings unconditionally.

Fixes #10812
2024-10-27 05:03:30 +01:00
Peter Ammon
2e2765eec0 Remove .cargo/config.toml
This added link args to target macOS 10.9, but these arguments are not necessary
when building via the make_pkg.sh script, and this file is causing other
problems.
2024-10-26 18:05:22 -07:00
Fabian Boehm
ca27e028df Silence unused imports for backports
Would be cool if there was a way to do this on future:: in general.
2024-10-26 22:28:37 +02:00
Fabian Boehm
0e62178320 Only apply kitty protocol MC hack in MC
This deactivated it everywhere
2024-10-26 22:24:22 +02:00
Johannes Altmanninger
bd9fee417b Use kitty keyboard protocol again for recent Midnight Commander
See https://midnight-commander.org/ticket/4597
2024-10-26 19:55:48 +02:00
Johannes Altmanninger
9ef76860e6 Default Vi cursor shapes for insert/replace mode
Let's provide a sensible default here. Use a line for "insert" and an
underline for "replace_one" mode.  Neovim does the same, it feels pretty
slick.

As mentioned in #10806
2024-10-26 08:25:12 +02:00
Johannes Altmanninger
5760a1afcf Don't reset the fish_cursor_selection_mode in fish_default_key_bindings
As of the parent commit, __fish_vi_key_bindings_remove_handlers
should be working properly now, so this is no longer necessary That
function also cleans up other stuff like fish_cursor_end_mode, that
fish_default_key_bindings doesn't know anything about.

Also this fixes a spurious exit status of 4 in some scenarios.
2024-10-26 08:25:12 +02:00
Johannes Altmanninger
b05e071238 Properly remove Vi mode when switching to different bindings
fish_key_bindings may be set directly
or via fish_{default,vi}_key_bindings.

The latter use "set --no-event" to simplify their control
flow.  This (24836f965 (Use set --no-event in the key binding
functions, 2023-01-10)) broke Vi mode cleanup, since Vi mode
uses a variable hook.  Let's update this variable also when using
fish_{default,vi}_key_bindings.  Another reason to keep this variable
in sync is to make the fish_key_bindings handlers working as expected.
2024-10-26 08:22:19 +02:00
Johannes Altmanninger
8eaa16542a Extract function for changing key bindings 2024-10-26 08:21:12 +02:00
Johannes Altmanninger
832cda26f6 Fix external cursor not being restored on exiting Vi mode 2024-10-26 08:21:12 +02:00
Johannes Altmanninger
0e97b876ea Simplify fish_vi_cursor
This command has redundant source statements which need a lot
of escaping. Also, let's extract a function, to be modified in a
following commit.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
aca8058717 Remove obsolete optimization in default binding initialization
This special case was added in fb2ed355e (Improve fork reporting Save a
couple of forks during init, 2012-04-24) but the reason for it is gone.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
dea7841611 Fix Vi replace mode regression not being able to append to command line
Regressed in d51f66964 (Vi mode: avoid placing cursor beyond last
character, 2024-02-14).
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
c2cde317f2 Remove stale FISH_UNIT_TESTS_RUNNING workaround
This exists to make sure our assertions pass independent of the
terminal but now we unconditionally print __fish_cursor_xterm.
2024-10-26 08:21:12 +02:00
Johannes Altmanninger
04c9134275 Limit command line rendering to $LINES lines
Render the command line buffer only until the last line we can fit
on the screen.

If the cursor pushes the viewport such that neither the prompt nor
the first line of the command line buffer are visible, then we are
"scrolled". In this case we need to make sure to erase any leftover
prompt, so add a hack to disable the "shared_prefix" optimization
that tries to minimize redraws.

Down-arrow scrolls down only when on the last line, and up-arrow always
scrolls up as much as possible.  This is somewhat unconventional;
probably we should change the up-arrow behavior but I guess it's a
good idea to show the prompt whenever possible.  In future we could
solve that in a different way: we could keep the prompt visible even
if we're scrolled. This would work well because at least the left
prompt lives in a different column from the command line buffer.
However this assumption breaks when the first line in the command
line buffer is soft-wrapped, so keep this approach for now.

Note that we're still broken when complete-and-search or history-pager
try to draw a pager on top of an overfull screen.  Will try to fix
this later.

Closes #7296
2024-10-25 17:35:42 +02:00
Johannes Altmanninger
50333d8d00 Fix code duplication in commandline rendering
Will use this in the next commit.
2024-10-25 17:11:54 +02:00
Peter Ammon
0d5e6f356e Correct spelling of "courtesy" 2024-10-24 20:25:22 -07:00
Mahmoud Al-Qudsi
9c960d6af8 Fix number of characters consumed for VT200 mouse tracking
It's a 9-char CSI and we've read 3 (`<ESC>[T`), so we need to read six more.
Verified against the previous C++ codebase and couldn't find a reason for the
change to consuming 10 chars in a `git blame` run.
2024-10-24 11:22:52 -05:00
Mahmoud Al-Qudsi
daa2f2d023 Document max CSI parameter count 2024-10-24 10:36:00 -05:00
Mahmoud Al-Qudsi
21860cbd39 Fix panic parsing CSIs
The array lengths were transposed, so attempting to parse a CSI with more than 4
parameters would go out of bounds and panic.
2024-10-24 10:28:04 -05:00
303 changed files with 7224 additions and 2819 deletions

View File

@@ -1,8 +0,0 @@
# For macOS, support 10.9 on x86-64, and 11.0 on aarch64, which
# is the minimum supported version for Apple Silicon.
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-mmacosx-version-min=10.9"]
[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-mmacosx-version-min=11.0"]

View File

@@ -13,16 +13,20 @@ max_line_length = 100
indent_style = tab
[*.{md,rst}]
max_line_length = unset
trim_trailing_whitespace = false
[*.{sh,ac}]
indent_size = 2
[*.sh]
indent_size = 4
[build_tools/release.sh]
max_line_length = 72
[Dockerfile]
indent_size = 2
[share/{completions,functions}/**.fish]
max_line_length = off
max_line_length = unset
[{COMMIT_EDITMSG,git-revise-todo}]
max_line_length = 80
[{COMMIT_EDITMSG,git-revise-todo,*.jjdescription}]
max_line_length = 72

View File

@@ -0,0 +1,14 @@
name: Install sphinx-markdown-builder
permissions:
contents: read
runs:
using: "composite"
steps:
- shell: bash
run: |
set -x
commit=b259de1dc97573a71470a1d71c3d83535934136b
pip install git+https://github.com/krobelus/sphinx-markdown-builder@"$commit"
python -c 'import sphinx_markdown_builder'

View File

@@ -0,0 +1,20 @@
name: Oldest Supported Rust Toolchain
inputs:
targets:
description: Comma-separated list of target triples to install for this toolchain
required: false
components:
description: Comma-separated list of components to be additionally installed
required: false
permissions:
contents: read
runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@1.70
with:
targets: ${{ inputs.targets }}
components: ${{ inputs.components}}

View File

@@ -0,0 +1,20 @@
name: Stable Rust Toolchain
inputs:
targets:
description: Comma-separated list of target triples to install for this toolchain
required: false
components:
description: Comma-separated list of components to be additionally installed
required: false
permissions:
contents: read
runs:
using: "composite"
steps:
- uses: dtolnay/rust-toolchain@1.89
with:
targets: ${{ inputs.targets }}
components: ${{ inputs.components }}

View File

@@ -1,42 +0,0 @@
name: macOS build and codesign
on:
workflow_dispatch: # Enables manual trigger from GitHub UI
jobs:
build-and-code-sign:
runs-on: macos-latest
environment: macos-codesign
steps:
- uses: actions/checkout@v4
- name: Install Rust 1.73.0
uses: dtolnay/rust-toolchain@1.73.0
with:
targets: x86_64-apple-darwin
- name: Install Rust 1.79
uses: dtolnay/rust-toolchain@1.79
with:
targets: aarch64-apple-darwin
- name: build-and-codesign
run: |
cargo install apple-codesign
mkdir -p "$FISH_ARTEFACT_PATH"
echo "$MAC_CODESIGN_APP_P12_BASE64" | base64 --decode > /tmp/app.p12
echo "$MAC_CODESIGN_INSTALLER_P12_BASE64" | base64 --decode > /tmp/installer.p12
echo "$MACOS_NOTARIZE_JSON" > /tmp/notarize.json
./build_tools/make_pkg.sh -s -f /tmp/app.p12 -i /tmp/installer.p12 -p "$MAC_CODESIGN_PASSWORD" -n -j /tmp/notarize.json
rm /tmp/installer.p12 /tmp/app.p12 /tmp/notarize.json
env:
MAC_CODESIGN_APP_P12_BASE64: ${{ secrets.MAC_CODESIGN_APP_P12_BASE64 }}
MAC_CODESIGN_INSTALLER_P12_BASE64: ${{ secrets.MAC_CODESIGN_INSTALLER_P12_BASE64 }}
MAC_CODESIGN_PASSWORD: ${{ secrets.MAC_CODESIGN_PASSWORD }}
MACOS_NOTARIZE_JSON: ${{ secrets.MACOS_NOTARIZE_JSON }}
# macOS runners keep having issues loading Cargo.toml dependencies from git (GitHub) instead
# of crates.io, so give this a try. It's also sometimes significantly faster on all platforms.
CARGO_NET_GIT_FETCH_WITH_CLI: true
FISH_ARTEFACT_PATH: /tmp/fish-built
- uses: actions/upload-artifact@v4
with:
name: macOS Artefacts
path: /tmp/fish-built/*
if-no-files-found: error

View File

@@ -1,4 +1,4 @@
name: make test
name: make fish_run_tests
on: [push, pull_request]
@@ -22,16 +22,17 @@ jobs:
sudo apt install gettext libpcre2-dev python3-pexpect tmux
# Generate a locale that uses a comma as decimal separator.
sudo locale-gen fr_FR.UTF-8
- uses: ./.github/actions/install-sphinx-markdown-builder
- name: cmake
run: |
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
- name: make
run: |
make VERBOSE=1
- name: make test
make -C build VERBOSE=1
- name: make fish_run_tests
run: |
make VERBOSE=1 test
make -C build VERBOSE=1 fish_run_tests
ubuntu-32bit-static-pcre2:
@@ -54,10 +55,10 @@ jobs:
cmake -DFISH_USE_SYSTEM_PCRE2=OFF -DRust_CARGO_TARGET=i586-unknown-linux-gnu ..
- name: make
run: |
make VERBOSE=1
- name: make test
make -C build VERBOSE=1
- name: make fish_run_tests
run: |
make VERBOSE=1 test
make -C build VERBOSE=1 fish_run_tests
ubuntu-asan:
@@ -92,8 +93,8 @@ jobs:
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
- name: make
run: |
make VERBOSE=1
- name: make test
make -C build VERBOSE=1
- 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
@@ -107,7 +108,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 -C build 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
@@ -133,9 +134,9 @@ jobs:
# - name: make
# run: |
# make
# - name: make test
# - name: make fish_run_tests
# run: |
# make test
# make -C build fish_run_tests
macos:
@@ -160,7 +161,7 @@ jobs:
cmake -DWITH_GETTEXT=NO -DCMAKE_BUILD_TYPE=Debug ..
- name: make
run: |
make VERBOSE=1
- name: make test
make -C build VERBOSE=1
- name: make fish_run_tests
run: |
make VERBOSE=1 test
make -C build VERBOSE=1 fish_run_tests

190
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,190 @@
name: Create a new release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (tag name)'
required: true
type: string
permissions:
contents: write
jobs:
is-release-tag:
name: Pre-release checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Check if the pushed tag looks like a release
run: |
set -x
commit_subject=$(git log -1 --format=%s)
tag=$(git describe)
[ "$commit_subject" = "Release $tag" ]
source-tarball:
needs: [is-release-tag]
name: Create the source tarball
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tarball-name: ${{ steps.version.outputs.tarball-name }}
steps:
- uses: actions/checkout@v4
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install dependencies
run: sudo apt install cmake gettext ninja-build python3-pip python3-sphinx
- uses: ./.github/actions/install-sphinx-markdown-builder
- name: Create tarball
run: |
set -x
mkdir /tmp/fish-built
FISH_ARTEFACT_PATH=/tmp/fish-built ./build_tools/make_tarball.sh
relnotes=/tmp/fish-built/release-notes.md
# Need history since the last release (i.e. tag) for stats.
git fetch --tags
git fetch --unshallow
sh -x ./build_tools/release-notes.sh >"$relnotes"
# Delete title
sed -n 1p "$relnotes" | grep -q "^## fish .*"
sed -n 2p "$relnotes" | grep -q '^$'
sed -i 1,2d "$relnotes"
- name: Upload tarball artifact
uses: actions/upload-artifact@v4
with:
name: source-tarball
path: |
/tmp/fish-built/fish-${{ inputs.version }}.tar.xz
/tmp/fish-built/release-notes.md
if-no-files-found: error
packages-for-linux:
needs: [is-release-tag]
name: Build single-file fish for Linux (experimental)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install Rust Stable
uses: ./.github/actions/rust-toolchain@stable
with:
targets: x86_64-unknown-linux-musl,aarch64-unknown-linux-musl
- name: Install dependencies
run: sudo apt install crossbuild-essential-arm64 musl-tools python3-sphinx
- name: Build statically-linked executables
run: |
set -x
CFLAGS="-D_FORTIFY_SOURCE=2" \
CMAKE_WITH_GETTEXT=0 \
CC=aarch64-linux-gnu-gcc \
RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc -C link-arg=-lgcc -C link-arg=-D_FORTIFY_SOURCE=0" \
cargo build --release --target aarch64-unknown-linux-musl --bin fish
cargo build --release --target x86_64-unknown-linux-musl --bin fish
- name: Compress
run: |
set -x
for arch in x86_64 aarch64; do
tar -cazf fish-$(git describe)-linux-$arch.tar.xz \
-C target/$arch-unknown-linux-musl/release fish
done
- uses: actions/upload-artifact@v4
with:
name: Static builds for Linux
path: fish-${{ inputs.version }}-linux-*.tar.xz
if-no-files-found: error
create-draft-release:
needs:
- is-release-tag
- source-tarball
- packages-for-linux
name: Create release draft
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: /tmp/artifacts
- name: List artifacts
run: find /tmp/artifacts -type f
- name: Create draft release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: fish ${{ inputs.version }}
body_path: /tmp/artifacts/release-notes.md
draft: true
files: |
/tmp/artifacts/fish-${{ inputs.version }}.tar.xz
/tmp/artifacts/fish-${{ inputs.version }}-linux-*.tar.xz
packages-for-macos:
needs: [is-release-tag, create-draft-release]
name: Build packages for macOS
runs-on: macos-latest
environment: macos-codesign
steps:
- uses: actions/checkout@v4
with:
# Workaround for https://github.com/actions/checkout/issues/882
ref: ${{ inputs.version }}
- name: Install Rust
uses: ./.github/actions/rust-toolchain@oldest-supported
with:
targets: x86_64-apple-darwin
- name: Install Rust Stable
uses: ./.github/actions/rust-toolchain@stable
with:
targets: aarch64-apple-darwin
- name: Build and codesign
run: |
die() { echo >&2 "$*"; exit 1; }
[ -n "$MAC_CODESIGN_APP_P12_BASE64" ] || die "Missing MAC_CODESIGN_APP_P12_BASE64"
[ -n "$MAC_CODESIGN_INSTALLER_P12_BASE64" ] || die "Missing MAC_CODESIGN_INSTALLER_P12_BASE64"
[ -n "$MAC_CODESIGN_PASSWORD" ] || die "Missing MAC_CODESIGN_PASSWORD"
[ -n "$MACOS_NOTARIZE_JSON" ] || die "Missing MACOS_NOTARIZE_JSON"
set -x
export FISH_ARTEFACT_PATH=/tmp/fish-built
# macOS runners keep having issues loading Cargo.toml dependencies from git (GitHub) instead
# of crates.io, so give this a try. It's also sometimes significantly faster on all platforms.
export CARGO_NET_GIT_FETCH_WITH_CLI=true
cargo install apple-codesign
mkdir -p "$FISH_ARTEFACT_PATH"
echo "$MAC_CODESIGN_APP_P12_BASE64" | base64 --decode >/tmp/app.p12
echo "$MAC_CODESIGN_INSTALLER_P12_BASE64" | base64 --decode >/tmp/installer.p12
echo "$MACOS_NOTARIZE_JSON" >/tmp/notarize.json
./build_tools/make_macos_pkg.sh -s -f /tmp/app.p12 \
-i /tmp/installer.p12 -p "$MAC_CODESIGN_PASSWORD" \
-n -j /tmp/notarize.json
version=$(git describe)
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.app.zip" ]
[ -f "${FISH_ARTEFACT_PATH}/fish-$version.pkg" ]
rm /tmp/installer.p12 /tmp/app.p12 /tmp/notarize.json
env:
MAC_CODESIGN_APP_P12_BASE64: ${{ secrets.MAC_CODESIGN_APP_P12_BASE64 }}
MAC_CODESIGN_INSTALLER_P12_BASE64: ${{ secrets.MAC_CODESIGN_INSTALLER_P12_BASE64 }}
MAC_CODESIGN_PASSWORD: ${{ secrets.MAC_CODESIGN_PASSWORD }}
MACOS_NOTARIZE_JSON: ${{ secrets.MACOS_NOTARIZE_JSON }}
- name: Add macOS packages to the release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(git describe)
gh release upload $version \
/tmp/fish-built/fish-$version.app.zip \
/tmp/fish-built/fish-$version.pkg

View File

@@ -31,3 +31,11 @@ jobs:
# This used to have --deny=warnings, but that turns rust release day
# into automatic CI failure day, so we don't do that.
run: cargo clippy --workspace --all-targets
# Disabling for now because it also checks "advisories",
# making CI fail for reasons unrelated to the patch
# cargo-deny:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: EmbarkStudios/cargo-deny-action@v1

View File

@@ -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

View File

@@ -1,27 +1,110 @@
fish 3.8.0 (released ???)
===================================
fish 4.0.9 (released September 27, 2025)
========================================
.. ignore: 9439 9440 9442 9452 9469 9480 9482 9520 9536 9541 9544 9559 9561 9576 9575
9568 9588 9556 9563 9567 9585 9591 9593 9594 9603 9600 9599 9592 9612 9613 9619 9630 9638 9625 9654 9637 9673 9666 9626 9688 9725 9636 9735
9542 9332 9566 9573 9579 9586 9589 9607 9608 9615 9616 9621 9641 9642 9643 9653 9658 9661
9671 9726 9729 9739 9745 9746 9754 9765 9767 9768 9771 9777 9778 9786 9816 9818 9821 9839
9845 9864 9916 9923 9962 9963 9990 9991 10121 10179 9856 9859 9861 9863 9867 9869 9874 9879
9881 9894 9896 9902 9873 10228 9925 9928 10145 10146 10161 10173 10195 10220 10222 10288
10342 10358 9927 9930 9947 9948 9950 9952 9966 9968 9980 9981 9984 10040 10061 10101 10090
10102 10108 10114 10115 10128 10129 10143 10174 10175 10180 10182 10184 10185 10186 10188
10198 10200 10201 10204 10210 10214 10219 10223 10227 10232 10235 10237 10243 10244 10245
10246 10251 10260 10267 10281 10347 10366 10368 10370 10371 10263 10270 10272 10276 10277
10278 10279 10291 10293 10305 10306 10309 10316 10317 10327 10328 10329 10330 10336 10340
10345 10346 10353 10354 10356 10372 10373 3299 10360 10359
2037 2037 3017 3018 3162 4865 5284 5991 6981 6996 7172 9751 9893 10241 10254 10268 10290 10307
10308 10321 10338 10348 10349 10355 10357 10379 10381 10388 10389 10390 10395 10398 10400 10403
10404 10407 10408 10409 10411 10412 10417 10418 10427 10429 10438 10439 10440 10441 10442 10443
10445 10448 10450 10451 10456 10457 10462 10463 10464 10466 10467 10474 10481 10490 10492 10494
10499 10503 10505 10508 10509 10510 10511 10512 10513 10518 10547 10719
This release fixes:
The entirety of fish's C++ code has been ported 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.
- a regression in 4.0.6 causing shifted keys to not be inserted on some terminals (:issue:`11813`).
- a regression in 4.0.6 causing the build to fail on systems where ``char`` is unsigned (:issue:`11804`).
- a regression in 4.0.0 causing a crash on an invalid :doc:`bg <cmds/bg>` invocation.
--------------
fish 4.0.8 (released September 18, 2025)
========================================
This release fixes a regression in 4.0.6 that caused user bindings to be shadowed by either fish's or a plugin's bindings (:issue:`11803`).
--------------
fish 4.0.6 (released September 12, 2025)
========================================
This release of fish fixes a number of issues identified in fish 4.0.2:
- fish now properly inherits $PATH under Windows WSL2 (:issue:`11354`).
- Remote filesystems are detected properly again on non-Linux systems.
- the :doc:`printf <cmds/printf>` builtin no longer miscalculates width of multi-byte characters (:issue:`11412`).
- For many years, fish has been "relocatable" -- it was possible to move the entire ``CMAKE_INSTALL_PREFIX`` and fish would use paths relative to its binary.
Only gettext locale paths were still determined purely at compile time, which has been fixed.
- the :doc:`commandline <cmds/commandline>` builtin failed to print the commandline set by a ``commandline -C`` invocation, which broke some completion scripts.
This has been corrected (:issue:`11423`).
- To work around terminals that fail to parse Operating System Command (OSC) sequences, a temporary feature flag has been added.
It allows you to disable prompt marking (OSC 133) by running (once) ``set -Ua fish_features no-mark-prompt`` and restarting fish (:issue:`11749`).
- The routines to save history and universal variables have seen some robustness improvements.
- builtin :doc:`status current-command <cmds/status>` no longer prints a trailing blank line.
- A crash displaying multi-line quoted command substitutions has been fixed (:issue:`11444`).
- Commands like ``set fish_complete_path ...`` accidentally disabled completion autoloading, which has been corrected.
- ``nmcli`` completions have been fixed to query network information dynamically instead of only when completing the first time.
- Git completions no longer print an error when no `git-foo` executable is in :envvar:`PATH`.
- Custom completions like ``complete foo -l long -xa ...`` that use the output of ``commandline -t``.
on a command-line like ``foo --long=`` have been invalidated by a change in 4.0; the completion scripts have been adjusted accordingly (:issue:`11508`).
- Some completions were misinterpreted, which caused garbage to be displayed in the completion list. This has been fixed.
- fish no longer interprets invalid control sequences from the terminal as if they were :kbd:`alt-[` or :kbd:`alt-o` key strokes.
- :doc:`bind <cmds/bind>` has been taught about the :kbd:`printscreen` and :kbd:`menu` keys.
- :kbd:`alt-delete` now deletes the word right of the cursor.
- :kbd:`ctrl-alt-h` erases the last word again (:issue:`11548`).
- :kbd:`alt-left` :kbd:`alt-right` were misinterpreted because they send unexpected sequences on some terminals; a workaround has been added. (:issue:`11479`).
- Key bindings like ``bind shift-A`` are no longer accepted; use ``bind shift-a`` or ``bind A``.
- Key bindings like ``bind shift-a`` take precedence over ``bind A`` when the key event included the shift modifier.
- Bindings using shift with non-ASCII letters (such as :kbd:`ctrl-shift-ä`) are now supported.
- Bindings with modifiers such as ``bind ctrl-w`` work again on non-Latin keyboard layouts such as a Russian one.
This is implemented by allowing key events such as :kbd:`ctrl-ц` to match bindings of the corresponding Latin key, using the kitty keyboard protocol's base layout key (:issue:`11520`).
- Vi mode: The cursor position after pasting via :kbd:`p` has been corrected.
- Vi mode: Trying to replace the last character via :kbd:`r` no longer replaces the last-but-one character (:issue:`11484`),
fish 4.0.2 (released April 20, 2025)
====================================
This release of fish fixes a number of issues identified in fish 4.0.1:
- Completions are quoted, rather than backslash-escaped, only if the completion is unambiguous. Continuing to edit the token is therefore easier (:issue:`11271`). This changes the behavior introduced in 4.0.0 where all completions were quoted.
- The warning when the terminfo database can't be found has been downgraded to a log message. fish will act as if the terminal behaves like xterm-256color, which is correct for the vast majority of cases (:issue:`11277`, :issue:`11290`).
- Key combinations using the super (Windows/command) key can now (actually) be bound using the :kbd:`super-` prefix (:issue:`11217`). This was listed in the release notes for 4.0.1 but did not work correctly.
- :doc:`function <cmds/function>` is stricter about argument parsing, rather than allowing additional parameters to be silently ignored (:issue:`11295`).
- Using parentheses in the :doc:`test <cmds/test>` builtin works correctly, following a regression in 4.0.0 where they were not recognized (:issue:`11387`).
- :kbd:`delete` in Vi mode when Num Lock is active will work correctly (:issue:`11303`).
- Abbreviations cannot alter the command-line contents, preventing a crash (:issue:`11324`).
- Improvements to various completions, including new completions for ``wl-randr`` (:issue:`11301`), performance improvements for ``cargo`` completions by avoiding network requests (:issue:`11347`), and other improvements for ``btrfs`` (:issue:`11320`), ``cryptsetup`` (:issue:`11315`), ``git`` (:issue:`11319`, :issue:`11322`, :issue:`11323`), ``jj`` (:issue:`11046`), and ``systemd-analyze`` (:issue:`11314`).
- The Mercurial (``hg``) prompt can handle working directories that contain an embedded newline, rather than producing errors (:issue:`11348`).
- A number of crashes have been fixed. Triggers include prompts containing backspace characters (:issue:`11280`), history pager search (:issue:`11355`), invalid UTF-8 in :doc:`read <cmds/read>` (:issue:`11383`), and the ``kill-selection`` binding (:issue:`11367`).
- A race condition in the test suite has been fixed (:issue:`11254`), and a test for fish versioning relaxed to support downstream distributors' modifications (:issue:`11173`).
- Small improvements to the documentation (:issue:`11264`, :issue:`11329`, :issue:`11361`).
--------------
fish 4.0.1 (released March 12, 2025)
====================================
This release of fish includes the following improvements compared to fish 4.0.0:
- Key combinations using the super (Windows/command) key can be bound using the :kbd:`super-` prefix (:issue:`11217`).
- Konsole's menu shows the "Open folder with" option again (:issue:`11198`).
- ``$fish_color_search_match`` will now only be applied to the foreground color if it has an explicit foreground. For example, this allows setting::
set -g fish_color_search_match --reverse
- Cursor shape commands (``\e[2 q``) are no longer sent in non-interactive shells or in redirections (:issue:`11255`).
- :doc:`status <cmds/status>` gained a ``is-interactive-read`` subcommand, to check whether the script is being called from an interactive :doc:`read <cmds/read>` invocation.
- fish's background tasks are now started in a way that avoids an error on macOS Terminal.app (:issue:`11181`).
- Using key combinations within qemu should work correctly.
- Prompts containing control characters no longer cause incorrect display of command lines (:issue:`11252`).
- Cancelling the command-line in Vi mode displays correctly again (:issue:`11261`).
- The acidhub prompt properly displays the git branch again (:issue:`11179`).
- Completions for ``wine`` correctly include files again (:issue:`11202`).
- On macOS, paths from ``/etc/paths`` and ``/etc/manpaths`` containing colons are handled correctly (:issue:`10684`). This functionality was included in the 4.0.0 release notes but was missing from the source code.
- The XTerm ``modifyOtherKeys`` keyboard encoding is no longer used under WezTerm, as it does not work correctly in all layouts (:issue:`11204`).
- kbd:`option-left` and other similar keys should now work in iTerm versions before 3.5.12; the kitty keyboard protocol is now disabled on these versions (:issue:`11192`).
- The kitty keyboard protocol is no longer used under Midnight Commander, as it does not work correctly (:issue:`10640`).
- fish now sends the commandline along with the OSC 133 semantic prompt command start sequence. This fixes a test in the kitty terminal (:issue:`11203`).
- Git completions for third-party commands like "git-absorb" are completed correctly again (:issue:`11205`).
- Completions for ``diskutil`` no longer produce an error (:issue:`11201`).
- The output of certain error messages no longer prints newlines to standard output (:issue:`11248`).
- A number of crashes have been fixed, including file names longer than 255 bytes (:issue:`11221`), using fish on a btrfs filesystem (:issue:`11219`), history files that do not have the expected format (:issue:`11236`), and pasting into an empty command line (:issue:`11256`).
--------------
fish 4.0.0 (released February 27, 2025)
=======================================
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
--------------------------------------
@@ -29,36 +112,33 @@ 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.
- Fish no longer supports terminals that fail to ignore OSC or CSI sequences they don't recognize.
The typical problem is that terminals echo the raw sequences sent by fish instead of silently ignoring them.
- :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).
- ``random`` now uses a different random number generator and so the values you get even with the same seed have changed.
Notably, it will now work much more sensibly with very small seeds.
- :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`).
- Variables in command position that expand to a subcommand keyword are now forbidden to fix a likely user error.
For example, ``set editor command emacs; $editor`` is no longer allowed (:issue:`10249`).
- ``functions --handlers`` will now list handlers in a different order.
Now it is definition order, first to last, where before it was last to first.
This was never specifically defined, and we recommend not relying on a specific order (:issue:`9944`).
- The ``qmark-noglob`` feature flag, introduced in fish 3.0, is now turned on by default. That means ``?`` will no longer act as a single-character glob.
- The ``qmark-noglob`` feature, introduced in fish 3.0, is enabled by default. That means ``?`` will no longer act as a single-character glob.
You can, for the time being, turn it back on by adding ``no-qmark-noglob`` to :envvar:`fish_features` and restarting fish::
set -Ua fish_features no-qmark-noglob
The flag will eventually be made read-only, making it impossible to turn off.
- 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 WSLv1, 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/exec (after the usual prompt to close or disown them) to work around a WSL 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.
- 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.
Notable improvements and fixes
------------------------------
.. _changelog-new-bindings:
- fish now requests XTerm's ``modifyOtherKeys`` keyboard encoding and `kitty keyboard protocol's <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_ progressive enhancements for a CSI u encoding.
Depending on terminal support, this allows to bind a lot more key combinations, including arbitrary combinations of modifiers :kbd:`ctrl`, :kbd:`alt` and :kbd:`shift`,
and to distinguish e.g. :kbd:`ctrl-i` from :kbd:`tab`.
- fish now requests XTerm's ``modifyOtherKeys`` keyboard encoding and `kitty keyboard protocol's <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_ progressive enhancements (:issue:`10359`).
Depending on terminal support, this allows to binding more key combinations, including arbitrary combinations of modifiers :kbd:`ctrl`, :kbd:`alt` and :kbd:`shift`, and distinguishing (for example) :kbd:`ctrl-i` from :kbd:`tab`.
Additionally, builtin ``bind`` no longer requires specifying keys as byte sequences but learned a human-readable syntax.
Additionally, ``bind`` now supports a human-readable syntax in addition to byte sequences.
This includes modifier names, and names for keys like :kbd:`enter` and :kbd:`backspace`.
For example
@@ -66,181 +146,224 @@ 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::
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/``. 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 ``bind ctrl-c __fish_cancel_commandline`` (: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.
- 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.
- 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^'
will expand "back" to ``reset --hard HEAD^``, but only when the command is ``git`` (:issue:`9411`, :issue:`10452`).
will expand "back" to ``reset --hard HEAD^``, but only when the command is ``git`` (:issue:`9411`).
Deprecations and removed features
---------------------------------
- ``commandline --tokenize`` (short option ``-o``) has been deprecated in favor of ``commandline --tokens-expanded`` (short option ``-x``) which expands variables and other shell syntax, removing the need to use "eval" in completion scripts (:issue:`10212`).
- ``commandline --tokenize`` (short option ``-o``) has been deprecated in favor of ``commandline --tokens-expanded`` (short option ``-x``) which expands variables and other shell syntax, removing the need to use :doc:`eval <cmds/eval>` in completion scripts (:issue:`10212`).
- Two new feature flags:
- ``remove-percent-self`` (see ``status features``) disables PID expansion of ``%self`` which has been supplanted by ``$fish_pid`` (:issue:`10262`).
- ``test-require-arg``, will disable ``test``'s one-argument mode. That means ``test -n`` without an additional argument will return false, ``test -z`` will keep returning true. Any other option without an argument, anything that is not an option and no argument will be an error. This also goes for ``[``, test's alternate name.
- ``remove-percent-self`` (see ``status features``) disables PID expansion of ``%self``, which has been supplanted by ``$fish_pid`` (:issue:`10262`).
- ``test-require-arg`` disables ``test``'s one-argument mode. That means ``test -n`` without an additional argument will return false, ``test -z`` will keep returning true. Any other option without an argument, anything that is not an option and no argument will be an error. This also goes for ``[``, test's alternate name.
This is a frequent source of confusion and so we are breaking with POSIX explicitly in this regard.
In addition to the feature flag, there is a debug category "deprecated-test". Running fish with ``fish -d deprecated-test`` will show warnings whenever a ``test`` invocation that would change is used. (:issue:`10365`).
as always these can be enabled with::
These can be enabled with::
set -Ua fish_features remove-percent-self test-require-arg
They are available as a preview now, it is our intention to enable them by default in future, and after that eventually make them read-only.
- Specifying key names as terminfo name (``bind -k``) is deprecated and may be removed in a future version.
We intend to enable them by default in future, and after that eventually make them read-only.
- Specifying key names as terminfo names (using the ``bind -k`` syntax) is deprecated and may be removed in a future version.
- When a terminal pastes text into fish using bracketed paste, fish used to switch to a special ``paste`` bind mode.
This bind mode has been removed. The behavior on paste is currently not meant to be configurable.
- When an interactive fish is stopped or terminated by a signal that cannot be caught (SIGSTOP or SIGKILL), it may leave the terminal in a state where keypresses with modifiers are sent as CSI u sequences instead of traditional control characters or escape sequences (that are recognized by bash/readline).
This bind mode has been removed. The behavior on paste is no longer configurable.
- When an interactive fish is stopped or terminated by a signal that cannot be caught (SIGSTOP or SIGKILL), it may leave the terminal in a state where keypresses with modifiers are sent as CSI u sequences, instead of traditional control characters or escape sequences that are recognized by Readline and compatible programs, such as bash and python.
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
----------------------
- for-loops will no longer remember local variables from the previous iteration (:issue:`10525`).
- Add ``history append`` subcommand to append a command to the history without executing it (:issue:`4506`).
- A new redirection: ``<? /path/to/file`` will try opening the file as input, and if it doesn't succeed silently use /dev/null instead.
- ``for`` loops will no longer remember local variables from the previous iteration (:issue:`10525`).
- A new ``history append`` subcommand appends a command to the history, without executing it (:issue:`4506`).
- A new redirection: ``<? /path/to/file`` will try opening the file as input, and if it doesn't succeed silently uses ``/dev/null`` instead.
This can help with checks like ``test -f /path/to/file; and string replace foo bar < /path/to/file``. (:issue:`10387`)
- New option ``commandline --tokens-raw`` prints a list of tokens without any unescaping (:issue:`10212`).
- New option ``commandline --showing-suggestion`` to check whether an autosuggestion is currently displayed (:issue:`10586`).
- ``functions`` and ``type`` now show where a function was copied and where it originally was instead of saying ``Defined interactively`` (:issue:`6575`).
- Stack trace now shows line numbers for copied functions.
- A new option ``commandline --tokens-raw`` prints a list of tokens without any unescaping (:issue:`10212`).
- A new option ``commandline --showing-suggestion`` tests whether an autosuggestion is currently displayed (:issue:`10586`).
- ``functions`` and ``type`` now show that a function was copied and its source, rather than solely ``Defined interactively`` (:issue:`6575`).
- Stack trace now shows line numbers for copied functions (:issue:`6575`).
- ``foo & && bar`` is now a syntax error, like in other shells (:issue:`9911`).
- ``if -e foo; end`` now prints a more accurate error (:issue:`10000`).
- Variables in command position that expand to a subcommand keyword are now forbidden to fix a likely user error.
For example ``set editor command emacs; $editor`` is no longer allowed (:issue:`10249`).
- ``cd`` into a directory that is not readable but accessible (permissions ``--x``) is now possible (:issue:`10432`).
- An integer overflow in ``string repeat`` leading to a near-infinite loop has been fixed (:issue:`9899`).
- ``string shorten`` behaves better in the presence of non-printable characters, including fixing an integer overflow that shortened strings more than intended. (:issue:`9854`)
- ``string pad`` no longer allows non-printable characters as padding. (:issue:`9854`)
- ``string repeat`` now allows omission of ``-n`` when the first argument is an integer. (:issue:`10282`)
- ``string shorten`` behaves better in the presence of non-printable characters, including fixing an integer overflow that shortened strings more than intended (:issue:`9854`).
- ``string pad`` no longer allows non-printable characters as padding (:issue:`9854`).
- ``string repeat`` now allows omission of ``-n`` when the first argument is an integer (:issue:`10282`).
- ``string match`` and ``replace`` have a new ``--max-matches`` option to return as soon as the specified number of matches have been identified, which can improve performance in scripts (:issue:`10587`).
- ``functions --handlers-type caller-exit`` once again lists functions defined as ``function --on-job-exit caller``, rather than them being listed by ``functions --handlers-type process-exit``.
- ``set`` has a new ``--no-event`` flag, to set or erase variables without triggering a variable event. This is useful e.g. to change a variable in an event handler. (:issue:`10480`)
- Commas in command substitution output are no longer used as separators in brace expansion, preventing a surprising expansion in rare cases (:issue:`5048`).
- Universal variables can now store strings containing invalid Unicode codepoints (:issue:`10313`).
- ``path basename`` now takes a ``-E`` option that causes it to return the basename (i.e. "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`).
- ``math`` now adds ``--scale-mode`` parameter. You can choose between ``truncate``, ``round``, ``floor``, ``ceiling`` as you wish (default value is ``truncate``). (:issue:`9117`).
- A new ``set --no-event`` option sets or erases variables without triggering a variable event. This can be useful to change a variable in an event handler (:issue:`10480`).
- Commas in command substitution output are no longer used as separators in brace expansion, preventing a surprising expansion in some cases (:issue:`5048`).
- Universal variables can now store strings containing invalid UTF-8 (:issue:`10313`).
- 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`).
- Tilde expansion in braces (that is, ``{~,}``) works correctly (:issue:`10610`).
Interactive improvements
------------------------
- When using :kbd:`ctrl-x` on Wayland in the VSCode terminal, the clipboard is no longer cleared on :kbd:`ctrl-c`.
- Command-specific tab completions may now offer results whose first character is a period. For example, it is now possible to tab-complete ``git add`` for files with leading periods. The default file completions hide these files, unless the token itself has a leading period (:issue:`3707`).
- 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.
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 matches Bash's behavior.
- Autosuggestions were sometimes not shown after recalling a line from history, which has been fixed (:issue:`10287`).
- Up-arrow search matches -- which are highlighted in reverse video -- are no longer syntax-highlighted, to fix bad contrast with the search match highlighting.
- Up-arrow search matches -- which are highlighted in reverse colors -- are no longer syntax-highlighted, to fix bad contrast with the search match highlighting.
- Command abbreviations (those with ``--position command`` or without a ``--position``) now also expand after decorators like ``command`` (:issue:`10396`).
- Abbreviations now expand after process separators like ``;`` and ``|``. This fixes a regression in version 3.6 (:issue:`9730`).
- When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, same as in the interactive command line editor (:issue:`8603`).
- When exporting interactively defined functions (using ``type``, ``functions`` or ``funcsave``) the function body is now indented, to match the interactive command line editor (:issue:`8603`).
- :kbd:`ctrl-x` (``fish_clipboard_copy``) on multiline commands now includes indentation (:issue:`10437`).
- :kbd:`ctrl-v` (``fish_clipboard_paste``) now strips ASCII control characters from the pasted text.
This is consistent with normal keyboard input (:issue:`5274`).
- When a command like ``fg %2`` fails to find the given job, it no longer behaves as if no job spec was given (:issue:`9835`).
- Redirection in command position like ``>echo`` is now highlighted as error (:issue:`8877`).
- ``fish_vi_cursor`` now works properly inside the prompt created by builtin ``read`` (:issue:`10088`).
- fish no longer fails to open a fifo if interrupted by a terminal resize signal (:issue:`10250`).
- fish no longer fails to open a FIFO if interrupted by a terminal resize signal (:issue:`10250`).
- ``read --help`` and friends no longer ignore redirections. This fixes a regression in version 3.1 (:issue:`10274`).
- 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 commandline), in an effort to be clearer about what it does (:issue:`10532`).
- ``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`).
- fish's default colorscheme 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 colorscheme will not be upgraded for existing installs. If you want, you should select it again via ``fish_config``.
- ``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`).
- 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`).
- 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
^^^^^^^^^^^^^^^^^^^^^^^^
- When the cursor is on a command that resolves to an executable script, :kbd:`alt-o` will now open that script in your editor (:issue:`10266`).
- 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.
Same for autosuggestions.
- 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-delete` now deletes the argument (which may contain quoted spaces) right of the cursor.
- Some improvements to the :kbd:`alt-e` binding which edits the commandline in an external editor:
- 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. This has been extended by also resolving aliases. For example use ``complete --wraps my-vim vim`` to synchronize cursors when ``EDITOR=my-vim``.
- 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``.
- Multiline commands are indented before being sent to the editor, which matches how they are displayed in fish.
- The ``*-path-component`` bindings like ``backward-kill-path-component`` now treat ``#`` as part of a path component (:issue:`10271`).
- The ``...-path-component`` bindings, like ``backward-kill-path-component``, now treat ``#`` as part of a path component (:issue:`10271`).
- Bindings like :kbd:`alt-l` that print output in between prompts now work correctly with multiline commandlines.
- :kbd:`ctrl-c` no longer cancels builtin ``read``.
- :kbd:`alt-d` on an empty command line lists the directory history again. This restores the behavior of version 2.1.
- ``history-prefix-search-{backward,forward}`` now maintain the cursor position instead of moving the cursor to the end of the command line (:issue:`10430`).
- The :kbd:`E` binding in vi mode now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`).
- The following keys have refined behavior if the terminal supports `disambiguating them <https://sw.kovidgoyal.net/kitty/keyboard-protocol/>`_:
- ``history-prefix-search-backward`` and ``-forward`` now maintain the cursor position, instead of moving the cursor to the end of the command line (:issue:`10430`).
- The following keys have refined behavior if the terminal supports :ref:`the new keyboard encodings <changelog-new-bindings>`:
- :kbd:`shift-enter` now inserts a newline instead of executing the command line.
- :kbd:`ctrl-backspace` now deletes the last word instead of only one character.
- :kbd:`ctrl-backspace` now deletes the last word instead of only one character (:issue:`10741`).
- :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`).
- The ``accept-autosuggestion`` special input function now returns false when there was nothing to accept.
- ``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.
- Insert-mode :kbd:`ctrl-n` accepts autosuggestions (:issue:`10339`).
- New default cursor shapes for insert and replace mode.
- :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.
- 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`).
- The :kbd:`E` binding now correctly handles the last character of the word, by jumping to the next word (:issue:`9700`).
Completions
^^^^^^^^^^^
- Command-specific tab completions may now offer results whose first character is a period. For example, it is now possible to tab-complete ``git add`` for files with leading periods. The default file completions hide these files, unless the token itself has a leading period (:issue:`3707`).
- 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`).
- Normally, file name completions start after the last ``:`` or ``=`` in a token.
This helps commands like ``rsync --files-from=``.
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.
- 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`).
Improved terminal support
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fish now marks the prompt and command-output regions (via OSC 133) to enable terminal shell integration (:issue:`10352`).
- fish now marks the prompt and command-output regions (via OSC 133) to enable terminal shell integration (:issue:`10352`).
Shell integration shortcuts can scroll to the next/previous prompt or show the last command output in a pager.
- Fish now reports the working directory (via OSC 7) unconditionally instead of only for some terminals (:issue:`9955`).
- Fish now sets the terminal window title (via OSC 0) unconditionally instead of only for some terminals (:issue:`10037`).
- fish now reports the working directory (via OSC 7) unconditionally instead of only for some terminals (:issue:`9955`).
- fish now sets the terminal window title (via OSC 0) unconditionally instead of only for some terminals (:issue:`10037`).
- Focus reporting in tmux is no longer disabled on the first prompt.
- Focus reporting is now disabled during execution of bind commands (:issue:`6942`).
- ``fish_vi_cursor`` no longer attempts to detect if the terminal is capable, as we can no longer find terminals that aren't and the allowlist was hard to keep up-to-date. (:issue:`10693`)
- Focus reporting is now disabled during commands run inside key bindings (:issue:`6942`).
- Cursor changes are applied to all terminals that support them, and the list of specifically-supported terminals has been removed (:issue:`10693`).
- If it cannot find the terminfo entry given by :envvar:`TERM` environment variable, fish will now use an included ``xterm-256color`` definition to match the vast majority of current terminal emulators (:issue:`10905`). If you need to have a specific terminfo profile for your terminal's ``TERM`` variable, install it into the terminfo database.
- Further improvements to the correct display of prompts which fill the width of the terminal (:issue:`8164`).
Other improvements
------------------
- ``fish_indent`` will now collapse multiple successive empty lines into one (:issue:`10325`).
- ``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`).
- The HTML-based configuration UI (``fish_config``) now uses Alpine.js instead of AngularJS (:issue:`9554`).
- ``fish_config`` now also works in a Windows MSYS environment (:issue:`10111`).
- Performance and interactivity under WSLv1 and WSLv2 has been improved with a workaround for Windows-specific locations being appended to ``$PATH`` by default (:issue:`10506`).
- 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:
For distributors
----------------
Fish has been ported to Rust. That means the dependencies have changed.
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).
It now requires Rust 1.70 at least.
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`).
CMake remains for now because cargo is unable to install the many asset files that fish needs. The minimum required CMake version has increased to 3.19.
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.
Some smaller changes:
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 default build configuration has changed to "Debug".
Please pass ``-DCMAKE_BUILD_TYPE=Release`` if you want to build a package.
- Xcode support has been removed (:issue:`9924`).
- fish no longer links against the (n)curses library, opting to read the terminfo database via the terminfo crate.
This means hashed terminfo databases are no longer supported (from our research, they are basically unmaintained and unused).
When packaging fish, please add a dependency on the package containing your terminfo database instead of curses,
if such a package is required.
If it cannot find a terminfo database, fish will now fall back on an included ``xterm-256color`` definition (:issue:`10269`).
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>`_.
--------------

View File

@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
project(fish LANGUAGES C)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(DEFAULT_BUILD_TYPE "Debug")
set(DEFAULT_BUILD_TYPE "RelWithDebInfo")
# Generate Xcode schemas (but not for tests).
set(CMAKE_XCODE_GENERATE_SCHEME 1)
@@ -56,8 +56,9 @@ function(CREATE_TARGET target)
${Rust_CARGO}
build --bin ${target}
$<$<CONFIG:Release>:--release>
$<$<CONFIG:RelWithDebInfo>:--release>
$<$<CONFIG:RelWithDebInfo>:--profile=release-with-debug>
--target ${Rust_CARGO_TARGET}
--no-default-features
${CARGO_FLAGS}
${FEATURES_ARG}
&&

View File

@@ -42,8 +42,8 @@ Guidelines
In short:
- Be conservative in what you need (``C++11``, few dependencies)
- Use automated tools to help you (including ``make test``, ``build_tools/style.fish`` and ``make lint``)
- 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 fish_run_tests`` and ``build_tools/style.fish``)
Contributing completions
========================
@@ -101,7 +101,7 @@ To ensure your changes conform to the style rules run
before committing your change. That will run our autoformatters:
- ``git-clang-format`` for c++
- ``rustfmt`` for Rust
- ``fish_indent`` (shipped with fish) for fish script
- ``black`` for python
@@ -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 isnt necessary.
@@ -322,12 +322,12 @@ Setting Code Up For Translations
--------------------------------
All non-debug messages output for user consumption should be marked for
translation. In C++, this requires the use of the ``_`` (underscore)
macro:
translation. In Rust, this requires the use of the ``wgettext!`` or ``wgettext_fmt!``
macros:
::
streams.out.append_format(_(L"%ls: There are no jobs\n"), argv[0]);
streams.out.append(wgettext_fmt!("%ls: There are no jobs\n", argv[0]));
All messages in fish script must be enclosed in single or double quote
characters for our message extraction script to find them.

174
Cargo.lock generated
View File

@@ -20,6 +20,15 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "block-buffer"
version = "0.10.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
dependencies = [
"generic-array",
]
[[package]]
name = "cc"
version = "1.1.30"
@@ -43,6 +52,25 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
[[package]]
name = "cpufeatures"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0"
dependencies = [
"libc",
]
[[package]]
name = "crypto-common"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
dependencies = [
"generic-array",
"typenum",
]
[[package]]
name = "dashmap"
version = "5.5.3"
@@ -56,6 +84,16 @@ dependencies = [
"parking_lot_core",
]
[[package]]
name = "digest"
version = "0.10.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
dependencies = [
"block-buffer",
"crypto-common",
]
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -69,12 +107,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "fish"
version = "0.1.0"
version = "4.0.9"
dependencies = [
"bitflags",
"cc",
@@ -90,6 +128,7 @@ dependencies = [
"portable-atomic",
"rand",
"rsconf",
"rust-embed",
"serial_test",
"terminfo",
"widestring",
@@ -100,6 +139,8 @@ name = "fish-printf"
version = "0.2.1"
dependencies = [
"libc",
"unicode-segmentation",
"unicode-width",
"widestring",
]
@@ -115,6 +156,16 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2"
[[package]]
name = "generic-array"
version = "0.14.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
dependencies = [
"typenum",
"version_check",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
@@ -371,6 +422,49 @@ dependencies = [
"cc",
]
[[package]]
name = "rust-embed"
version = "8.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa66af4a4fdd5e7ebc276f115e895611a34739a9c1c01028383d612d550953c0"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
"walkdir",
]
[[package]]
name = "rust-embed-impl"
version = "8.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6125dbc8867951125eec87294137f4e9c2c96566e61bf72c45095a7c77761478"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn 2.0.79",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
version = "8.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e5347777e9aacb56039b0e1f28785929a8a3b709e87482e7442c72e7c12529d"
dependencies = [
"sha2",
"walkdir",
]
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
@@ -397,7 +491,18 @@ checksum = "079a83df15f85d89a68d64ae1238f142f172b1fa915d0d76b26a7cba1b659a69"
dependencies = [
"proc-macro2",
"quote",
"syn",
"syn 1.0.109",
]
[[package]]
name = "sha2"
version = "0.10.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
dependencies = [
"cfg-if",
"cpufeatures",
"digest",
]
[[package]]
@@ -429,6 +534,17 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "syn"
version = "2.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "terminfo"
version = "0.9.0"
@@ -441,18 +557,61 @@ dependencies = [
"phf_codegen",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-ident"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "unicode-segmentation"
version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
[[package]]
name = "unicode-width"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "walkdir"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
]
[[package]]
name = "widestring"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
[[package]]
name = "winapi-util"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
@@ -462,6 +621,15 @@ dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"

View File

@@ -10,9 +10,13 @@ edition = "2021"
overflow-checks = true
lto = true
[profile.release-with-debug]
inherits = "release"
debug = true
[package]
name = "fish"
version = "0.1.0"
version = "4.0.9"
edition.workspace = true
rust-version.workspace = true
default-run = "fish"
@@ -53,6 +57,7 @@ rand = { version = "0.8.5", default-features = false, features = ["small_rng"] }
widestring = "1.1.0"
# We need 0.9.0 specifically for some crash fixes.
terminfo = "0.9.0"
rust-embed = { version = "8.2.0", optional = true }
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
portable-atomic = { version = "1", default-features = false, features = [
@@ -83,8 +88,9 @@ name = "fish_key_reader"
path = "src/bin/fish_key_reader.rs"
[features]
default = []
default = ["installable"]
benchmark = []
installable = ["dep:rust-embed"]
# The following features are auto-detected by the build-script and should not be enabled manually.
asan = []
@@ -97,3 +103,4 @@ rust.unknown_lints = "allow"
rust.unstable_name_collisions = "allow"
clippy.manual_range_contains = "allow"
clippy.needless_return = "allow"
clippy.needless_lifetimes = "allow"

View File

@@ -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

View File

@@ -66,8 +66,7 @@ Windows
for Linux with the instructions for the appropriate distribution
listed above under “Packages for Linux”, or from source with the
instructions below.
- Fish can also be installed on all versions of Windows using
`Cygwin <https://cygwin.com/>`__ (from the **Shells** category).
- fish (4.0 on and onwards) cannot be installed in Cygwin, due to a lack of Rust support.
Building from source
~~~~~~~~~~~~~~~~~~~~
@@ -121,33 +120,27 @@ Building
Dependencies
~~~~~~~~~~~~
Compiling fish from a tarball requires:
- a C++11 compiler (g++ 4.8 or later, or clang 3.3 or later)
- CMake (version 3.5 or later)
- PCRE2 (headers and libraries) - optional, this will be downloaded if missing
- gettext (headers and libraries) - optional, for translation support
Sphinx is also optionally required to build the documentation from a
cloned git repository.
Additionally, running the test suite requires Python 3.5+ and the pexpect package.
Dependencies, git master
~~~~~~~~~~~~~~~~~~~~~~~~
Building from git master currently requires:
Compiling fish requires:
- Rust (version 1.70 or later)
- CMake (version 3.19 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
- an Internet connection, as other dependencies will be downloaded automatically
Sphinx is also optionally required to build the documentation from a
cloned git repository.
Building from source (all platforms) - Makefile generator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Additionally, running the full test suite requires Python 3, tmux, and the pexpect package.
Building from source with CMake
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Rather than building from source, consider using a packaged build for your platform. Using the
steps below makes fish difficult to uninstall or upgrade. Release packages are available from the
links above, and up-to-date `development builds of fish are available for many platforms
<https://github.com/fish-shell/fish-shell/wiki/Development-builds>`__
To install into ``/usr/local``, run:
@@ -155,35 +148,50 @@ To install into ``/usr/local``, run:
mkdir build; cd build
cmake ..
make
sudo make install
cmake --build .
sudo cmake --install .
The install directory can be changed using the
``-DCMAKE_INSTALL_PREFIX`` parameter for ``cmake``.
Build options
~~~~~~~~~~~~~
CMake Build options
~~~~~~~~~~~~~~~~~~~
In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), fish has some other options available to customize it.
In addition to the normal CMake build options (like ``CMAKE_INSTALL_PREFIX``), fish's CMake build has some other options available to customize it.
- BUILD_DOCS=ON|OFF - whether to build the documentation. This is automatically set to OFF when Sphinx isn't installed.
- INSTALL_DOCS=ON|OFF - whether to install the docs. This is automatically set to on when BUILD_DOCS is or prebuilt documentation is available (like when building in-tree from a tarball).
- FISH_USE_SYSTEM_PCRE2=ON|OFF - whether to use an installed pcre2. This is normally autodetected.
- MAC_CODESIGN_ID=String|OFF - the codesign ID to use on Mac, or "OFF" to disable codesigning.
- WITH_GETTEXT=ON|OFF - whether to build with gettext support for translations.
- extra_functionsdir, extra_completionsdir and extra_confdir - to compile in an additional directory to be searched for functions, completions and configuration snippets
Note that fish does *not* support static linking and will attempt to error out if it detects it.
Building fish as self-installable (experimental)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Help, it didnt build!
~~~~~~~~~~~~~~~~~~~~~~
You can also build fish as a self-installing binary.
On Debian or Ubuntu you want these packages:
This will include all the datafiles like the included functions or web configuration tool in the main ``fish`` binary.
::
On the first interactive run, and whenever it notices they are out of date, it will extract the datafiles to ~/.local/share/fish/install/ (currently, subject to change). You can do this manually by running ``fish --install``.
sudo apt install build-essential cmake libpcre2-dev gettext
To install fish as self-installable, just use ``cargo``, like::
On RedHat, CentOS, or Amazon EC2 everything should be preinstalled.
cargo install --path /path/to/fish # if you have a git clone
cargo install --git https://github.com/fish-shell/fish-shell --tag 4.0 # to build from git once 4.0 is released
cargo install --git https://github.com/fish-shell/fish-shell # to build the current development snapshot without cloning
This will place the binaries in ``~/.cargo/bin/``, but you can place them wherever you want.
This build won't have the HTML docs (``help`` will open the online version) or translations.
It will try to build the man pages with sphinx-build. If that is not available and you would like to include man pages, you need to install it and retrigger the build script, e.g. by setting FISH_BUILD_DOCS=1::
FISH_BUILD_DOCS=1 cargo install --path .
Setting it to "0" disables the inclusion of man pages.
You can also link this build statically (but not against glibc) and move it to other computers.
Contributing Changes to the Code
--------------------------------

156
build.rs
View File

@@ -29,13 +29,25 @@ 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
rsconf::set_env_value(
"FISH_BUILD_VERSION",
&get_version(&env::current_dir().unwrap()),
);
rsconf::set_env_value("FISH_BUILD_VERSION", version);
std::env::set_var("FISH_BUILD_VERSION", version);
#[cfg(feature = "installable")]
#[cfg(not(clippy))]
{
let cman = std::fs::canonicalize(env!("CARGO_MANIFEST_DIR")).unwrap();
let targetman = cman.as_path().join("target").join("man");
build_man(&targetman);
}
rsconf::rebuild_if_path_changed("src/libc.c");
cc::Build::new()
.file("src/libc.c")
@@ -215,7 +227,7 @@ fn has_small_stack(_: &Target) -> Result<bool, Box<dyn Error>> {
}
fn setup_paths() {
fn get_path(name: &str, default: &str, onvar: PathBuf) -> PathBuf {
fn get_path(name: &str, default: &str, onvar: &Path) -> PathBuf {
let mut var = PathBuf::from(env::var(name).unwrap_or(default.to_string()));
if var.is_relative() {
var = onvar.join(var);
@@ -223,30 +235,51 @@ fn get_path(name: &str, default: &str, onvar: PathBuf) -> PathBuf {
var
}
let prefix = PathBuf::from(env::var("PREFIX").unwrap_or("/usr/local".to_string()));
if prefix.is_relative() {
let (prefix_from_home, prefix) = if let Ok(pre) = env::var("PREFIX") {
(false, PathBuf::from(pre))
} else {
(true, PathBuf::from(".local/"))
};
// If someone gives us a $PREFIX, we need it to be absolute.
// Otherwise we would try to get it from $HOME and that won't really work.
if !prefix_from_home && prefix.is_relative() {
panic!("Can't have relative prefix");
}
rsconf::rebuild_if_env_changed("PREFIX");
rsconf::set_env_value("PREFIX", prefix.to_str().unwrap());
let datadir = get_path("DATADIR", "share/", prefix.clone());
let datadir = get_path("DATADIR", "share/", &prefix);
rsconf::set_env_value("DATADIR", datadir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DATADIR");
let bindir = get_path("BINDIR", "bin/", prefix.clone());
let datadir_subdir = if prefix_from_home {
"fish/install"
} else {
"fish"
};
rsconf::set_env_value("DATADIR_SUBDIR", datadir_subdir);
let bindir = get_path("BINDIR", "bin/", &prefix);
rsconf::set_env_value("BINDIR", bindir.to_str().unwrap());
rsconf::rebuild_if_env_changed("BINDIR");
let sysconfdir = get_path("SYSCONFDIR", "etc/", datadir.clone());
let sysconfdir = get_path(
"SYSCONFDIR",
// If we get our prefix from $HOME, we should use the system's /etc/
// ~/.local/share/etc/ makes no sense
if prefix_from_home { "/etc/" } else { "etc/" },
&datadir,
);
rsconf::set_env_value("SYSCONFDIR", sysconfdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("SYSCONFDIR");
let localedir = get_path("LOCALEDIR", "locale/", datadir.clone());
let localedir = get_path("LOCALEDIR", "locale/", &datadir);
rsconf::set_env_value("LOCALEDIR", localedir.to_str().unwrap());
rsconf::rebuild_if_env_changed("LOCALEDIR");
let docdir = get_path("DOCDIR", "doc/fish", datadir.clone());
let docdir = get_path("DOCDIR", "doc/fish", &datadir);
rsconf::set_env_value("DOCDIR", docdir.to_str().unwrap());
rsconf::rebuild_if_env_changed("DOCDIR");
}
@@ -259,7 +292,7 @@ fn get_version(src_dir: &Path) -> String {
return var;
}
let path = PathBuf::from(src_dir).join("version");
let path = src_dir.join("version");
if let Ok(strver) = read_to_string(path) {
return strver.to_string();
}
@@ -270,7 +303,7 @@ fn get_version(src_dir: &Path) -> String {
if !rev.is_empty() {
// If it contains a ".", we have a proper version like "3.7",
// or "23.2.1-1234-gfab1234"
if rev.contains(".") {
if rev.contains('.') {
return rev;
}
// If it doesn't, we probably got *just* the commit SHA,
@@ -283,7 +316,98 @@ fn get_version(src_dir: &Path) -> String {
return version + "-g" + &rev;
}
}
// TODO: Do we just use the cargo version here?
"unknown".to_string()
// git did not tell us a SHA either because it isn't installed,
// or because it refused (safe.directory applies to `git describe`!)
// So we read the SHA ourselves.
fn get_git_hash() -> Result<String, Box<dyn std::error::Error>> {
let gitdir = Path::new(env!("CARGO_MANIFEST_DIR")).join(".git");
// .git/HEAD contains ref: refs/heads/branch
let headpath = gitdir.join("HEAD");
let headstr = read_to_string(headpath)?;
let headref = headstr.split(' ').collect::<Vec<_>>()[1].trim();
// .git/refs/heads/branch contains the SHA
let refpath = gitdir.join(headref);
// Shorten to 9 characters (what git describe does currently)
let refstr = &read_to_string(refpath)?[0..9];
let refstr = refstr.trim();
let version = env!("CARGO_PKG_VERSION").to_owned();
Ok(version + "-g" + refstr)
}
get_git_hash().expect("Could not get a version. Either set $FISH_BUILD_VERSION or install git.")
}
#[cfg(feature = "installable")]
// disable clippy because otherwise it would panic without sphinx
#[cfg(not(clippy))]
fn build_man(build_dir: &Path) {
use std::process::Command;
let mandir = build_dir;
let sec1dir = mandir.join("man1");
let docsrc_path = std::fs::canonicalize(env!("CARGO_MANIFEST_DIR"))
.unwrap()
.as_path()
.join("doc_src");
let docsrc = docsrc_path.to_str().unwrap();
let args = &[
"-j",
"auto",
"-q",
"-b",
"man",
"-c",
docsrc,
// doctree path - put this *above* the man1 dir to exclude it.
// this is ~6M
"-d",
mandir.to_str().unwrap(),
docsrc,
sec1dir.to_str().unwrap(),
];
let _ = std::fs::create_dir_all(sec1dir.to_str().unwrap());
rsconf::rebuild_if_env_changed("FISH_BUILD_DOCS");
if env::var("FISH_BUILD_DOCS") == Ok("0".to_string()) {
println!("cargo:warning=Skipping man pages because $FISH_BUILD_DOCS is set to 0");
return;
}
// We run sphinx to build the man pages.
// Every error here is fatal so cargo doesn't cache the result
// - if we skipped the docs with sphinx not installed, installing it would not then build the docs.
// That means you need to explicitly set $FISH_BUILD_DOCS=0 (`FISH_BUILD_DOCS=0 cargo install --path .`),
// which is unfortunate - but the docs are pretty important because they're also used for --help.
match Command::new("sphinx-build").args(args).spawn() {
Err(x) if x.kind() == std::io::ErrorKind::NotFound => {
if env::var("FISH_BUILD_DOCS") == Ok("1".to_string()) {
panic!("Could not find sphinx-build to build man pages.\nInstall sphinx or disable building the docs by setting $FISH_BUILD_DOCS=0.");
}
println!("cargo:warning=Cannot find sphinx-build to build man pages.");
println!("cargo:warning=If you install it now you need to run `cargo clean` and rebuild, or set $FISH_BUILD_DOCS=1 explicitly.");
}
Err(x) => {
// Another error - permissions wrong etc
panic!("Error starting sphinx-build to build man pages: {:?}", x);
}
Ok(mut x) => match x.wait() {
Err(err) => {
panic!(
"Error waiting for sphinx-build to build man pages: {:?}",
err
);
}
Ok(out) => {
if out.success() {
// Success!
return;
} else {
panic!("sphinx-build failed to build the man pages.");
}
}
},
}
}

View File

@@ -53,16 +53,16 @@ fi
if test -r "$FBVF"
then
VC=$(grep -v '^#' "$FBVF" | tr -d '"' | sed -e 's/^FISH_BUILD_VERSION=//')
VC=$(cat "$FBVF")
else
VC="unset"
fi
# Maybe output the FBVF
# It looks like FISH_BUILD_VERSION="2.7.1-621-ga2f065e6"
# It looks like "2.7.1-621-ga2f065e6"
test "$VN" = "$VC" || {
echo >&2 "FISH_BUILD_VERSION=$VN"
echo "FISH_BUILD_VERSION=\"$VN\"" >"$FBVF"
echo >&2 "$VN"
echo "$VN" >"$FBVF"
}
# Output the fish-build-version-witness.txt

177
build_tools/make_macos_pkg.sh Executable file
View File

@@ -0,0 +1,177 @@
#!/usr/bin/env bash
# Script to produce an OS X installer .pkg and .app(.zip)
usage() {
echo "Build macOS packages, optionally signing and notarizing them."
echo "Usage: $0 options"
echo "Options:"
echo " -s Enables code signing"
echo " -f <APP_KEY.p12> Path to .p12 file for application signing"
echo " -i <INSTALLER_KEY.p12> Path to .p12 file for installer signing"
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
echo " -n Enables notarization. This will fail if code signing is not also enabled."
echo " -j <API_KEY.JSON> Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)"
echo
exit 1
}
set -x
set -e
SIGN=
NOTARIZE=
ARM64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=11.0'
X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.9'
# As of this writing, the most recent Rust release supports macOS back to 10.12.
# The first supported version of macOS on arm64 is 10.15, so any Rust is fine for arm64.
# We wish to support back to 10.9 on x86-64; the last version of Rust to support that is
# version 1.73.0.
RUST_VERSION_X86_64=1.70.0
while getopts "sf:i:p:e:nj:" opt; do
case $opt in
s) SIGN=1;;
f) P12_APP_FILE=$(realpath "$OPTARG");;
i) P12_INSTALL_FILE=$(realpath "$OPTARG");;
p) P12_PASSWORD="$OPTARG";;
e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");;
n) NOTARIZE=1;;
j) API_KEY_FILE=$(realpath "$OPTARG");;
\?) usage;;
esac
done
if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then
usage
fi
if [ -n "$NOTARIZE" ] && [ -z "$API_KEY_FILE" ]; then
usage
fi
VERSION=$(build_tools/git_version_gen.sh --stdout 2>/dev/null)
echo "Version is $VERSION"
PKGDIR=$(mktemp -d)
echo "$PKGDIR"
SRC_DIR=$PWD
OUTPUT_PATH=${FISH_ARTEFACT_PATH:-~/fish_built}
mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/intermediates" "$PKGDIR/dst"
# Build and install for arm64.
# Pass FISH_USE_SYSTEM_PCRE2=OFF because a system PCRE2 on macOS will not be signed by fish,
# and will probably not be built universal, so the package will fail to validate/run on other systems.
# Note CMAKE_OSX_ARCHITECTURES is still relevant for the Mac app.
{ cd "$PKGDIR/build_arm64" \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DWITH_GETTEXT=OFF \
-DRust_CARGO_TARGET=aarch64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF \
"$SRC_DIR" \
&& env $ARM64_DEPLOY_TARGET make VERBOSE=1 -j 12 \
&& env DESTDIR="$PKGDIR/root/" $ARM64_DEPLOY_TARGET make install;
}
# Build for x86-64 but do not install; instead we will make some fat binaries inside the root.
# Set RUST_VERSION_X86_64 to the last version of Rust that supports macOS 10.9.
{ cd "$PKGDIR/build_x86_64" \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DWITH_GETTEXT=OFF \
-DRust_TOOLCHAIN="$RUST_VERSION_X86_64" \
-DRust_CARGO_TARGET=x86_64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF "$SRC_DIR" \
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
# Fatten them up.
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
chmod 755 "$FILE"
done
if test -n "$SIGN"; then
echo "Signing executables"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
(set +x; rcodesign sign "${ARGS[@]}" "$FILE")
done
fi
pkgbuild --scripts "$SRC_DIR/build_tools/osx_package_scripts" --root "$PKGDIR/root/" --identifier 'com.ridiculousfish.fish-shell-pkg' --version "$VERSION" "$PKGDIR/intermediates/fish.pkg"
productbuild --package-path "$PKGDIR/intermediates" --distribution "$SRC_DIR/build_tools/osx_distribution.xml" --resources "$SRC_DIR/build_tools/osx_package_resources/" "$OUTPUT_PATH/fish-$VERSION.pkg"
if test -n "$SIGN"; then
echo "Signing installer"
ARGS=(
--p12-file "$P12_INSTALL_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
(set +x; rcodesign sign "${ARGS[@]}" "$OUTPUT_PATH/fish-$VERSION.pkg")
fi
# Make the app
(cd "$PKGDIR/build_arm64" && env $ARM64_DEPLOY_TARGET make -j 12 fish_macapp)
(cd "$PKGDIR/build_x86_64" && env $X86_64_DEPLOY_TARGET make -j 12 fish_macapp)
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtesy of CMake.
cd "$PKGDIR/build_arm64"
for FILE in fish.app/Contents/Resources/base/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
# macho-universal-create screws up the permissions.
chmod 755 "$FILE"
done
if test -n "$SIGN"; then
echo "Signing app"
ARGS=(
--p12-file "$P12_APP_FILE"
--p12-password "$P12_PASSWORD"
--code-signature-flags runtime
--for-notarization
)
if [ -n "$ENTITLEMENTS_FILE" ]; then
ARGS+=(--entitlements-xml-file "$ENTITLEMENTS_FILE")
fi
(set +x; rcodesign sign "${ARGS[@]}" "fish.app")
fi
cp -R "fish.app" "$OUTPUT_PATH/fish-$VERSION.app"
cd "$OUTPUT_PATH"
# Maybe notarize.
if test -n "$NOTARIZE"; then
echo "Notarizing"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.pkg"
rcodesign notarize --staple --wait --max-wait-seconds 1800 --api-key-file "$API_KEY_FILE" "$OUTPUT_PATH/fish-$VERSION.app"
fi
# Zip it up.
zip -r "fish-$VERSION.app.zip" "fish-$VERSION.app" && rm -Rf "fish-$VERSION.app"
rm -rf "$PKGDIR"

View File

@@ -3,18 +3,18 @@
# Script to produce an OS X installer .pkg and .app(.zip)
usage() {
echo "Build macOS packages, optionally signing and notarizing them."
echo "Usage: $0 options"
echo "Options:"
echo " -s Enables code signing"
echo " -f <APP_KEY.p12> Path to .p12 file for application signing"
echo " -i <INSTALLER_KEY.p12> Path to .p12 file for installer signing"
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
echo " -n Enables notarization. This will fail if code signing is not also enabled."
echo " -j <API_KEY.JSON> Path to JSON file generated with `rcodesign encode-app-store-connect-api-key` (required for notarization)"
echo
exit 1
echo "Build macOS packages, optionally signing and notarizing them."
echo "Usage: $0 options"
echo "Options:"
echo " -s Enables code signing"
echo " -f <APP_KEY.p12> Path to .p12 file for application signing"
echo " -i <INSTALLER_KEY.p12> Path to .p12 file for installer signing"
echo " -p <PASSWORD> Password for the .p12 files (necessary to access the certificates)"
echo " -e <entitlements file> (Optional) Path to an entitlements XML file"
echo " -n Enables notarization. This will fail if code signing is not also enabled."
echo " -j <API_KEY.JSON> Path to JSON file generated with \`rcodesign encode-app-store-connect-api-key\` (required for notarization)"
echo
exit 1
}
set -x
@@ -30,35 +30,35 @@ X86_64_DEPLOY_TARGET='MACOSX_DEPLOYMENT_TARGET=10.9'
# The first supported version of macOS on arm64 is 10.15, so any Rust is fine for arm64.
# We wish to support back to 10.9 on x86-64; the last version of Rust to support that is
# version 1.73.0.
RUST_VERSION_X86_64=1.73.0
RUST_VERSION_X86_64=1.70.0
while getopts "sf:i:p:e:nj:" opt; do
case $opt in
s) SIGN=1;;
f) P12_APP_FILE=$(realpath "$OPTARG");;
i) P12_INSTALL_FILE=$(realpath "$OPTARG");;
p) P12_PASSWORD="$OPTARG";;
e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");;
n) NOTARIZE=1;;
j) API_KEY_FILE=$(realpath "$OPTARG");;
\?) usage;;
esac
case $opt in
s) SIGN=1;;
f) P12_APP_FILE=$(realpath "$OPTARG");;
i) P12_INSTALL_FILE=$(realpath "$OPTARG");;
p) P12_PASSWORD="$OPTARG";;
e) ENTITLEMENTS_FILE=$(realpath "$OPTARG");;
n) NOTARIZE=1;;
j) API_KEY_FILE=$(realpath "$OPTARG");;
\?) usage;;
esac
done
if [ -n "$SIGN" ] && ([ -z "$P12_APP_FILE" ] || [-z "$P12_INSTALL_FILE"] || [ -z "$P12_PASSWORD" ]); then
usage
if [ -n "$SIGN" ] && { [ -z "$P12_APP_FILE" ] || [ -z "$P12_INSTALL_FILE" ] || [ -z "$P12_PASSWORD" ]; }; then
usage
fi
if [ -n "$NOTARIZE" ] && [ -z "$API_KEY_FILE" ]; then
usage
usage
fi
VERSION=$(git describe --always --dirty 2>/dev/null)
if test -z "$VERSION" ; then
echo "Could not get version from git"
if test -f version; then
VERSION=$(cat version)
fi
echo "Could not get version from git"
if test -f version; then
VERSION=$(cat version)
fi
fi
echo "Version is $VERSION"
@@ -76,7 +76,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in
# and will probably not be built universal, so the package will fail to validate/run on other systems.
# Note CMAKE_OSX_ARCHITECTURES is still relevant for the Mac app.
{ cd "$PKGDIR/build_arm64" \
&& cmake \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DWITH_GETTEXT=OFF \
@@ -91,7 +91,7 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in
# Build for x86-64 but do not install; instead we will make some fat binaries inside the root.
# Set RUST_VERSION_X86_64 to the last version of Rust that supports macOS 10.9.
{ cd "$PKGDIR/build_x86_64" \
&& cmake \
&& cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-ld_classic" \
-DWITH_GETTEXT=OFF \
@@ -99,11 +99,11 @@ mkdir -p "$PKGDIR/build_x86_64" "$PKGDIR/build_arm64" "$PKGDIR/root" "$PKGDIR/in
-DRust_CARGO_TARGET=x86_64-apple-darwin \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DFISH_USE_SYSTEM_PCRE2=OFF "$SRC_DIR" \
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
&& env $X86_64_DEPLOY_TARGET make VERBOSE=1 -j 12; }
# Fatten them up.
for FILE in "$PKGDIR"/root/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/$(basename $FILE)"
X86_FILE="$PKGDIR/build_x86_64/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
chmod 755 "$FILE"
done
@@ -142,10 +142,10 @@ fi
(cd "$PKGDIR/build_arm64" && env $ARM64_DEPLOY_TARGET make -j 12 fish_macapp)
(cd "$PKGDIR/build_x86_64" && env $X86_64_DEPLOY_TARGET make -j 12 fish_macapp)
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtsey of CMake.
# Make the app's /usr/local/bin binaries universal. Note fish.app/Contents/MacOS/fish already is, courtesy of CMake.
cd "$PKGDIR/build_arm64"
for FILE in fish.app/Contents/Resources/base/usr/local/bin/*; do
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename $FILE)"
X86_FILE="$PKGDIR/build_x86_64/fish.app/Contents/Resources/base/usr/local/bin/$(basename "$FILE")"
rcodesign macho-universal-create --output "$FILE" "$FILE" "$X86_FILE"
# macho-universal-create screws up the permissions.

104
build_tools/release-notes.sh Executable file
View File

@@ -0,0 +1,104 @@
#!/bin/sh
set -e
workspace_root=$(dirname "$0")/..
relnotes_tmp=$(mktemp -d)
mkdir -p "$relnotes_tmp/fake-workspace" "$relnotes_tmp/out"
(
cd "$workspace_root"
cp -r doc_src CONTRIBUTING.rst README.rst "$relnotes_tmp/fake-workspace"
)
version=$(sed 's,^fish \(\S*\) .*,\1,; 1q' "$workspace_root/CHANGELOG.rst")
previous_version=$(
cd "$workspace_root"
awk <CHANGELOG.rst '
( /^fish \S*\.\S*\.\S* \(released .*\)$/ &&
NR > 1 &&
# Skip tags that have not been created yet..
system("git rev-parse --verify >/dev/null --quiet refs/tags/"$2) == 0 \
) {
print $2; ok = 1; exit
}
END { exit !ok }
'
)
minor_version=${version%.*}
previous_minor_version=${previous_version%.*}
{
sed -n 1,2p <"$workspace_root/CHANGELOG.rst"
ListCommitters() {
comm "$@" "$relnotes_tmp/committers-then" "$relnotes_tmp/committers-now"
}
(
cd "$workspace_root"
git log "$previous_version" --format="%aN" | sort -u >"$relnotes_tmp/committers-then"
git log "$previous_version".. --format="%aN" | sort -u >"$relnotes_tmp/committers-now"
ListCommitters -13 >"$relnotes_tmp/committers-new"
ListCommitters -12 >"$relnotes_tmp/committers-returning"
)
if [ "$minor_version" != "$previous_minor_version" ]; then
(
cd "$workspace_root"
num_commits=$(git log --no-merges --format=%H "$previous_version".. | wc -l)
num_authors=$(wc -l <"$relnotes_tmp/committers-now")
num_new_authors=$(wc -l <"$relnotes_tmp/committers-new")
printf %s \
"This release comprises $num_commits commits since $previous_version," \
" contributed by $num_authors authors, $num_new_authors of which are new committers."
echo
echo
)
fi
printf %s "$(awk <"$workspace_root/CHANGELOG.rst" '
NR <= 2 || /^\.\. ignore / { next }
/^===/ { exit }
{ print }
' | sed '$d')" |
sed -e '$s/^----*$//' # Remove spurious transitions at the end of the document.
if [ "$minor_version" != "$previous_minor_version" ]; then
JoinEscaped() {
sed 's/\S/\\&/g' |
awk '
NR != 1 { printf ",\n" }
{ printf "%s", $0 }
END { printf "\n" }
'
}
echo ""
echo "---"
echo ""
echo "Thanks to everyone who contributed through issue discussions, code reviews, or code changes."
echo
printf "Welcome our new committers: "
JoinEscaped <"$relnotes_tmp/committers-new"
echo
printf "Welcome back our returning committers: "
JoinEscaped <"$relnotes_tmp/committers-returning"
fi
echo
echo "---"
echo
echo "*Download links: To download the source code for fish, we suggest the file named \"fish-$version.tar.xz\". The file downloaded from \"Source code (tar.gz)\" will not build correctly.*"
echo
echo "*The files called fish-$version-linux-\*.tar.xz are experimental packages containing a single standalone ``fish`` binary for any Linux with the given CPU architecture.*"
} >"$relnotes_tmp/fake-workspace"/CHANGELOG.rst
sphinx-build >&2 -j auto \
-W -E -b markdown -c "$workspace_root/doc_src" \
-d "$relnotes_tmp/doctree" "$relnotes_tmp/fake-workspace/doc_src" "$relnotes_tmp/out" \
-D markdown_http_base="https://fishshell.com/docs/$minor_version" \
-D markdown_uri_doc_suffix=".html" \
-D markdown_github_flavored=1 \
"$@"
# Skip changelog header
sed -n 1p "$relnotes_tmp/out/relnotes.md" | grep -Fxq "# Release notes"
sed -n 2p "$relnotes_tmp/out/relnotes.md" | grep -Fxq ''
sed 1,2d "$relnotes_tmp/out/relnotes.md"
rm -r "$relnotes_tmp"

229
build_tools/release.sh Executable file
View File

@@ -0,0 +1,229 @@
#!/bin/sh
{
set -ex
version=$1
repository_owner=fish-shell
remote=origin
if [ -n "$2" ]; then
set -u
repository_owner=$2
remote=$3
set +u
[ $# -eq 3 ]
fi
[ -n "$version" ]
for tool in \
bundle \
gh \
jq \
ruby \
timeout \
; do
if ! command -v "$tool" >/dev/null; then
echo >&2 "$0: missing command: $1"
exit 1
fi
done
repo_root="$(dirname "$0")/.."
fish_site=$repo_root/../fish-site
for path in . "$fish_site"
do
if ! git -C "$path" diff HEAD --quiet ||
git ls-files --others --exclude-standard | grep .; then
echo >&2 "$0: index and worktree must be clean"
exit 1
fi
done
if git tag | grep -qxF "$version"; then
echo >&2 "$0: tag $version already exists"
exit 1
fi
integration_branch=$(
git for-each-ref --points-at=HEAD 'refs/heads/Integration_*' \
--format='%(refname:strip=2)'
)
[ -n "$integration_branch" ] ||
git merge-base --is-ancestor $remote/master HEAD
sed -n 1p CHANGELOG.rst | grep -q '^fish .*(released .*)$'
sed -n 2p CHANGELOG.rst | grep -q '^===*$'
changelog_title="fish $version (released $(date +'%B %d, %Y'))"
sed -i \
-e "1c$changelog_title" \
-e "2c$(printf %s "$changelog_title" | sed s/./=/g)" \
CHANGELOG.rst
CommitVersion() {
sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml
cargo fetch --offline
git add CHANGELOG.rst Cargo.toml Cargo.lock
git commit -m "$2
Created by ./build_tools/release.sh $version"
}
CommitVersion "$version" "Release $version"
# N.B. this is not GPG-signed.
git tag --annotate --message="Release $version" $version
git push $remote $version
TIMEOUT=
gh() {
command ${TIMEOUT:+timeout $TIMEOUT} \
gh --repo "$repository_owner/fish-shell" "$@"
}
gh workflow run release.yml --ref="$version" \
--raw-field="version=$version"
run_id=
while [ -z "$run_id" ] && sleep 5
do
run_id=$(gh run list \
--json=databaseId --jq=.[].databaseId \
--workflow=release.yml --limit=1 \
--commit="$(git rev-parse "$version^{commit}")")
done
# Update fishshell.com
tag_oid=$(git rev-parse "$version")
tmpdir=$(mktemp -d)
# TODO This works on draft releases only if "gh" is configured to
# have write access to the fish-shell repository. Unless we are fine
# publishing the release at this point, we should at least fail if
# "gh" doesn't have write access.
while ! \
gh release download "$version" --dir="$tmpdir" \
--pattern="fish-$version.tar.xz"
do
TIMEOUT=30 gh run watch "$run_id" ||:
sleep 5
done
actual_tag_oid=$(git ls-remote "$remote" |
awk '$2 == "refs/tags/'"$version"'" { print $1 }')
[ "$tag_oid" = "$actual_tag_oid" ]
( cd "$tmpdir" && tar xf fish-$version.tar.xz )
CopyDocs() {
rm -rf "$fish_site/site/docs/$1"
cp -r "$tmpdir/fish-$version/user_doc/html" "$fish_site/site/docs/$1"
git -C $fish_site add "site/docs/$1"
}
minor_version=${version%.*}
CopyDocs "$minor_version"
latest_release=$(
releases=$(git tag | grep '^[0-9]*\.[0-9]*\.[0-9]*.*' |
sed $(: "De-prioritize release candidates (1.2.3-rc0)") \
's/-/~/g' | LC_ALL=C sort --version-sort)
printf %s\\n "$releases" | tail -1
)
if [ "$version" = "$latest_release" ]; then
CopyDocs current
fi
rm -rf "$tmpdir"
(
cd "$fish_site"
make
git add -u
! git ls-files --others --exclude-standard | grep .
git commit --message="$(printf %s "\
| Release $version (docs)
|
| Created by ../fish-shell/build_tools/release.sh
" | sed 's,^\s*| \?,,')"
)
# Approve macos-codesign
# TODO what if current user can't approve?
gh_pending_deployments() {
command gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$repository_owner/fish-shell/actions/runs/$run_id/pending_deployments" \
"$@"
}
while {
environment_id=$(gh_pending_deployments | jq .[].environment.id)
[ -z "$environment_id" ]
}
do
sleep 5
done
echo '
{
"environment_ids": ['"$environment_id"'],
"state": "approved",
"comment": "Approved via ./build_tools/release.sh"
}
' |
gh_pending_deployments -XPOST --input=-
# Await completion.
gh run watch "$run_id"
while {
! draft=$(gh release view "$version" --json=isDraft --jq=.isDraft) \
|| [ "$draft" = true ]
}
do
sleep 20
done
(
cd "$fish_site"
make new-release
git add -u
! git ls-files --others --exclude-standard | grep .
git commit --message="$(printf %s "\
| Release $version (release list update)
|
| Created by ../fish-shell/build_tools/release.sh
" | sed 's,^\s*| \?,,')"
# This takes care to support remote names that are different from
# fish-shell remote name. Also, support detached HEAD state.
git push git@github.com:$repository_owner/fish-site HEAD:master
)
if [ -n "$integration_branch" ]; then
git push $remote "$version^{commit}":refs/heads/$integration_branch
else
changelog=$(cat - CHANGELOG.rst <<EOF
fish ?.?.? (released ???)
=========================
EOF
)
printf %s\\n "$changelog" >CHANGELOG.rst
CommitVersion ${version}-snapshot "start new cycle"
git push $remote HEAD:master
fi
# TODO This can currently require a TTY for editing and password
# prompts.
if [ "$repository_owner" = fish-shell ]; then {
mail=$(mktemp)
cat >$mail <<EOF
From: $(git var GIT_AUTHOR_IDENT | sed 's/ [0-9]* +[0-9]*$//')
Subject: fish $version released
See https://github.com/fish-shell/fish-shell/releases/tag/$version
EOF
git send-email --suppress-cc=all --confirm=always $mail \
--to="fish-users Mailing List <fish-users@lists.sourceforge.net>"
rm $mail
} fi
exit
}

View File

@@ -29,7 +29,7 @@ add_custom_target(sphinx-docs
# sphinx-manpages needs the fish_indent binary for the version number
add_custom_target(sphinx-manpages
env PATH="${CMAKE_BINARY_DIR}:$$PATH"
env FISH_BUILD_VERSION_FILE="${CMAKE_CURRENT_BINARY_DIR}/${FBVF}"
${SPHINX_EXECUTABLE}
-j auto
-q -b man
@@ -38,7 +38,7 @@ add_custom_target(sphinx-manpages
"${SPHINX_SRC_DIR}"
# TODO: This only works if we only have section 1 manpages.
"${SPHINX_MANPAGE_DIR}/man1"
DEPENDS fish_indent
DEPENDS CHECK-FISH-BUILD-VERSION-FILE
COMMENT "Building man pages with Sphinx")
if(SPHINX_EXECUTABLE)

View File

@@ -265,18 +265,6 @@ else()
endif()
if (_RUSTC_VERSION_RAW MATCHES "rustup [0-9\\.]+")
if (_USER_SPECIFIED_RUSTC)
message(
WARNING "User-specified Rust_COMPILER pointed to rustup's rustc proxy. Corrosion's "
"FindRust will always try to evaluate to an actual Rust toolchain, and so the "
"user-specified Rust_COMPILER will be discarded in favor of the default "
"rustup-managed toolchain."
)
unset(Rust_COMPILER)
unset(Rust_COMPILER CACHE)
endif()
# Get `rustup` next to the `rustc` proxy
get_filename_component(_RUST_PROXIES_PATH "${_Rust_COMPILER_TEST}" DIRECTORY)
find_program(Rust_RUSTUP rustup HINTS "${_RUST_PROXIES_PATH}" NO_DEFAULT_PATH)
@@ -318,18 +306,23 @@ if (Rust_RESOLVE_RUSTUP_TOOLCHAINS)
set(_DISCOVERED_TOOLCHAINS_VERSION "")
foreach(_TOOLCHAIN_RAW ${_TOOLCHAINS_RAW})
if (_TOOLCHAIN_RAW MATCHES "([a-zA-Z0-9\\._\\-]+)[ \t\r\n]?(\\(default\\) \\(override\\)|\\(default\\)|\\(override\\))?[ \t\r\n]+(.+)")
# We're going to try to parse the output of `rustup toolchain list --verbose`.
# We expect output like this:
# stable-random-toolchain-junk (parenthesized-random-stuff-like-active-or-default) /path/to/toolchain/blah/more-blah
# In the following regex, we capture the toolchain name, any parenthesized stuff, and then the path.
message(STATUS "Parsing toolchain: ${_TOOLCHAIN_RAW}")
if (_TOOLCHAIN_RAW MATCHES "([^\t ]+)[\t ]*(\\(.*\\))?[\t ]*(.+)")
set(_TOOLCHAIN "${CMAKE_MATCH_1}")
set(_TOOLCHAIN_TYPE "${CMAKE_MATCH_2}")
set(_TOOLCHAIN_PATH "${CMAKE_MATCH_3}")
set(_TOOLCHAIN_${_TOOLCHAIN}_PATH "${CMAKE_MATCH_3}")
if (_TOOLCHAIN_TYPE MATCHES ".*\\(default\\).*")
if (_TOOLCHAIN_TYPE MATCHES "default")
set(_TOOLCHAIN_DEFAULT "${_TOOLCHAIN}")
endif()
if (_TOOLCHAIN_TYPE MATCHES ".*\\(override\\).*")
if (_TOOLCHAIN_TYPE MATCHES "override")
set(_TOOLCHAIN_OVERRIDE "${_TOOLCHAIN}")
endif()

View File

@@ -106,7 +106,7 @@ configure_file(fish.pc.in fish.pc.noversion @ONLY)
add_custom_command(OUTPUT fish.pc
COMMAND sed '/Version/d' fish.pc.noversion > fish.pc
COMMAND printf "Version: " >> fish.pc
COMMAND sed 's/FISH_BUILD_VERSION=//\;s/\"//g' ${FBVF} >> fish.pc
COMMAND cat ${FBVF} >> fish.pc
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS CHECK-FISH-BUILD-VERSION-FILE ${CMAKE_CURRENT_BINARY_DIR}/fish.pc.noversion)

View File

@@ -24,7 +24,7 @@ add_executable(fish_macapp EXCLUDE_FROM_ALL
# Compute the version. Note this is done at generation time, not build time,
# so cmake must be re-run after version changes for the app to be updated. But
# generally this will be run by make_pkg.sh which always re-runs cmake.
# generally this will be run by make_macos_pkg.sh which always re-runs cmake.
execute_process(
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build_tools/git_version_gen.sh --stdout
COMMAND cut -d- -f1
@@ -32,7 +32,7 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Note CMake appends .app, so the real output name will be fish.app.
# Note CMake appends .app, so the real output name will be fish.app.
# This target does not include the 'base' resource.
set_target_properties(fish_macapp PROPERTIES OUTPUT_NAME "fish")

View File

@@ -22,7 +22,7 @@ else()
set(rust_target_dir "${FISH_RUST_BUILD_DIR}/${Rust_CARGO_HOST_TARGET}")
endif()
set(rust_profile $<IF:$<CONFIG:Debug>,debug,release>)
set(rust_profile $<IF:$<CONFIG:Debug>,debug,$<IF:$<CONFIG:RelWithDebInfo>,release-with-debug,release>>)
set(rust_debugflags "$<$<CONFIG:Debug>:-g>$<$<CONFIG:RelWithDebInfo>:-g>")
@@ -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}"

View File

@@ -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)
@@ -54,6 +43,7 @@ set(TEST_ROOT_DIR ${TEST_DIR}/root)
if(NOT FISH_IN_TREE_BUILD)
add_custom_target(funcs_dir)
add_custom_command(TARGET funcs_dir
POST_BUILD
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/share
# Don't run ln twice or it will create a new link in the link.
COMMAND test -e ${CMAKE_BINARY_DIR}/share/functions || ln -sf
@@ -63,6 +53,7 @@ if(NOT FISH_IN_TREE_BUILD)
add_custom_target(tests_dir DEPENDS tests)
add_custom_command(TARGET tests_dir
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/tests/ ${CMAKE_BINARY_DIR}/tests/
COMMENT "Copying test files to binary dir"
@@ -79,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)
@@ -153,7 +144,7 @@ endif()
add_test(
NAME "cargo-test"
COMMAND env ${VARS_FOR_CARGO} cargo test ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
COMMAND env ${VARS_FOR_CARGO} cargo test --no-default-features ${CARGO_FLAGS} --workspace --target-dir ${rust_target_dir} ${cargo_test_flags}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
)
set_tests_properties("cargo-test" PROPERTIES SKIP_RETURN_CODE ${SKIP_RETURN_CODE})

24
debian/control vendored
View File

@@ -3,10 +3,16 @@ Section: shells
Priority: optional
Maintainer: ridiculous_fish <corydoras@ridiculousfish.com>
Uploaders: David Adam <zanchey@ucc.gu.uwa.edu.au>
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.15.0) | cmake-mozilla (>= 3.15.0),
gettext,
libpcre2-dev,
rustc (>= 1.70),
# Test dependencies
locales-all, 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,16 @@ Vcs-Browser: https://github.com/fish-shell/fish-shell
Package: fish
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, passwd (>= 4.0.3-10), gettext-base, man-db,
procps, python3 (>=3.5)
Depends: bsdextrautils | bsdmainutils,
file,
gettext-base,
groff-base,
man-db,
ncurses-base,
procps,
python3 (>=3.5),
${misc:Depends},
${shlibs:Depends}
Conflicts: fish-common
Recommends: xsel (>=1.2.0)
Suggests: xdg-utils

5
debian/rules vendored
View File

@@ -17,6 +17,9 @@ override_dh_auto_configure:
dh_auto_configure --buildsystem=cmake -- -DCMAKE_BUILD_TYPE=RelWithDebInfo
override_dh_clean:
dh_clean
dh_clean --exclude=Cargo.toml.orig
-unlink .cargo
-unlink vendor
override_dh_auto_test:
make fish_run_tests

22
deny.toml Normal file
View File

@@ -0,0 +1,22 @@
[licenses]
# We want really high confidence when inferring licenses from text
confidence-threshold = 0.93
unused-allowed-license = "allow" # don't warn for unused licenses in this list
allow = [
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0",
"GPL-2.0",
"ISC",
"LGPL-2.0",
"MIT",
"MPL-2.0",
"PSF-2.0",
"Unicode-DFS-2016",
"WTFPL",
"Zlib",
]
[sources.allow-org]
# 1 or more github.com organizations to allow git sources for
github = ["fish-shell"]

View File

@@ -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 <funcsave>`.
@@ -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.

View File

@@ -23,7 +23,7 @@ If both ``KEYS`` and ``COMMAND`` are given, ``bind`` adds (or replaces) a bindin
If only ``KEYS`` is given, any existing binding in the given ``MODE`` will be printed.
``KEYS`` is a comma-separated list of key names.
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``/``c-``, ``alt-``/``a-`` and ``shift-``.
Modifier keys can be specified by prefixing a key name with a combination of ``ctrl-``, ``alt-``, ``shift-`` and ``super-`` (i.e. the "windows" or "command" key).
For example, pressing :kbd:`w` while holding the Alt modifier is written as ``alt-w``.
Key names are case-sensitive; for example ``alt-W`` is the same as ``alt-shift-w``.
``ctrl-x,ctrl-e`` would mean pressing :kbd:`ctrl-x` followed by :kbd:`ctrl-e`.
@@ -99,6 +99,12 @@ The following options are available:
**-s** or **--silent**
Silences some of the error messages, including for unknown key names and unbound sequences.
**-k KEY_NAME** or **--key KEY_NAME**
This looks up KEY_NAME in terminfo and binds that sequence instead of a key that fish would decode.
To view a list of the terminfo keys fish knows about, use ``bind --key-names`` or ``bind -K``.
This is deprecated and provided for compatibility with older fish versions. You should bind the keys directly.
Instead of ``bind -k sright`` use ``bind shift-right``, instead of ``bind -k nul`` use ``bind ctrl-space`` and so on.
**-h** or **--help**
Displays help about using this command.
@@ -162,7 +168,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
@@ -170,6 +176,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``.
@@ -259,7 +268,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 +278,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 +301,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

View File

@@ -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:
@@ -97,7 +97,12 @@ If ``commandline`` is called during a call to complete a given string using ``co
The following options output metadata about the commandline state:
**-L** or **--line**
Print the line that the cursor is on, with the topmost line starting at 1.
If no argument is given, print the line that the cursor is on, with the topmost line starting at 1.
Otherwise, set the cursor to the given line.
**--column**
If no argument is given, print the 1-based offset from the start of the line to the cursor position in Unicode code points.
Otherwise, set the cursor to the given code point offset.
**-S** or **--search-mode**
Evaluates to true if the commandline is performing a history search.
@@ -111,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.

50
doc_src/cmds/export.rst Normal file
View File

@@ -0,0 +1,50 @@
.. _cmd-export:
export - compatibility function for exporting variables
=======================================================
Synopsis
--------
.. synopsis::
export
export NAME=VALUE
Description
-----------
``export`` is a function included for compatibility with POSIX shells. In general, the :doc:`set <set>`
builtin should be used instead.
When called without arguments, ``export`` prints a list of currently-exported variables, like ``set
-x``.
When called with a ``NAME=VALUE`` pair, the variable ``NAME`` is set to ``VALUE`` in the global
scope, and exported as an environment variable to other commands.
There are no options available.
Example
-------
The following commands have an identical effect.
::
set -gx PAGER bat
export PAGER=bat
Note: If you want to add to e.g. ``$PATH``, you need to be careful to :ref:`combine the list <cartesian-product>`. Quote it, like so::
export PATH="$PATH:/opt/bin"
Or just use ``set``, which avoids this::
set -gx PATH $PATH /opt/bin
See more
--------
1. The :doc:`set <set>` command.

View File

@@ -34,12 +34,18 @@ The following options are available:
See :ref:`Debugging <debugging-fish>` 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 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 data files to PATH/share/fish and copy itself to PATH/bin/fish.
**-l** or **--login**
Act as if invoked as a login shell.

View File

@@ -26,15 +26,12 @@ The first argument to fish_title contains the most recently executed foreground
This requires that your terminal supports programmable titles and the feature is turned on.
To disable setting the title, use an empty function (see below).
Example
-------
A simple title:
::
A simple title::
function fish_title
set -q argv[1]; or set argv fish
@@ -43,3 +40,7 @@ A simple title:
echo (fish_prompt_pwd_dir_length=1 prompt_pwd): $argv;
end
Do not change the title::
function fish_title
end

View File

@@ -279,7 +279,7 @@ Examples
path normalize [-z | --null-in] [-Z | --null-out] [-q | --quiet] [PATH ...]
``path normalize`` returns the normalized versions of all paths. That means it squashes duplicate "/" (except for two leading "//"), collapses "../" with earlier components and removes "." components.
``path normalize`` returns the normalized versions of all paths. That means it squashes duplicate "/", collapses "../" with earlier components and removes "." components.
Unlike ``realpath`` or ``path resolve``, it does not make the paths absolute. It also does not resolve any symlinks. As such it can operate on non-existent paths.

View File

@@ -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.

View File

@@ -11,6 +11,7 @@ Synopsis
status
status is-login
status is-interactive
status is-interactive-read
status is-block
status is-breakpoint
status is-command-substitution
@@ -29,6 +30,7 @@ Synopsis
status job-control CONTROL_TYPE
status features
status test-feature FEATURE
status buildinfo
Description
-----------
@@ -49,6 +51,9 @@ The following operations (subcommands) are available:
**is-interactive**, **-i** or **--is-interactive**
Returns 0 if fish is interactive - that is, connected to a keyboard.
**is-interactive-read** or **--is-interactive-read**
Returns 0 if fish is running an interactive :doc:`read <read>` builtin which is connected to a keyboard.
**is-login**, **-l** or **--is-login**
Returns 0 if fish is a login shell - that is, if fish should perform login tasks such as setting up :envvar:`PATH`.
@@ -97,6 +102,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
-----

View File

@@ -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.

View File

@@ -52,13 +52,13 @@ Match Glob Examples
::
>_ string match '?' a
>_ string match 'a' a
a
>_ string match 'a*b' axxb
axxb
>_ string match -i 'a??B' Axxb
>_ string match -i 'a*B' Axxb
Axxb
>_ string match -- '-*' -h foo --version bar
@@ -67,7 +67,7 @@ Match Glob Examples
-h
--version
>_ echo 'ok?' | string match '*\?'
>_ echo 'ok?' | string match '*?'
ok?
# Note that only the second STRING will match here.
@@ -79,7 +79,7 @@ Match Glob Examples
foo
foo2
>_ string match 'foo?' 'foo1' 'foo' 'foo2'
>_ string match 'foo*' 'foo1' 'foo' 'foo2'
foo1
foo2

View File

@@ -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

View File

@@ -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

View File

@@ -18,7 +18,11 @@ Description
.. BEGIN DESCRIPTION
``string trim`` removes leading and trailing whitespace from each *STRING*. If **-l** or **--left** is given, only leading whitespace is removed. If **-r** or **--right** is given, only trailing whitespace is trimmed. The **-c** or **--chars** switch causes the characters in *CHARS* to be removed instead of whitespace. Exit status: 0 if at least one character was trimmed, or 1 otherwise.
``string trim`` removes leading and trailing whitespace from each *STRING*. If **-l** or **--left** is given, only leading whitespace is removed. If **-r** or **--right** is given, only trailing whitespace is trimmed.
The **-c** or **--chars** switch causes the set of characters in *CHARS* to be removed instead of whitespace. This is a set of characters, not a string - if you pass ``-c foo``, it will remove any "f" or "o", not just "foo" as a whole.
Exit status: 0 if at least one character was trimmed, or 1 otherwise.
.. END DESCRIPTION

View File

@@ -79,6 +79,7 @@ Some helper functions, often to give you information for use in your prompt:
- :doc:`fish_add_path <cmds/fish_add_path>` to easily add a path to $PATH.
- :doc:`alias <cmds/alias>` to quickly define wrapper functions ("aliases").
- :doc:`fish_delta <cmds/fish_delta>` to show what you have changed from the default configuration.
- :doc:`export <cmds/export>` as a compatibility function for other shells.
Helper commands
^^^^^^^^^^^^^^^

View File

@@ -10,9 +10,19 @@ import glob
import os.path
import subprocess
import sys
from sphinx.highlighting import lexers
from sphinx.errors import SphinxWarning
from docutils import nodes
try:
import sphinx_markdown_builder
extensions = [
"sphinx_markdown_builder",
]
except ImportError:
pass
# -- Helper functions --------------------------------------------------------
@@ -35,11 +45,14 @@ def issue_role(name, rawtext, text, lineno, inliner, options=None, content=None)
return [link], []
def remove_fish_indent_lexer(app):
if app.builder.name in ("man", "markdown"):
del lexers["fish-docs-samples"]
# -- Load our extensions -------------------------------------------------
def setup(app):
# Our own pygments lexers
from sphinx.highlighting import lexers
this_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, this_dir)
from fish_indent_lexer import FishIndentLexer
@@ -52,6 +65,8 @@ def setup(app):
app.add_config_value("issue_url", default=None, rebuild="html")
app.add_role("issue", issue_role)
app.connect("builder-inited", remove_fish_indent_lexer)
# The default language to assume
highlight_language = "fish-docs-samples"
@@ -59,15 +74,22 @@ highlight_language = "fish-docs-samples"
# -- Project information -----------------------------------------------------
project = "fish-shell"
copyright = "2024, fish-shell developers"
copyright = "fish-shell developers"
author = "fish-shell developers"
issue_url = "https://github.com/fish-shell/fish-shell/issues"
# Parsing FISH-BUILD-VERSION-FILE is possible but hard to ensure that it is in the right place
# fish_indent is guaranteed to be on PATH for the Pygments highlighter anyway
ret = subprocess.check_output(
("fish_indent", "--version"), stderr=subprocess.STDOUT
).decode("utf-8")
if "FISH_BUILD_VERSION_FILE" in os.environ:
f = open(os.environ["FISH_BUILD_VERSION_FILE"], "r")
ret = f.readline().strip()
elif "FISH_BUILD_VERSION" in os.environ:
ret = os.environ["FISH_BUILD_VERSION"]
else:
ret = subprocess.check_output(
("../build_tools/git_version_gen.sh", "--stdout"), stderr=subprocess.STDOUT
).decode("utf-8")
# The full version, including alpha/beta/rc tags
release = ret.strip().split(" ")[-1]
# The short X.Y version

View File

@@ -154,7 +154,7 @@ in :ref:`config.fish <configuration>`.
How do I run a command from history?
------------------------------------
Type some part of the command, and then hit the :kbd:`up` (````) or :kbd:`ctrl-down` (````) arrow keys to navigate through history matches, or press :kbd:`ctrl-r` to open the history in a searchable pager. In this pager you can press :kbd:`ctrl-r` or :kbd:`ctrl-s` to move to older or younger history respectively.
Type some part of the command, and then hit the :kbd:`up` (````) or :kbd:`down` (````) arrow keys to navigate through history matches, or press :kbd:`ctrl-r` to open the history in a searchable pager. In this pager you can press :kbd:`ctrl-r` or :kbd:`ctrl-s` to move to older or younger history respectively.
Additional default key bindings include :kbd:`ctrl-p` (up) and :kbd:`ctrl-n` (down). See :ref:`Searchable command history <history-search>` for more information.
@@ -168,7 +168,7 @@ In general, fish's history recall works like this:
- Like other shells, the Up arrow, ``up`` recalls whole lines, starting from the last executed line. So instead of typing ``!!``, you would just hit the up-arrow.
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will filter the recalled lines to ones that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like. If you want to see more context, you can press ``ctlr-b`` to open the history in the pager.
- If the line you want is far back in the history, type any part of the line and then press Up one or more times. This will filter the recalled lines to ones that include this text, and you will get to the line you want much faster. This replaces "!vi", "!?bar.c" and the like. If you want to see more context, you can press ``ctrl-r`` to open the history in the pager.
- ``alt-up`` recalls individual arguments, starting from the last argument in the last executed line. This can be used instead of "!$".

View File

@@ -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.
@@ -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.
@@ -360,11 +364,13 @@ To enable emacs mode, use :doc:`fish_default_key_bindings <cmds/fish_default_key
- :kbd:`ctrl-b`, :kbd:`ctrl-f` move the cursor one character left or right or accept the autosuggestion just like the :kbd:`left` (````) and :kbd:`right` (````) shared bindings (which are available as well).
- :kbd:`alt-b`, :kbd:`alt-f` move the cursor one word left or right, or accept one word of the autosuggestion. If the command line is empty, moves forward/backward in the directory history instead.
- :kbd:`ctrl-n`, :kbd:`ctrl-p` move the cursor up/down or through history, like the up and down arrow shared bindings.
- :kbd:`delete` or :kbd:`backspace` or :kbd:`ctrl-h` removes one character forwards or backwards respectively.
- :kbd:`ctrl-backspace` removes one word backwards and :kbd:`alt-backspace` removes one argument backwards.
- :kbd:`alt-backspace` removes one word backwards. If supported by the terminal, :kbd:`ctrl-backspace` does the same.
- :kbd:`alt-<` moves to the beginning of the commandline, :kbd:`alt->` moves to the end.
@@ -382,7 +388,7 @@ To enable emacs mode, use :doc:`fish_default_key_bindings <cmds/fish_default_key
- :kbd:`ctrl-z`, :kbd:`ctrl-_` (:kbd:`ctrl-/` on some terminals) undo the most recent edit of the line.
- :kbd:`alt-/` reverts the most recent undo.
- :kbd:`alt-/` or :kbd:`ctrl-shift-z` reverts the most recent undo.
- :kbd:`ctrl-r` opens the history in a pager. This will show history entries matching the search, a few at a time. Pressing :kbd:`ctrl-r` again will search older entries, pressing :kbd:`ctrl-s` (that otherwise toggles pager search) will go to newer entries. The search bar will always be selected.
@@ -476,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.
@@ -497,6 +504,8 @@ Insert mode
- :kbd:`backspace` removes one character to the left.
- :kbd:`ctrl-n` accepts the autosuggestion.
.. _vi-mode-visual:
Visual mode

View File

@@ -266,8 +266,9 @@ Consider this helper function::
Now let's see a few cases::
# Redirect both stderr and stdout to less
# (can also be spelt as `&|`)
print 2>&1 | less
# or
print &| less
# Show the "out" on stderr, silence the "err"
print >&2 2>/dev/null
@@ -869,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 <cmds/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 <cmds/read>` command.
.. [#] One exception: Setting ``$IFS`` to empty will disable line splitting. This is deprecated, use :doc:`string split <cmds/string-split>` instead.
@@ -1844,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
@@ -2021,17 +2022,21 @@ 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
keyboard-protocols on 4.0 Use keyboard protocols (kitty, xterm's modifyotherkeys
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``.
- ``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 <cmds/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 <debugging-fish>` 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 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 4.0. To get fish's pid, you can use the :envvar:`fish_pid` variable.
- ``test-require-arg`` removes :doc:`builtin test <cmds/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 <debugging-fish>` 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::
@@ -2052,12 +2057,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

View File

@@ -53,7 +53,6 @@ body {
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related {
@@ -71,12 +70,10 @@ div.related h3 {
}
div.related li.right {
float: right;
margin-right: 5px;
}
div.sphinxsidebar {
width: 230px;
overflow-wrap: break-word;
}
@@ -113,7 +110,6 @@ div.sphinxsidebar ul {
margin: 10px;
padding: 0;
color: var(--secondary-link-color);
margin: 10px;
list-style: none;
}
@@ -548,10 +544,6 @@ div.sphinxsidebar ul {
}
div.bodywrapper {
margin-left: 230px;
}
aside.footnote > .label {
display: inline;
}
@@ -565,19 +557,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.bodywrapper, div.content {
margin-left: 0;
}
div.sphinxsidebar h3, div.sphinxsidebar h4 {
margin-top: 0;
}
div.sphinxsidebar ul {
flex-basis: content;
@@ -585,14 +594,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 +623,9 @@ div.documentwrapper {
/* On print media remove anything non-essential. */
@media print {
div.document {
display: block;
}
.inline-search {
display: none;
}

View File

@@ -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
@@ -31,8 +31,15 @@ BuildRequires: glibc-langpack-en
%endif
BuildRequires: python3 procps
%if 0%{?suse_version}
Requires: terminfo-base
%else
Requires: ncurses-base
%endif
Requires: file
Requires: python3
Requires: man
Requires: procps
# Although the build scripts mangle the version number to be RPM compatible
# for continuous builds (transforming the output of `git describe`), Fedora 32+

View File

@@ -9,3 +9,5 @@ license = "MIT"
[dependencies]
libc = "0.2.155"
widestring = { version = "1.0.2", optional = true }
unicode-segmentation = "1.12.0"
unicode-width = "0.2.0"

View File

@@ -73,7 +73,7 @@ macro_rules! sprintf {
/// - `args`: Iterator over the arguments to format.
///
/// # Returns
/// A `Result` which is `Ok` containing the number of characters written on success, or an `Error`.
/// A `Result` which is `Ok` containing the width of the string written on success, or an `Error`.
///
/// # Example
///

View File

@@ -5,6 +5,8 @@
use std::fmt::{self, Write};
use std::mem;
use std::result::Result;
use unicode_segmentation::UnicodeSegmentation;
use unicode_width::UnicodeWidthStr;
#[cfg(feature = "widestring")]
use widestring::Utf32Str as wstr;
@@ -382,7 +384,7 @@ pub fn sprintf_locale(
}
// Read field width. We do not support $.
let width = if s.at(0) == Some('*') {
let desired_width = if s.at(0) == Some('*') {
let arg_width = args.next().ok_or(Error::MissingArg)?.as_sint()?;
s.advance_by(1);
if arg_width < 0 {
@@ -397,7 +399,7 @@ pub fn sprintf_locale(
};
// Optionally read precision. We do not support $.
let mut prec: Option<usize> = if s.at(0) == Some('.') && s.at(1) == Some('*') {
let mut desired_precision: Option<usize> = if s.at(0) == Some('.') && s.at(1) == Some('*') {
// "A negative precision is treated as though it were missing."
// Here we assume the precision is always signed.
s.advance_by(2);
@@ -410,7 +412,7 @@ pub fn sprintf_locale(
None
};
// Disallow precisions larger than i32::MAX, in keeping with C.
if prec.unwrap_or(0) > i32::MAX as usize {
if desired_precision.unwrap_or(0) > i32::MAX as usize {
return Err(Error::Overflow);
}
@@ -429,7 +431,7 @@ pub fn sprintf_locale(
// "If a precision is given with a numeric conversion (d, i, o, u, i, x, and X),
// the 0 flag is ignored." p is included here.
let spec_is_numeric = matches!(conv_spec, CS::d | CS::u | CS::o | CS::p | CS::x | CS::X);
if spec_is_numeric && prec.is_some() {
if spec_is_numeric && desired_precision.is_some() {
flags.zero_pad = false;
}
@@ -443,13 +445,22 @@ pub fn sprintf_locale(
CS::e | CS::f | CS::g | CS::a | CS::E | CS::F | CS::G | CS::A => {
// Floating point types handle output on their own.
let float = arg.as_float()?;
let len = format_float(f, float, width, prec, flags, locale, conv_spec, buf)?;
let len = format_float(
f,
float,
desired_width,
desired_precision,
flags,
locale,
conv_spec,
buf,
)?;
out_len = out_len.checked_add(len).ok_or(Error::Overflow)?;
continue 'main;
}
CS::p => {
const PTR_HEX_DIGITS: usize = 2 * mem::size_of::<*const u8>();
prec = prec.map(|p| p.max(PTR_HEX_DIGITS));
desired_precision = desired_precision.map(|p| p.max(PTR_HEX_DIGITS));
let uint = arg.as_uint()?;
if uint != 0 {
prefix = "0x";
@@ -479,8 +490,8 @@ pub fn sprintf_locale(
if uint != 0 {
write!(buf, "{:o}", uint)?;
}
if flags.alt_form && prec.unwrap_or(0) <= buf.len() + 1 {
prec = Some(buf.len() + 1);
if flags.alt_form && desired_precision.unwrap_or(0) <= buf.len() + 1 {
desired_precision = Some(buf.len() + 1);
}
buf
}
@@ -514,10 +525,38 @@ pub fn sprintf_locale(
CS::s => {
// also 'S'
let s = arg.as_str(buf)?;
let p = prec.unwrap_or(s.len()).min(s.len());
prec = Some(p);
flags.zero_pad = false;
&s[..p]
match desired_precision {
Some(precision) => {
// from man printf(3)
// "the maximum number of characters to be printed from a string"
// We interpret this to mean the maximum width when printed, as defined by
// Unicode grapheme cluster width.
let mut byte_len = 0;
let mut width = 0;
let mut graphemes = s.graphemes(true);
// Iteratively add single grapheme clusters as long as the fit within the
// width limited by precision.
while width < precision {
match graphemes.next() {
Some(grapheme) => {
let grapheme_width = grapheme.width();
if width + grapheme_width <= precision {
byte_len += grapheme.len();
width += grapheme_width;
} else {
break;
}
}
None => break,
}
}
let p = precision.min(width);
desired_precision = Some(p);
&s[..byte_len]
}
None => s,
}
}
};
// Numeric output should be empty iff the value is 0.
@@ -528,23 +567,26 @@ pub fn sprintf_locale(
// Decide if we want to apply thousands grouping to the body, and compute its size.
// Note we have already errored out if grouped is set and this is non-numeric.
let wants_grouping = flags.grouped && locale.thousands_sep.is_some();
let body_len = match wants_grouping {
let body_width = match wants_grouping {
// We assume that text representing numbers is ASCII, so len == width.
true => body.len() + locale.separator_count(body.len()),
false => body.len(),
false => body.width(),
};
// Resolve the precision.
// In the case of a non-numeric conversion, update the precision to at least the
// length of the string.
let prec = if !spec_is_numeric {
prec.unwrap_or(body_len)
let desired_precision = if !spec_is_numeric {
desired_precision.unwrap_or(body_width)
} else {
prec.unwrap_or(1).max(body_len)
desired_precision.unwrap_or(1).max(body_width)
};
let prefix_len = prefix.len();
let unpadded_width = prefix_len.checked_add(prec).ok_or(Error::Overflow)?;
let width = width.max(unpadded_width);
let prefix_width = prefix.width();
let unpadded_width = prefix_width
.checked_add(desired_precision)
.ok_or(Error::Overflow)?;
let width = desired_width.max(unpadded_width);
// Pad on the left with spaces to the desired width?
if !flags.left_adj && !flags.zero_pad {
@@ -560,7 +602,8 @@ pub fn sprintf_locale(
}
// Pad on the left to the given precision?
pad(f, '0', prec, body_len)?;
// TODO: why pad with 0 here?
pad(f, '0', desired_precision, body_width)?;
// Output the actual value, perhaps with grouping.
if wants_grouping {

View File

@@ -13,6 +13,7 @@ macro_rules! sprintf_check {
$(,)? // optional trailing comma
) => {
{
use unicode_width::UnicodeWidthStr;
let mut target = String::new();
let mut args = [$($arg.to_arg()),*];
let len = $crate::printf_c_locale(
@@ -20,7 +21,7 @@ macro_rules! sprintf_check {
$fmt.as_ref() as &str,
&mut args,
).expect("printf failed");
assert!(len == target.len(), "Wrong length returned: {} vs {}", len, target.len());
assert_eq!(len, target.width(), "Wrong length returned");
target
}
};
@@ -723,6 +724,18 @@ fn test_huge_precision_g() {
sprintf_err!("%.2147483648g", f => Error::Overflow);
}
#[test]
fn test_non_ascii() {
assert_fmt!("%3s", "ö" => " ö");
assert_fmt!("%3s", "🇺🇳" => " 🇺🇳");
assert_fmt!("%.3s", "🇺🇳🇺🇳" => "🇺🇳");
assert_fmt!("%.3s", "a🇺🇳" => "a🇺🇳");
assert_fmt!("%.3s", "aa🇺🇳" => "aa");
assert_fmt!("%3.3s", "aa🇺🇳" => " aa");
assert_fmt!("%.1s", "𒈙a" => "𒈙");
assert_fmt!("%3.3s", "👨‍👨‍👧‍👧" => " 👨‍👨‍👧‍👧");
}
#[test]
fn test_errors() {
use Error::*;

View File

@@ -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"

View File

@@ -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 '<dir> path to ACPI info (/proc/acpi)'

View File

@@ -64,6 +64,16 @@ function __fish_adb_list_uninstallable_packages
__fish_adb_run_command pm list packages -3 | string replace 'package:' ''
end
function __fish_adb_list_local_files
set -l token (commandline -ct)*
# Unquoted $token to expand the array
# Return list of directories suffixed with '/'
find $token -maxdepth 0 -type d 2>/dev/null | string replace -r '$' /
# Return list of files
find $token -maxdepth 0 -type f -o -type l 2>/dev/null
end
function __fish_adb_list_files
set -l token (commandline -ct)
@@ -187,7 +197,8 @@ complete -n '__fish_seen_subcommand_from reconnect' -c adb -x -a device -d 'Kick
# commands that accept listing device files
complete -n '__fish_seen_subcommand_from shell' -c adb -f -a "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from pull' -c adb -F -a "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from push' -c adb -F -a "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from push' -c adb -ka "(__fish_adb_list_files)" -d 'File on device'
complete -n '__fish_seen_subcommand_from push' -c adb -ka "(__fish_adb_list_local_files)"
# logcat
complete -n '__fish_seen_subcommand_from logcat' -c adb -f

View File

@@ -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"

View File

@@ -2,7 +2,7 @@
function __fish_apt_no_subcommand -d 'Test if apt has yet to be given the subcommand'
for i in (commandline -xpc)
if contains -- $i auto manual hold unhold showauto showmanual showhold
if contains -- $i auto manual minimize-manual hold unhold showauto showmanual showhold
return 1
end
end
@@ -23,6 +23,7 @@ complete -c apt-mark -n __fish_apt_use_package -a '(__fish_print_apt_packages)'
complete -c apt-mark -s h -l help -d 'Display help and exit'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a auto -d 'Mark a package as automatically installed'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a manual -d 'Mark a package as manually installed'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a minimize-manual -d 'Mark all dependencies of meta packages as auto'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a hold -d 'Hold a package, prevent automatic installation or removal'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a unhold -d 'Cancel a hold on a package'
complete -f -n __fish_apt_no_subcommand -c apt-mark -a showauto -d 'Show automatically installed packages'
@@ -31,4 +32,6 @@ complete -f -n __fish_apt_no_subcommand -c apt-mark -a showhold -d 'Show held pa
complete -c apt-mark -s v -l version -d 'Display version and exit'
complete -r -c apt-mark -s c -l config-file -d 'Specify a config file'
complete -r -c apt-mark -s o -l option -d 'Set a config option'
complete -c apt-mark -l color -d 'Turn colors on'
complete -c apt-mark -l no-color -d 'Turn colors off'
complete -r -c apt-mark -s f -l file -d 'Write package statistics to a file'

View File

@@ -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"'

View File

@@ -72,7 +72,7 @@ function __fish_bind_complete
printf '%sshift-\tShift modifier…\n' $prefix
set -l key_names minus comma backspace delete escape \
enter up down left right pageup pagedown home end insert tab \
space f(seq 12)
space menu printscreen f(seq 12)
printf '%s\tNamed key\n' $prefix$key_names
end
end

View File

@@ -1,4 +1,13 @@
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
# 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'
@@ -13,6 +22,9 @@ 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)'
complete -c bootctl -s h -l help -d 'Show this help'
complete -c bootctl -l version -d 'Print version'

View File

@@ -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)'

View File

@@ -102,33 +102,36 @@ complete -f -c btrfs -n $restore -s S -l symlink -d 'Restore symbolic links'
complete -f -c btrfs -n $restore -s v -l verbose -d Verbose
complete -f -c btrfs -n $restore -s i -l ignore-errors -d 'Ignore errors'
complete -f -c btrfs -n $restore -s o -l overwrite -d Overwrite
complete -f -c btrfs -n $restore -s t -d 'Tree location'
complete -f -c btrfs -n $restore -s f -d 'Filesystem location'
complete -f -c btrfs -n $restore -s u -l super -d 'Super mirror'
complete -f -c btrfs -n $restore -s r -l root -d 'Root objectid'
complete -f -c btrfs -n $restore -s t -r -d 'Tree location'
complete -f -c btrfs -n $restore -s f -r -d 'Filesystem location'
complete -f -c btrfs -n $restore -s u -l super -r -d 'Super mirror'
complete -f -c btrfs -n $restore -s r -l root -r -d 'Root objectid'
complete -f -c btrfs -n $restore -s d -d 'Find dir'
complete -f -c btrfs -n $restore -s l -l list-roots -d 'List tree roots'
complete -f -c btrfs -n $restore -s D -l dry-run -d 'Only list files that would be recovered'
complete -f -c btrfs -n $restore -l path-regex -d 'Restore only filenames matching regex'
complete -f -c btrfs -n $restore -l path-regex -r -d 'Restore only filenames matching regex'
complete -f -c btrfs -n $restore -s c -d 'Ignore case (--path-regex only)'
# btrfs send
complete -f -c btrfs -n $send -s e -d ''
complete -f -c btrfs -n $send -s p -d 'Send an incremental stream from <parent> to <subvol>'
complete -f -c btrfs -n $send -s c -d 'Use this snapshot as a clone source for an incremental send'
complete -f -c btrfs -n $send -s f -d 'Output is normally written to stdout'
complete -f -c btrfs -n $send -s p -r -d 'Send an incremental stream from <parent> to <subvol>'
complete -f -c btrfs -n $send -s c -r -d 'Use this snapshot as a clone source for an incremental send'
complete -f -c btrfs -n $send -s f -r -d 'Output is normally written to stdout'
complete -f -c btrfs -n $send -l no-data -d 'send in NO_FILE_DATA mode'
complete -f -c btrfs -n $send -s v -l verbose -d 'Enable verbose output to stderr'
complete -f -c btrfs -n $send -s q -l quiet -d 'Suppress all messages, except errors'
complete -f -c btrfs -n $send -l proto -a '0 1 2' -r -d 'Use send protocol version'
complete -f -c btrfs -n $send -l proto -l compressed-data -d 'Send compressed data directly'
# btrfs receive
complete -f -c btrfs -n $receive -s v -d 'Increase verbosity about performed actions'
complete -f -c btrfs -n $receive -s q -l quiet -d 'Suppress all messages, except errors'
complete -f -c btrfs -n $receive -s f -d 'Read the stream from FILE instead of stdin'
complete -f -c btrfs -n $receive -s f -r -d 'Read the stream from FILE instead of stdin'
complete -f -c btrfs -n $receive -s e -d 'Terminate after receiving an <end cmd> marker in the stream'
complete -f -c btrfs -n $receive -s C -l chroot -d 'Confine the process to <mount> using chroot'
complete -f -c btrfs -n $receive -s E -l max-errors -d 'Terminate when NUMBER errors occur'
complete -f -c btrfs -n $receive -s m -d 'The root mount point of the destination filesystem'
complete -f -c btrfs -n $receive -s E -l max-errors -r -d 'Terminate when NUMBER errors occur'
complete -f -c btrfs -n $receive -s m -r -d 'The root mount point of the destination filesystem'
complete -f -c btrfs -n $receive -l force-decompress -r -d 'Always decompress data'
complete -f -c btrfs -n $receive -l dump -d 'Dump stream metadata'
# btrfs help
@@ -147,9 +150,11 @@ complete -f -c btrfs -n $subvolume -a show -d 'Show more information about the s
complete -f -c btrfs -n $subvolume -a sync -d 'Wait until given subvolume(s) are completely removed from the filesystem.'
# btrfs subvolume create
complete -f -c btrfs -n '__btrfs_command_groups subvolume create' -s i -d 'Add subvolume to a qgroup (can be given multiple times)'
complete -f -c btrfs -n '__btrfs_command_groups subvolume create' -s p -d 'Create any missing parent directories'
# btrfs subvolume delete
complete -f -c btrfs -n '__btrfs_command_groups subvolume delete' -s c -l commit-after -d 'Wait for transaction commit at the end of the operation'
complete -f -c btrfs -n '__btrfs_command_groups subvolume delete' -s C -l commit-each -d 'Wait for transaction commit after deleting each subvolume'
complete -f -c btrfs -n '__btrfs_command_groups subvolume delete' -s R -l recursive -d 'Delete subvolumes beneath each subvolume recursively'
complete -f -c btrfs -n '__btrfs_command_groups subvolume delete' -s v -l verbose -d 'Verbose output of operations'
# btrfs subvolume list
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s o -d 'Print only subvolumes below specified path'
@@ -164,8 +169,8 @@ complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s s -d 'List on
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s r -d 'List readonly subvolumes (including snapshots)'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s d -d 'List deleted subvolumes that are not yet cleaned'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s t -d 'Print the result as a table'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s G -d 'Filter the subvolumes by generation'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s C -d 'Filter the subvolumes by ogeneration'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s G -r -d 'Filter the subvolumes by generation'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -s C -r -d 'Filter the subvolumes by ogeneration'
complete -f -c btrfs -n '__btrfs_command_groups subvolume list' -l sort -d 'List the subvolume in order' -a '{gen,ogen,rootid,path}'
# btrfs subvolume snapshot
complete -f -c btrfs -n '__btrfs_command_groups subvolume snapshot' -s r -d 'Create a readonly snapshot'
@@ -194,6 +199,7 @@ complete -f -c btrfs -n $filesystem -a defragment -d 'Defragment a file or a dir
complete -f -c btrfs -n $filesystem -a resize -d 'Resize a filesystem'
complete -f -c btrfs -n $filesystem -a label -d 'Get or change the label of a filesystem'
complete -f -c btrfs -n $filesystem -a usage -d 'Show detailed information about internal filesystem usage.'
complete -f -c btrfs -n $filesystem -a mkswapfile -d 'Create a new swapfile'
# btrfs filesystem df
complete -f -c btrfs -n '__btrfs_command_groups filesystem df' -s b -l raw -d 'Show raw numbers in bytes'
complete -f -c btrfs -n '__btrfs_command_groups filesystem df' -s h -l human-readable -d 'Show human friendly numbers, base 1024'
@@ -230,9 +236,12 @@ complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s v -d '
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s r -d 'Defragment files recursively'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s c -d 'Compress the file while defragmenting' -ra '{zlib,lzo,zstd}'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s f -d 'Flush data to disk immediately after defragmenting'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s s -d 'Defragment only from NUMBER byte onward'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s l -d 'Defragment only up to LEN bytes'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s t -d 'Target extent SIZE hint'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s s -r -d 'Defragment only from NUMBER byte onward'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s l -r -d 'Defragment only up to LEN bytes'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s t -r -d 'Target extent SIZE hint'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -l step -r -d 'Defragment in steps of SIZE'
complete -f -c btrfs -n '__btrfs_command_groups filesystem defragment' -s L -l level -r -d 'Specify compression levels'
# btrfs filesystem usage
complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s b -l raw -d 'Show raw numbers in bytes'
complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s h -l human-readable -d 'Show human friendly numbers, base 1024'
@@ -244,6 +253,11 @@ complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s m -l mbytes
complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s g -l gbytes -d 'Show sizes in GiB, or GB with --si'
complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s t -l tbytes -d 'Show sizes in TiB, or TB with --si'
complete -f -c btrfs -n '__btrfs_command_groups filesystem usage' -s T -d 'Show data in tabular format'
# btrfs filesystem mkswapfile
complete -f -c btrfs -n '__btrfs_command_groups filesystem mkswapfile' -s s -l size -r -d 'Swapfile size'
complete -f -c btrfs -n '__btrfs_command_groups filesystem mkswapfile' -s U -l uuid -r -d 'UUID for the swapfile'
# btrfs filesystem resize
complete -f -c btrfs -n '__btrfs_command_groups filesystem resize' -l enqueue -d 'Wait for other exclusive operations'
# btrfs balance
complete -f -c btrfs -n $balance -a start -d 'Balance chunks across the devices'
@@ -252,13 +266,23 @@ complete -f -c btrfs -n $balance -a cancel -d 'Cancel running or paused balance'
complete -f -c btrfs -n $balance -a resume -d 'Resume interrupted balance'
complete -f -c btrfs -n $balance -a status -d 'Show status of running or paused balance'
# btrfs balance start
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s d -d 'Act on data chunks with FILTERS'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s m -d 'Act on metadata chunks with FILTERS'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s s -d 'Act on system chunks with FILTERS (only under -f)'
function __btrfs_balance_filters
set -l profiles raid{0,1{,c3,c4},10,5,6} dup single
set -l btrfs_balance_filters \
profiles=$profiles\t"Balances only block groups with the given profiles" \
convert=$profiles\t"Convert selected block groups to given profile" \
usage= devid= vrange= limit= strips= soft
set -l prefix (commandline -tc | string replace -r '^-d' -- '' | string match -rg '^(.*?)?[^,]*$' -- $token)
printf "%s\n" "$prefix"$btrfs_balance_filters
end
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s d -ra '(__btrfs_balance_filters)' -d 'Act on data chunks with FILTERS'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s m -ra '(__btrfs_balance_filters)' -d 'Act on metadata chunks with FILTERS'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s s -ra '(__btrfs_balance_filters)' -d 'Act on system chunks with FILTERS (only under -f)'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s v -d 'Be verbose'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -s f -d 'Force a reduction of metadata integrity'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -l full-balance -d 'Do not print warning and do not delay start'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -l background -l bg -d 'Run the balance as a background process'
complete -f -c btrfs -n '__btrfs_command_groups balance start' -l enqueue -d 'Wait for other exclusive operations'
# btrfs balance status
complete -f -c btrfs -n '__btrfs_command_groups balance status' -s v -d 'Be verbose'
@@ -279,6 +303,10 @@ complete -f -c btrfs -n '__btrfs_command_groups device scan' -s u -l forget -d '
# btrfs device stats
complete -f -c btrfs -n '__btrfs_command_groups device stats' -s c -l check -d 'Return non-zero if any stat counter is not zero'
complete -f -c btrfs -n '__btrfs_command_groups device stats' -s z -l reset -d 'Show current stats and reset values to zero'
complete -f -c btrfs -n '__btrfs_command_groups device stats' -s T -d "Print stats in a tabular form"
# btrfs device remove
complete -f -c btrfs -n '__btrfs_command_groups device remove' -l enqueue -d 'Wait for other exclusive operations'
complete -f -c btrfs -n '__btrfs_command_groups device remove' -l force -d 'Skip the safety timeout for removing multiple devices'
# btrfs device usage
complete -f -c btrfs -n '__btrfs_command_groups device usage' -s b -l raw -d 'Show raw numbers in bytes'
complete -f -c btrfs -n '__btrfs_command_groups device usage' -s h -l human-readable -d 'Show human friendly numbers, base 1024'
@@ -295,12 +323,18 @@ complete -f -c btrfs -n $scrub -a start -d 'Start a new scrub. If a scrub is alr
complete -f -c btrfs -n $scrub -a cancel -d 'Cancel a running scrub'
complete -f -c btrfs -n $scrub -a resume -d 'Resume previously canceled or interrupted scrub'
complete -f -c btrfs -n $scrub -a status -d 'Show status of running or finished scrub'
complete -f -c btrfs -n $scrub -a limit -d 'Show or set scrub limits on devices of the given filesystem'
# btrfs scrub limit
complete -f -c btrfs -n '__btrfs_command_groups scrub limit' -s d -l devid -d 'Select the device by DEVID to apply the limit'
complete -f -c btrfs -n '__btrfs_command_groups scrub limit' -s l -l limit -d 'Set the limit of the device'
complete -f -c btrfs -n '__btrfs_command_groups scrub limit' -s a -l all -d 'Apply the limit to all devices'
# btrfs scrub start
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s B -d 'Do not background'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s d -d 'Stats per device (-B only)'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s q -d 'Be quiet'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s r -d 'Read only mode'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s R -d 'Raw print mode, print full data instead of summary'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -l limit -d 'Set the scrub throughput limit'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s c -d 'Set ioprio class (see ionice(1) manpage)'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s n -d 'Set ioprio classdata (see ionice(1) manpage)'
complete -f -c btrfs -n '__btrfs_command_groups scrub start' -s f -d 'Force starting new scrub'
@@ -321,6 +355,9 @@ complete -f -c btrfs -n $rescue -a chunk-recover -d 'Recover the chunk tree by s
complete -f -c btrfs -n $rescue -a super-recover -d 'Recover bad superblocks from good copies'
complete -f -c btrfs -n $rescue -a zero-log -d 'Clear the tree log. Usable if it\'s corrupted and prevents mount.'
complete -f -c btrfs -n $rescue -a fix-device-size -d 'Re-align device and super block sizes'
complete -f -c btrfs -n $rescue -a clear-ino-cache -d 'Remove leftover items pertaining to the deprecated inode cache feature'
complete -f -c btrfs -n $rescue -a clear-space-cache -d 'Completely remove the on-disk data of free space cache of given version'
complete -f -c btrfs -n $rescue -a clear-uuid-tree -d 'Clear the UUID tree'
# btrfs rescue chunk-recover
complete -f -c btrfs -n '__btrfs_command_groups rescue chunk-recover' -s y -d 'Assume an answer of YES to all questions'
complete -f -c btrfs -n '__btrfs_command_groups rescue chunk-recover' -s v -d 'Verbose mode'
@@ -337,6 +374,8 @@ complete -f -c btrfs -n $inspect_internal -a min-dev-size -d 'Get the minimum si
complete -f -c btrfs -n $inspect_internal -a dump-tree -d 'Dump tree structures from a given device'
complete -f -c btrfs -n $inspect_internal -a dump-super -d 'Dump superblock from a device in a textual form'
complete -f -c btrfs -n $inspect_internal -a tree-stats -d 'Print various stats for trees'
complete -f -c btrfs -n $inspect_internal -a list-chunks -d 'Enumerate chunks on all devices'
complete -f -c btrfs -n $inspect_internal -a map-swapfile -d 'Find device-specific physical offset of file that can be used for hibernation'
# btrfs inspect-internal inode-resolve
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal inode-resolve' -s v -d 'Verbose mode'
# btrfs inspect-internal logical-resolve
@@ -351,20 +390,50 @@ complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s d
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s r -l roots -d 'Print only short root node info'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s R -l backups -d 'Print short root node info and backup root info'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s u -l uuid -d 'Print only the uuid tree'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s b -l block -d 'Print info from the specified BLOCK only'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s t -l tree -d 'Print only tree with the given ID'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s b -l block -r -d 'Print info from the specified BLOCK only'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -s t -l tree -r -d 'Print only tree with the given ID'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l follow -d 'Use with -b, to show all children tree blocks of <block_num>'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l noscan -d 'Do not scan the devices from the filesystem'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l bfs -d 'Breadth-first traversal of the trees, print nodes, then leaves'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l dfs -d 'Depth-first traversal of the trees'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l hide-names -d 'Print placeholder instead of names'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l csum-headers -d 'Print b-tree node checksums in headers'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-tree' -l csum-items -d 'Print checksums stored in checksum items'
# btrfs inspect-internal dump-super
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-super' -s f -l full -d 'Print full superblock information, backup roots etc.'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-super' -s a -l all -d 'Print information about all superblocks'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-super' -s s -l super -d 'Specify which SUPER-BLOCK copy to print out' -ra '{0,1,2}'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-super' -s F -l force -d 'Attempt to dump superblocks with bad magic'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal dump-super' -l bytenr -d 'Specify alternate superblock OFFSET'
# btrfs inspect-internal logical-resolve
complete -f -c btrfs -n '__btrfs_command_groups logical-resolve' -s P -d 'Print inodes instead of resolving paths'
complete -f -c btrfs -n '__btrfs_command_groups logical-resolve' -s o -d 'Ignore offsets, find all references to an extent'
complete -f -c btrfs -n '__btrfs_command_groups logical-resolve' -s s -r -d 'Set internal buffer size for storing file names'
# btrfs inspect-internal tree-stats
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -s b -d 'Show raw numbers in bytes'
# btrfs inspect-internal list-chunks
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l sort -ra 'devid pstart lstart usage length' -d 'Sort by a column (ascending)'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l raw -d 'Show raw numbers in bytes'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l human-readable -d 'Show human friendly numbers, base 1024'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l iec -d 'Use 1024 as a base (KiB, MiB, GiB, TiB)'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l si -d 'Use 1000 as a base (kB, MB, GB, TB)'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l kbytes -d 'Show sizes in KiB, or kB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l mbytes -d 'Show sizes in MiB, or MB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l gbytes -d 'Show sizes in GiB, or GB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal list-chunks' -l tbytes -d 'Show sizes in TiB, or TB with --si'
# btrfs inspect-internal map-swapfile
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal map-swapfile' -l resume-offset -s r -d 'Print the value suitable as resume offset for /sys/power/resume_offset.'
# btrfs inspect-internal tree-stats
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -s t -r -d 'Print stats only for the given treeid'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l raw -s b -d 'Show raw numbers in bytes'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l human-readable -d 'Show human friendly numbers, base 1024'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l iec -d 'Use 1024 as a base (KiB, MiB, GiB, TiB)'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l si -d 'Use 1000 as a base (kB, MB, GB, TB)'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l kbytes -d 'Show sizes in KiB, or kB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l mbytes -d 'Show sizes in MiB, or MB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l gbytes -d 'Show sizes in GiB, or GB with --si'
complete -f -c btrfs -n '__btrfs_command_groups inspect-internal tree-stats' -l tbytes -d 'Show sizes in TiB, or TB with --si'
# btrfs property
complete -f -c btrfs -n $property -a get -d 'Get a property value of a btrfs object'
@@ -381,9 +450,12 @@ complete -f -c btrfs -n '__btrfs_command_groups property list' -s t -d 'List pro
complete -f -c btrfs -n $quota -a enable -d 'Enable subvolume quota support for a filesystem.'
complete -f -c btrfs -n $quota -a disable -d 'Disable subvolume quota support for a filesystem.'
complete -f -c btrfs -n $quota -a rescan -d 'Trash all qgroup numbers and scan the metadata again with the current config.'
# btrfs quota enable
complete -f -c btrfs -n '__btrfs_command_groups quota enable' -s s -l simple -d 'Use simple quotas'
# btrfs quota rescan
complete -f -c btrfs -n '__btrfs_command_groups quota rescan' -s s -d 'Show status of a running rescan operation'
complete -f -c btrfs -n '__btrfs_command_groups quota rescan' -s w -d 'Wait for rescan operation to finish'
complete -f -c btrfs -n '__btrfs_command_groups quota rescan' -s s -l status -d 'Show status of a running rescan operation'
complete -f -c btrfs -n '__btrfs_command_groups quota rescan' -s w -l wait -d 'Wait for rescan operation to finish'
complete -f -c btrfs -n '__btrfs_command_groups quota rescan' -s W -l wait-norescan -d 'Wait for rescan to finish without starting it'
# btrfs qgroup
complete -f -c btrfs -n $qgroup -a assign -d 'Assign SRC as the child qgroup of DST'
@@ -391,6 +463,7 @@ complete -f -c btrfs -n $qgroup -a remove -d 'Remove a child qgroup SRC from DST
complete -f -c btrfs -n $qgroup -a create -d 'Create a subvolume quota group.'
complete -f -c btrfs -n $qgroup -a destroy -d 'Destroy a quota group.'
complete -f -c btrfs -n $qgroup -a show -d 'Show subvolume quota groups.'
complete -f -c btrfs -n $qgroup -a clear-stale -d 'Clear all stale qgroups whose subvolume does not exist'
complete -f -c btrfs -n $qgroup -a limit -d 'Set the limits a subvolume quota group.'
# btrfs qgroup assign
complete -f -c btrfs -n '__btrfs_command_groups qgroup assign' -l rescan -d 'Schedule qutoa rescan if needed'
@@ -424,5 +497,7 @@ complete -f -c btrfs -n $replace -a cancel -d 'Cancel a running device replace o
complete -f -c btrfs -n '__btrfs_command_groups replace start' -s r -d 'Only read from <srcdev> if no other zero-defect mirror exists'
complete -f -c btrfs -n '__btrfs_command_groups replace start' -s f -d 'Force using and overwriting <targetdev>'
complete -f -c btrfs -n '__btrfs_command_groups replace start' -s B -d 'Do not background'
complete -f -c btrfs -n '__btrfs_command_groups replace start' -l enqueue -d "Wait if there's another exclusive operation running"
complete -f -c btrfs -n '__btrfs_command_groups replace start' -s K -l nodiscard -d 'Do not perform TRIM on DEVICES'
# btrfs replace status
complete -f -c btrfs -n '__btrfs_command_groups replace status' -s 1 -d 'Only print once until the replace operation finishes'

View File

@@ -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'

View File

@@ -3,9 +3,6 @@
## --- WRITTEN MANUALLY ---
set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
# Append user-installed extensions (e.g. cargo-foo, invokable as `cargo foo`) to the list of subcommands (à la git)
set -la __fish_cargo_subcommands (complete -C'cargo-' | string replace -rf '^cargo-(\w+).*' '$1')
complete -c cargo -f -c cargo -n __fish_use_subcommand -a "$__fish_cargo_subcommands"
complete -c cargo -x -c cargo -n '__fish_seen_subcommand_from help' -a "$__fish_cargo_subcommands"
@@ -53,27 +50,6 @@ end
complete -c cargo -n '__fish_seen_subcommand_from run test build debug check' -l package \
-xa "(__fish_cargo_packages)"
# Look up crates.io crates matching the single argument provided to this function
function __fish_cargo_search
if test (string length -- "$argv[1]") -le 2
# Don't waste time searching for strings with too many results to realistically
# provide a meaningful completion within our results limit.
return
end
# This doesn't do a prefix search, so bump up the limit a tiny bit to try and
# get enough results to show something.
cargo search --color never --quiet --limit 20 -- $argv[1] 2>/dev/null |
# Filter out placeholders and "... and xxx more crates"
string match -rvi '^\.\.\.|= "0.0.0"|# .*(reserved|yanked)' |
# Remove the version number and map the description
string replace -rf '^([^ ]+).*# (.*)' '$1\t$2'
end
# Complete possible crate names by search the crates.io index
complete -c cargo -n '__fish_seen_subcommand_from add install' -n '__fish_is_nth_token 2' \
-a "(__fish_cargo_search (commandline -ct))"
## --- AUTO-GENERATED WITH `cargo complete fish` ---
# Manually massaged to improve some descriptions
complete -c cargo -n __fish_use_subcommand -l explain -d 'Run `rustc --explain CODE`'
@@ -737,6 +713,7 @@ complete -c cargo -n "__fish_seen_subcommand_from tree" -s v -l verbose -d 'Use
complete -c cargo -n "__fish_seen_subcommand_from tree" -l frozen -d 'Require Cargo.lock and cache are up to date'
complete -c cargo -n "__fish_seen_subcommand_from tree" -l locked -d 'Require Cargo.lock is up to date'
complete -c cargo -n "__fish_seen_subcommand_from tree" -l offline -d 'Run without accessing the network'
complete -c cargo -n "__fish_seen_subcommand_from uninstall" -fa '(cargo install --list | string replace -rf "(\S+) (.*):" \'$1\t$2\')'
complete -c cargo -n "__fish_seen_subcommand_from uninstall" -s p -l package -d 'Package to uninstall'
complete -c cargo -n "__fish_seen_subcommand_from uninstall" -l bin -d 'Only uninstall the binary NAME'
complete -c cargo -n "__fish_seen_subcommand_from uninstall" -l root -d 'Directory to uninstall packages from'

View File

@@ -49,10 +49,10 @@ function __fish_clj_tools -V bb_helper
bb -e "$bb_helper" tools
end
complete -c clj -s X -x -r -k -a "(__fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath or supply exec fn/args"
complete -c clj -s A -x -r -k -a "(__fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath"
complete -c clj -s M -x -r -k -a "(__fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath or supply main opts"
complete -c clj -s T -x -r -k -a "(__fish_complete_list : __fish_clj_tools)" -d "Invoke tool by name or via aliases ala -X"
complete -c clj -s X -x -r -k -a "(__fish_stripprefix='^-\w*X' __fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath or supply exec fn/args"
complete -c clj -s A -x -r -k -a "(__fish_stripprefix='^-\w*A' __fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath"
complete -c clj -s M -x -r -k -a "(__fish_stripprefix='^-\w*M' __fish_complete_list : __fish_clj_aliases)" -d "Use concatenated aliases to modify classpath or supply main opts"
complete -c clj -s T -x -r -k -a "(__fish_stripprefix='^-\w*T' __fish_complete_list : __fish_clj_tools)" -d "Invoke tool by name or via aliases ala -X"
complete -c clj -f -o Sdeps -r -d "Deps data to use as the last deps file to be merged"
complete -c clj -f -o Spath -d "Compute classpath and echo to stdout only"

View File

@@ -1,37 +1,4 @@
function __cmd_complete_args -d 'Function to generate args'
set -l current_token (commandline -tc)
switch $current_token
case '/t:*'
echo -e '0\tBlack
1\tBlue
2\tGreen
3\tAqua
4\tRed
5\tPurple
6\tYellow
7\tWhite
8\tGray
9\tLight blue
A\tLight green
B\tLight aqua
C\tLight red
D\tLight purple
E\tLight yellow
F\tBright white' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }"
case '/e:*'
echo -e 'on\tEnable command extensions
off\tDisable command extensions' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }"
case '/f:*'
echo -e 'on\tEnable file and directory name completion
off\tDisable file and directory name completion' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }"
case '/v:*'
echo -e 'on\tEnable delayed environment variable expansion
off\tDisable delayed environment variable expansion' | awk -F '\t' "{ printf \"$current_token%s\t%s\n\", \$1, \$2 }"
end
end
complete -c cmd -f -a '(__cmd_complete_args)'
complete -c cmd -f -a '(__fish_cmd__complete_args)'
complete -c cmd -f -n 'not __fish_seen_argument -w c -w k' -a /c \
-d 'Carry out the command specified by string and then stop'

View File

@@ -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'

View File

@@ -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'

View File

@@ -94,3 +94,6 @@ complete -c cryptsetup -l veracrypt-query-pim -d "Query Personal Iteration Multi
complete -c cryptsetup -l verbose -s v -d "Shows more detailed error messages"
complete -c cryptsetup -l verify-passphrase -s y -d "Verifies the passphrase by asking for it twice"
complete -c cryptsetup -l version -s V -d "Print package version"
# subcommands
complete -c cryptsetup -n "__fish_seen_subcommand_from close status resize" -f -r -a "(path basename /dev/mapper/* | string match -v control)"

View File

@@ -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"

View File

@@ -1 +1,3 @@
delta --generate-completion fish | source
# Older versions of delta do not have a --generate-completion option and will complain
# to stderr but emit nothing to stdout, making it safe (but a no-op) to source.
delta --generate-completion fish 2>/dev/null | source

View File

@@ -14,11 +14,6 @@ function __fish_diskutil_mounted_volumes
printf '%s\n' $mountpoints
end
function __fish_diskutil_writeable_volumes
set -l mountpoints (path filter -w /Volumes/*)
printf '%s\n' $mountpoints
end
function __fish_diskutil_using_not_subcommand
not __fish_seen_subcommand_from apfs
and not __fish_seen_subcommand_from appleRAID
@@ -58,7 +53,7 @@ complete -f -c diskutil -n '__fish_diskutil_using_not_subcommand umountDisk' -a
# eject
complete -f -c diskutil -n __fish_use_subcommand -a eject -d 'Eject a volume or disk'
complete -f -c diskutil -n '__fish_diskutil_using_not_subcommand eject' -a '(__fish_diskutil_writeable_volumes ; __fish_diskutil_devices)'
complete -f -c diskutil -n '__fish_diskutil_using_not_subcommand eject' -a '(__fish_diskutil_mounted_volumes ; __fish_diskutil_devices)'
# mount
complete -f -c diskutil -n __fish_use_subcommand -a mount -d 'Mount a single volume'

View File

@@ -2,8 +2,12 @@
# 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}" --installed </dev/null
dnf repoquery --cacheonly "$cur*" --qf "%{name}\n" --installed </dev/null
end
function __dnf_list_available_packages
@@ -15,9 +19,14 @@ function __dnf_list_available_packages
return
end
set -l results
# dnf --cacheonly list --available gives a list of non-installed packages dnf is aware of,
# but it is slow as molasses. Unfortunately, sqlite3 is not available oob (Fedora Server 32).
if type -q sqlite3
if __dnf_is_dnf5
# dnf5 provides faster completions than repoquery, but does not maintain the
# same sqlite db as dnf4
set results (dnf --complete=2 dnf install "$tok*")
else if type -q sqlite3
# dnf --cacheonly list --available gives a list of non-installed packages dnf is aware of,
# but it is slow as molasses. Unfortunately, sqlite3 is not available oob (Fedora Server 32).
# This schema is bad, there is only a "pkg" field with the full
# packagename-version-release.fedorarelease.architecture
# tuple. We are only interested in the packagename.
@@ -26,7 +35,7 @@ function __dnf_list_available_packages
else
# In some cases dnf will ask for input (e.g. to accept gpg keys).
# Connect it to /dev/null to try to stop it.
set results (dnf repoquery --cacheonly "$tok*" --qf "%{name}" --available </dev/null 2>/dev/null)
set results (dnf repoquery --cacheonly "$tok*" --qf "%{name}\n" --available </dev/null 2>/dev/null)
end
if set -q results[1]
set results (string match -r -- '.*\\.rpm$' $files) $results
@@ -37,7 +46,7 @@ function __dnf_list_available_packages
end
function __dnf_list_transactions
if type -q sqlite3
if not __dnf_is_dnf5 && type -q sqlite3
sqlite3 /var/lib/dnf/history.sqlite "SELECT id, cmdline FROM trans" 2>/dev/null | string replace "|" \t
end
end

View File

@@ -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=

View File

@@ -1,29 +0,0 @@
complete -c dust -s d -l depth -d "Depth to show"
complete -c dust -s n -l number-of-lines -d "Number of lines of output to show"
complete -c dust -s p -l full-paths -d "Subdirectories will not have their path shortened"
complete -c dust -s X -l ignore-directory -d "Exclude any file or directory with this name"
complete -c dust -s I -l ignore-all-in-file -d "Exclude any file or directory with a regex"
complete -c dust -s L -l dereference-links -d "dereference sym links - Treat sym links as directories and go into them"
complete -c dust -s x -l limit-filesystem -d "Only count the files and directories on the same filesystem as the supplied directory"
complete -c dust -s s -l apparent-size -d "Use file length instead of blocks"
complete -c dust -s r -l reverse -d "Print tree upside down (biggest highest)"
complete -c dust -s c -l no-colors -d "No colors will be printed"
complete -c dust -s C -l force-colors -d "Force colors print"
complete -c dust -s b -l no-percent-bars -d "No percent bars or percentages will be displayed"
complete -c dust -s B -l bars-on-right -d "percent bars moved to right side of screen"
complete -c dust -s z -l min-size -d "Minimum size file to include in output"
complete -c dust -s R -l screen-reader -d "For screen readers"
complete -c dust -l skip-total -d "No total row will be displayed"
complete -c dust -s f -l filecount -d "Directory 'size' is number of child files instead of disk size"
complete -c dust -s i -l ignore_hidden -d "Do not display hidden files"
complete -c dust -s v -l invert-filter -d "Exclude filepaths matching this regex"
complete -c dust -s e -l filter -d "Only include filepaths matching this regex"
complete -c dust -s t -l file_types -d "show only these file types"
complete -c dust -s w -l terminal_width -d "Specify width of output"
complete -c dust -s P -l no-progress -d "Disable the progress indication"
complete -c dust -s D -l only-dir -d "Only directories will be displayed"
complete -c dust -s F -l only-file -d "Only files will be displayed (finds your largest files)"
complete -c dust -s o -l output-format -d "Changes output display size"
complete -c dust -s S -l stack-size -d "Specify memory to use as stack size"
complete -c dust -s h -l help -d "Print help"
complete -c dust -s V -l version -d "Print version"

View File

@@ -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"

View File

@@ -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

View File

@@ -85,7 +85,7 @@ complete -c equery -n '__fish_seen_subcommand_from f files' -s s -l timestamp -d
complete -c equery -n '__fish_seen_subcommand_from f files' -s t -l type -d "Include file type in output"
complete -c equery -n '__fish_seen_subcommand_from f files' -l tree -d "Display results in a tree"
complete -c equery -n '__fish_seen_subcommand_from f files' -s f -l filter -d "Filter output by file type" \
-xa "(__fish_complete_list , __fish_equery_files_filter_args)"
-xa "(__fish_stripprefix='^(--filter=|-\w*f)' __fish_complete_list , __fish_equery_files_filter_args)"
# has + hasuse
complete -c equery -n '__fish_seen_subcommand_from a has h hasuse' -s I -l exclude-installed -d "Exclude installed pkgs from search path"

View File

@@ -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

View File

@@ -0,0 +1,55 @@
function __fish_firejail_profiles
path basename -- /etc/firejail/*.profile ~/.config/firejail/*.profile
end
function __fish_firejail_complete_sandboxes
firejail --list | string replace -rf -- '([^:]+):([^:]+):([^:]+):(.*)' '$1\t$3: $4 ($2)\n$3\t$1: $4 ($2)'
end
complete -c firejail -f
complete -c firejail -l help -d 'Show help and exit'
complete -c firejail -l version -d 'Show version and exit'
complete -c firejail -l debug -d 'Print debug info'
complete -c firejail -l debug-blacklists -d 'Debug blacklisting'
complete -c firejail -l debug-whitelists -d 'Debug whitelisting'
complete -c firejail -l debug-caps -d 'Print known capabilities and exit'
complete -c firejail -l debug-errnos -d 'Print known error numbers and exit'
complete -c firejail -l debug-private-lib -d 'Debug --private-lib'
complete -c firejail -l debug-protocols -d 'Print known protocols and exit'
complete -c firejail -l debug-syscalls -d 'Print known syscalls and exit'
complete -c firejail -l debug-syscalls32 -d 'Print known 32-bit syscalls and exit'
complete -c firejail -l list -d 'List all sandboxes'
complete -c firejail -l tree -d 'Print a tree of all sandboxes'
complete -c firejail -l top -d 'Monitor sandboxes (like `top`)'
complete -c firejail -l shutdown -d 'Show help and exit'
# Profiles
# Note: firejail's option parsing is weird and *requires* the --foo=bar form
# So we don't use -r
complete -c firejail -l profiles -d 'Load a custom security profile' -a '(__fish_firejail_profiles)'
# Sandboxes
complete -c firejail -l join -d 'Join existing sandbox' -a '(__fish_firejail_complete_sandboxes)'
# Files
complete -c firejail -l hosts-file -d 'Show help and exit' -a '(__fish_firejail_profiles)'
# directory
complete -c firejail -l chroot -d 'Chroot into this directory' -a '(__fish_complete_directories)'
complete -c firejail -l tmpfs -d 'Mount tmpfs into sandbox' -a '(__fish_complete_directories)'
complete -c firejail -l blacklist -d 'Blacklist dir or file' -F
complete -c firejail -l noblacklist -d 'Disable blacklist for dir or file' -F
complete -c firejail -l whitelist -d 'Whitelist dir or file' -F
complete -c firejail -l nowhitelist -d 'Disable whitelist for dir or file' -F
complete -c firejail -l read-only -d 'Set dir or file read-only' -F
complete -c firejail -l read-write -d 'Set dir or file read-write' -F
# TODO: Comma-separated ("/etc/foo,/usr/etc/foo" bind-mounts /etc/foo on /usr/etc/foo)
complete -c firejail -l bind -d 'Bind-mount file on top of another' -F
complete -c firejail -l private -d 'Mount temporary home directories and delete on exit' -F
complete -c firejail -l netfilter -d 'Enable firewall given by this file' -F
# Interfaces
complete -c firejail -l net -d 'Enable network namespace connected to this interface' -a '(__fish_print_interfaces)'
# Commands
complete -c firejail -a '(__fish_complete_subcommand)'

View File

@@ -0,0 +1,2 @@
__fish_cache_sourced_completions fish-lsp complete
or fish-lsp complete | source

View File

@@ -0,0 +1 @@
folderify --completions fish | source

View File

@@ -0,0 +1 @@
complete -c gcloud -f -a '(__fish_argcomplete_complete gcloud)'

View File

@@ -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)'

View File

@@ -1,6 +1,6 @@
# gh, at least as of version 1.17.5, does not write errors to stderr, causing
# `checks/completions.fish` to fail if the `gh-completion` module is missing.
# It also does not exit with a non-zero error code, making this harder than it needs to be :(
set completion "$(gh completion --shell fish)"
set completion "$(gh completion --shell fish 2>/dev/null)"
string match -rq '^Error' -- $completion && return -1
echo $completion | source

View File

@@ -0,0 +1,27 @@
complete -f -c git -a subtree -d 'Manage git subtrees'
# Git subtree common completions
complete -f -c git -n '__fish_git_using_command subtree' -s q -l quiet -d 'Suppress output'
complete -f -c git -n '__fish_git_using_command subtree' -s d -l debug -d 'Debug output'
complete -f -c git -n '__fish_git_using_command subtree' -s P -l path -d 'Path to the subtree'
# Git subtree subcommands
complete -f -c git -n '__fish_git_using_command subtree' -a add -d "Add a new subtree to the repository"
complete -f -c git -n '__fish_git_using_command subtree' -a merge -d "Merge changes from a subtree into the repository"
complete -f -c git -n '__fish_git_using_command subtree' -a split -d "Extract a subtree from the repository"
complete -f -c git -n '__fish_git_using_command subtree' -a pull -d "Fetch and integrate changes from a remote subtree"
complete -f -c git -n '__fish_git_using_command subtree' -a push -d "Push changes to a remote subtree"
# Completions for push and split subcommands
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split' -l annotate -d 'Annotate the commit'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split' -s b -l branch -d 'Branch to split'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split' -l ignore-joins -d 'Ignore joins during history reconstruction'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split' -l onto -d 'Specify the commit ID to start history reconstruction'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split' -l rejoin -d 'Merge the synthetic history back into the main project'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split; and __fish_contains_opt rejoin' -l squash -d 'Merge subtree changes as a single commit'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split; and __fish_contains_opt rejoin' -l no-squash -d 'Do not merge subtree changes as a single commit'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from push split; and __fish_contains_opt rejoin' -s m -l message -d 'Use the given message as the commit message for the merge commit'
# Completion for add and merge subcommands
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from add merge' -l squash -d 'Merge subtree changes as a single commit'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from add merge' -l no-squash -d 'Do not merge subtree changes as a single commit'
complete -f -c git -n '__fish_git_using_command subtree; and __fish_seen_subcommand_from add merge' -s m -l message -d 'Use the given message as the commit message for the merge commit'

View File

@@ -653,6 +653,7 @@ function __fish_git_aliased_command
end
end
set -g __fish_git_aliases
git config -z --get-regexp 'alias\..*' | while read -lz alias cmdline
set -l command (__fish_git_aliased_command $cmdline)
string match -q --regex '\w+' -- $command; or continue
@@ -778,7 +779,8 @@ function __fish_git_custom_commands
# if any of these completion results match the name of the builtin git commands,
# but it's simpler just to blacklist these names. They're unlikely to change,
# and the failure mode is we accidentally complete a plumbing command.
for name in (string replace -r "^.*/git-([^/]*)" '$1' $PATH/git-*)
set -l git_subcommands $PATH/git-*
for name in (string replace -r "^.*/git-([^/]*)" '$1' $git_subcommands)
switch $name
case cvsserver receive-pack shell upload-archive upload-pack
# skip these
@@ -882,9 +884,16 @@ short\t<sha1> / <author> / <title line>
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"
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
@@ -892,6 +901,15 @@ function __fish_git_is_rebasing
test -e (__fish_git rev-parse --absolute-git-dir)/rebase-merge
end
function __fish_git_filters
printf "%s\n" \
blob:none\t"omits all blobs" \
blob:limit=\t"omits blobs by size" \
object:type={tag,commit,tree,blob}\t"omit object which are not of the requested type" \
sparse:oid=\t"omit blobs not required for a sparse checkout" \
tree:\t"omits all blobs and trees"
end
# general options
complete git -f -l help -s h -d 'Display manual of a Git command'
complete git -f -n __fish_git_needs_command -l version -s v -d 'display git version'
@@ -1026,6 +1044,7 @@ complete -f -c git -n '__fish_git_using_command fetch' -l unshallow -d 'Convert
complete -f -c git -n '__fish_git_using_command fetch' -l refetch -d 'Re-fetch without negotiating common commits'
complete -f -c git -n '__fish_git_using_command fetch' -l negotiation-tip -d 'Only report commits reachable from these tips' -kxa '(__fish_git_commits; __fish_git_branches)'
complete -f -c git -n '__fish_git_using_command fetch' -l negotiate-only -d "Don't fetch, only show commits in common with the server"
complete -f -c git -n '__fish_git_using_command fetch' -l filter -ra '(__fish_git_filters)' -d 'Request a subset of objects from server'
# TODO other options
@@ -1340,6 +1359,7 @@ complete -f -c git -n '__fish_git_using_command clone' -s o -l origin -d 'Use a
complete -f -c git -n '__fish_git_using_command clone' -s b -l branch -d 'Use a specific branch instead of the one used by the cloned repository'
complete -f -c git -n '__fish_git_using_command clone' -l depth -d 'Truncate the history to a specified number of revisions'
complete -f -c git -n '__fish_git_using_command clone' -l recursive -d 'Initialize all submodules within the cloned repository'
complete -f -c git -n '__fish_git_using_command clone' -l filter -ra '(__fish_git_filters)' -d 'Partial clone by requesting a subset of objects from server'
### commit
complete -c git -n __fish_git_needs_command -a commit -d 'Record changes to the repository'
@@ -1440,7 +1460,7 @@ complete -c git -n '__fish_git_using_command diff' -s 1 -l base -d 'Compare the
complete -c git -n '__fish_git_using_command diff' -s 2 -l ours -d 'Compare the working tree with the "our branch"'
complete -c git -n '__fish_git_using_command diff' -s 3 -l theirs -d 'Compare the working tree with the "their branch"'
complete -c git -n '__fish_git_using_command diff' -s 0 -d 'Omit diff output for unmerged entries and just show "Unmerged"'
complete -c git -n '__fish_git_using_command diff' -n 'not __fish_git_contains_opt cached staged' -a '(
complete -c git -n '__fish_git_using_command diff' -k -n 'not __fish_git_contains_opt cached staged' -a '(
set -l kinds modified
contains -- -- (commandline -xpc) && set -a kinds deleted modified-staged-deleted
__fish_git_files $kinds
@@ -1588,6 +1608,7 @@ complete -c git -n '__fish_git_using_command log rev-list' -l bisect
complete -c git -n '__fish_git_using_command log rev-list' -l stdin -d 'Read commits from stdin'
complete -c git -n '__fish_git_using_command log rev-list' -l cherry-mark -d 'Mark equivalent commits with = and inequivalent with +'
complete -c git -n '__fish_git_using_command log rev-list' -l cherry-pick -d 'Omit equivalent commits'
complete -f -c git -n '__fish_git_using_command rev-list' -l filter -ra '(__fish_git_filters)' -d 'Omits objects from the list of printed objects'
complete -c git -n '__fish_git_using_command log' -l left-only
complete -c git -n '__fish_git_using_command log' -l right-only
complete -c git -n '__fish_git_using_command log' -l cherry
@@ -1791,6 +1812,8 @@ complete -f -c git -n '__fish_git_using_command merge' -l rerere-autoupdate -d '
complete -f -c git -n '__fish_git_using_command merge' -l no-rerere-autoupdate -d 'Do not use previous conflict resolutions'
complete -f -c git -n '__fish_git_using_command merge' -l abort -d 'Abort the current conflict resolution process'
complete -f -c git -n '__fish_git_using_command merge' -l continue -d 'Conclude current conflict resolution process'
complete -f -c git -n '__fish_git_using_command merge' -l autostash -d 'Before starting merge, stash local changes, and apply stash when done'
complete -f -c git -n '__fish_git_using_command merge' -l no-autostash -d 'Do not stash local changes before starting merge'
### merge-base
complete -f -c git -n __fish_git_needs_command -a merge-base -d 'Find a common ancestor for a merge'
@@ -2271,6 +2294,7 @@ complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subco
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from update' -s N -l no-fetch -d "Don't fetch new objects from the remote"
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from update' -l remote -d "Instead of using superproject's SHA-1, use the state of the submodule's remote-tracking branch"
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from update' -l force -d "Discard local changes when switching to a different commit & always run checkout"
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from update' -l filter -ra '(__fish_git_filters)' -d 'Request a subset of objects from server'
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from add' -l force -d "Also add ignored submodule path"
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from deinit' -l force -d "Remove even with local changes"
complete -f -c git -n '__fish_git_using_command submodule' -n '__fish_seen_subcommand_from deinit' -l all -d "Remove all submodules"
@@ -2562,16 +2586,17 @@ complete -c git -n __fish_git_needs_command -a '(__fish_git_custom_commands)' -d
function __fish_git_complete_custom_command -a subcommand
set -l cmd (commandline -xpc)
set -e cmd[1] # Drop "git".
set -lx subcommand_args
set -l subcommand_args
if argparse -s (__fish_git_global_optspecs) -- $cmd
set subcommand_args $argv[2..] # Drop the subcommand.
set subcommand_args (string escape -- $argv[2..]) # Drop the subcommand.
end
complete -C "git-$subcommand \$subcommand_args "(commandline -ct)
complete -C "git-$subcommand $subcommand_args "(commandline -ct)
end
# source git-* commands' autocompletion file if exists
set -l __fish_git_custom_commands_completion
for file in (path filter -xZ $PATH/git-* | path basename)
set -l git_subcommands $PATH/git-*
for file in (path filter -xZ $git_subcommands | path basename)
# Already seen this command earlier in $PATH.
contains -- $file $__fish_git_custom_commands_completion
and continue

View File

@@ -4,5 +4,5 @@ complete -c gpasswd -s d -l delete -d 'Remove user from group' -xa '(__fish_comp
complete -c gpasswd -s h -l help -d 'Print help'
complete -c gpasswd -s r -l remove-password -d 'Remove the GROUP\'s password'
complete -c gpasswd -s R -l restrict -d 'Restrict access to GROUP to its members'
complete -c gpasswd -s M -l members -d 'Set the list of members of GROUP' -xa '(__fish_complete_list , __fish_complete_users)'
complete -c gpasswd -s A -l administrators -d 'set the list of administrators for GROUP' -xa '(__fish_complete_list , __fish_complete_users)'
complete -c gpasswd -s M -l members -d 'Set the list of members of GROUP' -xa "(__fish_stripprefix='^(--members=|-\w*M)' __fish_complete_list , __fish_complete_users)"
complete -c gpasswd -s A -l administrators -d 'set the list of administrators for GROUP' -xa "(__fish_stripprefix='^(--administrators=|-\w*A)' __fish_complete_list , __fish_complete_users)"

View File

@@ -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"

View File

@@ -0,0 +1 @@
complete -c gsutil -f -a '(__fish_argcomplete_complete gsutil)'

View File

@@ -0,0 +1,68 @@
function __fish_guild__complete_warnings
guild compile -Whelp |
string replace --filter --regex '^\s+`([a-z\-]+)\'\s+(.+)' '$1\t$2'
printf '%s\n' 0 2 3
echo 1\tdefault
end
function __fish_guild__complete_optimizations
guild compile -Ohelp |
string replace --filter --regex '^\s+-O(.+)' '$1\nno-$1'
printf '%s\n' 0 1 3
echo 2\tdefault
end
set -l command guild
complete -c $command -f
set -l compile_condition '__fish_seen_subcommand_from compile'
complete -c $command -a 'compile\tCompile scripts' -n "not $compile_condition"
complete -c $command -s h -l help -d 'Show help' -n $compile_condition
complete -c $command -l version -d 'Show version' -n $compile_condition
complete -c $command -s L -l load-path -F \
-d 'Specify the directory to prepend to module load path' \
-n $compile_condition
complete -c $command -s o -l output -F \
-d 'Specify the output file to put bytecode in' \
-n $compile_condition
complete -c $command -s x -x \
-d 'Specify the extension to prepend to extension list' \
-n $compile_condition
complete -c $command -s W -l warning \
-a "(__fish_stripprefix='^(--warning=|-\w*W)' __fish_complete_list , __fish_guild__complete_warnings)" \
-d 'Specify the warning level for a compilation' \
-n $compile_condition
complete -c $command -s O -l optimize \
-a '(__fish_guild__complete_optimizations)' \
-d 'Specify the optimization level for a compilation' \
-n $compile_condition
for standard in 6 7
set -l option r$standard"rc"
complete -c $command -l $option \
-d "Use $(string upper -- $option) compatible mode" \
-n $compile_condition
end
complete -c $command -s f -l from \
-a 'scheme\tdefault elisp ecmascript' \
-d 'Specify the language for sources' \
-n $compile_condition
complete -c $command -s t -l to \
-a 'rtl\tdefault' \
-d 'Specify the language for an output' \
-n $compile_condition
complete -c $command -s T -l target \
-d 'Specify the target for a code' \
-n $compile_condition

View File

@@ -0,0 +1,115 @@
function __fish_guile__complete_srfis
printf '%s\n' 0\t'cond-expand' \
1\t'List library' \
2\t'and-let*' \
4\t'Homogeneous numeric vector datatypes' \
6\t'Basic String Ports' \
8\t'receive' \
9\t'define-record-type' \
10\t'Hash-Comma Reader Extension' \
11\t'let-values' \
13\t'String Library' \
14\t'Character-set Library' \
16\t'case-lambda' \
17\t'Generalized set!' \
18\t'Multithreading support' \
19\t'Time/Date Library' \
23\t'Error Reporting' \
26\t'specializing parameters' \
27\t'Sources of Random Bits' \
28\t'Basic Format Strings' \
30\t'Nested Multi-line Comments' \
31\t'A special form rec for recursive evaluation' \
34\t'Exception handling for programs' \
35\t'Conditions' \
37\t'args-fold' \
38\t'External Representation for Data With Shared Structure' \
39\t'Parameters' \
41\t'Streams' \
42\t'Eager Comprehensions' \
43\t'Vector Library' \
45\t'Primitives for Expressing Iterative Lazy Algorithms' \
46\t'Basic syntax-rules Extensions' \
55\t'Requiring Features' \
60\t'Integers as Bits' \
61\t'A more general cond clause' \
62\t'S-expression comments' \
64\t'A Scheme API for test suites' \
67\t'Compare procedures' \
69\t'Basic hash tables' \
71\t'Extended let-syntax for multiple values' \
87\t'in case clauses' \
88\t'Keyword Objects' \
98\t'Accessing environment variables' \
105\t'Curly-infix expressions' \
111\t'Boxes' \
119\t'Wisp: simpler indentation-sensitive Scheme'
end
function __fish_guile__complete_function_names
set -l path (commandline -poc |
string match --regex '.*\\.scm$' |
sed -n 1p)
test -e "$path" && begin
cat $path |
string match --all --groups-only --regex '\(\s*define\s+\(\s*(\w+)'
end
end
set -l command guile
complete -c $command -f
complete -c $command -s h -l help -d 'Show help'
complete -c $command -s v -l version -d 'Show version'
complete -c $command -s s -F -r -d 'Specify the script to run'
complete -c $command -s c -x -d 'Specify the code to run'
complete -c $command -s L -F -r \
-d 'Specify the directory to prepend to module load path'
complete -c $command -s C -F -r \
-d 'Specify the directory to prepend to module load path for compiled files'
complete -c $command -s x -x \
-a '.scm\tdefault' \
-d 'Specify the extension to prepend to extension list'
complete -c $command -s l -F -r -d 'Specify the script to load'
complete -c $command -s e -x \
-a '(__fish_guile__complete_function_names)' \
-d 'Specify the entry point of a script'
complete -c $command -o ds \
-d 'Treat the last -s option as if it occurred at this point'
complete -c $command -l use-srfi \
-a "(__fish_stripprefix='^--use-srfi=' __fish_complete_list , __fish_guile__complete_srfis)" \
-d 'Specify the SRFI modules to load'
for standard in 6 7
set -l option r$standard"rc"
complete -c $command -l $option \
-d "Use $(string upper -- $option) compatible mode"
end
complete -c $command -l debug -d 'Use debug mode'
complete -c $command -l no-debug -d "Don't use debug mode"
complete -c $command -s q -d "Don't load .guile file"
complete -c $command -l listen \
-a '37146\tdefault' \
-d 'Specify the port to list to'
complete -c $command -l auto-compile -d 'Compile scripts automatically'
complete -c $command -l fresh-auto-compile \
-d 'Compile scripts automatically forcefully'
complete -c $command -l no-auto-compile -d "Don't compile scripts automatically"
complete -c $command -l language \
-a 'scheme\tdefault elisp ecmascript' \
-d 'Specify the language for sources'

View File

@@ -58,7 +58,7 @@ complete -c hashcat -l restore -d "Restore session from --session"
complete -c hashcat -l restore-disable -d "Do not write restore file"
complete -c hashcat -l restore-file-path -rF -d "Specific path to restore file"
complete -c hashcat -s o -l outfile -rF -d "Define outfile for recovered hash"
complete -c hashcat -l outfile-format -xa "(__fish_complete_list , __fish_hashcat_outfile_formats)" -d "Outfile formats to use"
complete -c hashcat -l outfile-format -xa "(__fish_stripprefix='^--outfile-format=' __fish_complete_list , __fish_hashcat_outfile_formats)" -d "Outfile formats to use"
complete -c hashcat -l outfile-autohex-disable -d "Disable the use of \$HEX[] in output plains"
complete -c hashcat -l outfile-check-timer -x -d "Sets seconds between outfile checks"
complete -c hashcat -l wordlist-autohex-disable -d "Disable the conversion of \$HEX[] from the wordlist"
@@ -106,7 +106,7 @@ complete -c hashcat -l backend-ignore-metal -d "Do not try to open Metal interfa
complete -c hashcat -l backend-ignore-opencl -d "Do not try to open OpenCL interface on startup"
complete -c hashcat -s I -l backend-info -d "Show info about detected backend API devices"
complete -c hashcat -s d -l backend-devices -x -d "Backend devices to use"
complete -c hashcat -s D -l opencl-device-types -xa "(__fish_complete_list , __fish_hashcat_device_types)" -d "OpenCL device-types to use"
complete -c hashcat -s D -l opencl-device-types -xa "(__fish_stripprefix='^(--opencl-device-types=|-\w*D)' __fish_complete_list , __fish_hashcat_device_types)" -d "OpenCL device-types to use"
complete -c hashcat -s O -l optimized-kernel-enable -d "Enable optimized kernels (limits password length)"
complete -c hashcat -s M -l multiply-accel-disable -d "Disable multiply kernel-accel with processor count"
complete -c hashcat -s w -l workload-profile -d "Enable a specific workload profile" -xa "

View File

@@ -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

View File

@@ -0,0 +1,29 @@
function __fish_iftop_sort_orders
echo -e "2s\tSort by 2s traffic average"
echo -e "10s\tSort by 10s traffic average (default)"
echo -e "40s\tSort by 40s traffic average"
echo -e "source\tSort by source address"
echo -e "destination\tSort by destination address"
end
complete -c iftop -f
complete -c iftop -s h -d "Print a summary of usage"
complete -c iftop -s n -d "Don't do hostname lookups"
complete -c iftop -s N -d "Don't resolve port number to service names"
complete -c iftop -s p -d "Run in promiscuous mode"
complete -c iftop -s P -d "Turn on port display"
complete -c iftop -s l -d "Include link-local IPv6 addresses"
complete -c iftop -s b -d "Don't display bar graphs of traffic"
complete -c iftop -s m -x -d "Set the upper limit for the bandwidth scale"
complete -c iftop -s B -d "Show bandwidth rates in bytes/s rather than bits/s"
complete -c iftop -s i -xa "(__fish_print_interfaces)" -d "Listen to packets on interface"
complete -c iftop -s f -x -d "Use filter code to select the packets to count"
complete -c iftop -s F -x -d "Filter to only specified IPv4 network"
complete -c iftop -s G -x -d "Filter to only specified IPv6 network"
complete -c iftop -s c -r -d "Use specified config file"
complete -c iftop -s o -xa "(__fish_iftop_sort_orders)" -d "Sort by specified column"
complete -c iftop -s t -d "Use text interface without ncurses"
complete -c iftop -s L -x -d "Number of lines to print with -t"
complete -c iftop -s s -x -d "With -t, print single output after specific number of seconds"

Some files were not shown because too many files have changed in this diff Show More