Compare commits

..

205 Commits

Author SHA1 Message Date
Johannes Altmanninger
00e987df15 completions/git: stop "git for-each-ref refs/remotes/" after 200ms
See #11535
2025-06-01 17:11:54 +02:00
Johannes Altmanninger
a6ee9be72a completions/git: only look at local branches and tags when computing 50 recent commits
Commit 836b6bea73 (git completions: Add commit hashes for `show`, 2015-12-18)
made

	git show foo<TAB>

magically expand "foo" to the commit hash of a recent commit.  I would
discourage from using raw commit IDs on the command line but I guess it's the
most convenient way sometimes. Probably this is still useful to some users even
though "git show :/foo" exists.  The set of target commits was "git log -50".

Commit 3c3bf7ffd7 (completions/git: Show recent commits *on all branches*
for rebase, 2021-03-12) and others expanded the set of target commits to "git
log -50 --all" for some commands. I think Git partially sorts the result
set before returning the top 50 entries, possibly causing a slowdown.
(A slowdown is easily reproducible with "time git log --max-count=50
>/dev/null" with and without "--all").

The "--all" flag seems excessive because
1. it looks at remote branches. There can be a lot of those, especially in
   a monorepo context or when Git is configured to fetch branches from
   multiple remotes.  See also #9248 where we explicitly decided not to sort
   remote branches.
2. it looks at refs that are neither branches nor tags.
   Some systems like Jujutsu or git-branchless use such refs to prevent their
   commits from being garbage-collected. Such refs typically have opaque
   (autogenerated) IDs and should normally not be shown in a generic Git UI.

I don't know if completion of commit IDs for these kinds of refs is worth it.
(Normally you'd run something like "git checkout remote-branch" instead.)

Exclude these two types of refs.  Do include HEAD which is not a branch or
tag.  In future we could include refs like REBASE_HEAD again; though again,
I don't know if those are needed for commit-ID completion.

Given

	$ git for-each-ref refs/tags | wc -l
	1033
	$ git for-each-ref refs/heads | wc -l   # local branches
	6
	$ git for-each-ref refs/remotes | wc -l # remote branches
	5270
	$ git for-each-ref refs/jj/keep | wc -l # Jujutsu
	8390

this results in a good speedup for completions:

	$ fish -c "time complete -C'git ' >/dev/null && time complete -C'git checkout hello' >/dev/null" &| grep .
	________________________________________________________
	Executed in   68.61 millis    fish           external
	   usr time   63.50 millis   55.17 millis    8.33 millis
	   sys time   13.41 millis   13.41 millis    0.00 millis
	________________________________________________________
	Executed in  911.49 millis    fish           external
	   usr time  359.17 millis   91.00 millis  268.18 millis
	   sys time  604.22 millis   24.70 millis  579.53 millis
	$ fish -c "time complete -C'git ' >/dev/null && time complete -C'git checkout hello' >/dev/null" &| grep .
	________________________________________________________
	Executed in   70.20 millis    fish           external
	   usr time   59.81 millis   59.81 millis    0.00 millis
	   sys time   19.39 millis   12.22 millis    7.17 millis
	________________________________________________________
	Executed in  449.83 millis    fish           external
	   usr time  240.37 millis   94.17 millis  146.21 millis
	   sys time  403.66 millis   29.66 millis  374.00 millis

Part of #11535
2025-06-01 17:11:54 +02:00
Johannes Altmanninger
ad28e17b50 completions/git: sort stash completions after branches and others
Completions like "stash@{1}" don't give a lot of information, unlike local
branches which are sorted by recency so let's put those first.
2025-06-01 17:11:54 +02:00
Johannes Altmanninger
a7d9f2293e completions/git: extract logic 2025-06-01 17:11:54 +02:00
Johannes Altmanninger
df92c93332 completions/git: extract function for adding completions for arbitrary revisions
Most commands take arbitrary revisions.  AFAICT, the order should always be
the same: we list local branches before remote branches before commit IDs etc.

Let's extract a function. This adds a various revision-types that were missing.
2025-06-01 17:11:54 +02:00
Johannes Altmanninger
aebae23533 completions/git: rebase --onto requires a revision argument 2025-06-01 17:11:54 +02:00
Johannes Altmanninger
69b5ad110a completions/git: add more special refs
These are things like .git/HEAD, i.e. the ones that are typically not
namespaced under .git/refs.  The list is taken from gitrevisions(7).
2025-06-01 17:11:54 +02:00
Johannes Altmanninger
17446ad20f completions/git: fix copy-paste error
This variable is never defined. It was copied from Git's
contrib/completion/git-completion.bash where $match is probably equivalent
to $(commandline -t).  I could measure a significant speedup passing down
this filter, so let's remove it for now.
2025-06-01 17:11:54 +02:00
Daniel Rainer
8c5de9acfb Remove manual contains
See https://rust-lang.github.io/rust-clippy/master/index.html#manual_contains.

The old code results in a clippy warning on Rust 1.87.
2025-05-31 12:56:58 +02:00
Johannes Altmanninger
7a79728df3 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)
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
4cbd1b83f1 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.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
3ab6fcf21c fish_key_reader: show most specific key notation first
As of the parent commit, "ctrl-shift-x" bindings will take precedence over
"ctrl-X". Have fish_key_reader imply this via the ordering The next commit
will make this more explicit.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
08c8afcb12 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
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
3951a858dd reader: do not send queries if stdout is not a terminal
Interactive fish with output redirected ("fish >/dev/null")
is not a common use case but it is valid.

Perhaps surprisingly, "fish >some-file" *does* print terminal escape codes
(colors, cursor movement etc.) even if terminal output is not a TTY.
This is typically harmless, and potentially useful for debugging.

We also send blocking terminal queries but those are not harmless in this case.
Since no terminal will receive the queries, we hang; indefinitely as of today,
but we should give up after a timeout and print an error.  Either way that
seems needlessly surprising. Suppress queries in this case.

In future, we should probably do something similar if stdin is not a terminal;
though in that case we're even less likely to be interactive (only "-i"
I think).
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
c7a19a00ab reader: minor simplification 2025-05-29 17:57:38 +02:00
Johannes Altmanninger
e5fdd77b09 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.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
3fcdbe1a19 Discard input queue when ctrl-c is pressed while waiting for query response
On startup, we block until the terminal responds to our primary device
attribute query.
As an escape hatch, ctrl-c makes us stop waiting.

No keys are discarded; even ctrl-c is still enqueued.  Usually this isn't
noticed because typing "echo<ctrl-c>" will insert a "echo" only to immediately
clear it.

The double interpretation of ctrl-c seems odd.
Additionally, the queuing seems unsafe considering that when typing something
like "echo hello<enter><ctrl-c>" the command will be executed.

Clear the queue instead, including ctrl-c.
This matches other programs like gdb, Kakoune and possibly others.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
2071df126c Idiomatic type for reader_readline nchars argument 2025-05-29 17:57:38 +02:00
Johannes Altmanninger
4b5650ee4f 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.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
5657f093e7 Test case for autoload + erase + autoload
Commit 5918bca1eb (Make "complete -e" prevent completion autoloading,
2024-08-24) has a weird "!removed" check; it was added because "complete
-e" only needs to create the tombstone if we removed nothing.  Otherwise the
autoloader will usually take care of not loading the removed completions again.
We should probably get rid of "!removed"..  for now add a test to demonstrate
this behavior.
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
a7c04890c9 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".
2025-05-29 17:57:38 +02:00
Johannes Altmanninger
52f23b9752 autoload: add more details to autoload-result log 2025-05-29 17:50:48 +02:00
Johannes Altmanninger
6737872fb7 embed-data: naturalize generated_completions-hack to prevent repeated autoloading
As reported in https://github.com/fish-shell/fish-shell/issues/11535#issuecomment-2915440295,
a command like "complete -C'git '" gets progressively slower every time.

A diff of "fish_trace=1" output shows that each completion invocation added
more stuff to the global "__fish_git_aliases", resulting in output like:

	--> for s db
	...
	--> for s db s db
	...
	--> for s db s db s db

Reproducer:

	$ touch ~/.local/share/fish/generated_completions/foo.fish
	$ cargo install --path . --debug
	$ ~/.cargo/bin/fish -d autoload -c 'function foo; end; for i in 1 2; complete -C"foo "; end'

We redundantly autoload the embedded file, which, by definition doesn't change.
This happens when
1. the "embed-data" feature is enabled (default for "cargo install")
2. there is a completion file in generated_completions

which triggers a hack to give precedence to "embedded:completions/git.fish"
over "generated_completions/git.fish".

Since we always load all file-based files first, we clobber the autoload cache
("self.autoloaded_files") with the mtime of the generated completion file, even
if we're never gonna return it.  This makes the embed-data logic think that
the asset has changed (which is impossible! But of course it is possible that
"fish_complete_path" changes and causes a need to load "embedded:git.fish").

Fix that by treating embedded files more like normal files.  This is closer
to historical behavior where $__fish_data_dir/{functions,completions}
are normal directories. Seems like this should fix a false negative in
"has_attempted_autoload" which feels useful.

Add a dead test, I guess. It's not run with feature="embed-data" yet. In
future we should test this in CI.
2025-05-29 17:38:42 +02:00
Johannes Altmanninger
f88f7e8dd6 autoload: remove code clone 2025-05-29 16:39:52 +02:00
Johannes Altmanninger
b3dbdb90c2 On enter, insert any failed search into the command line
This might help with use cases such as https://github.com/fish-shell/fish-shell/pull/11450.
Not sure.
2025-05-29 16:39:52 +02:00
Johannes Altmanninger
dc129add9e Assert that autosuggestions are always valid
This documents an invariant established by 532abaddae (Invalidate stale
autosuggestions eagerly, 2024-12-25). It was initially broken but fixed in
ba4ead6ead (Stop saving autosuggestions that we can't restore, 2025-01-17).
2025-05-29 16:39:52 +02:00
Johannes Altmanninger
19c3bebdd9 Merge pull request #11506 2025-05-29 16:23:19 +02:00
Johannes Altmanninger
093b468ac1 Merge pull request #11502 2025-05-29 16:06:24 +02:00
Johannes Altmanninger
88bbf5f3ac Merge pull request #11497 2025-05-29 16:06:11 +02:00
Daniel Rainer
ec8fa7485c Improve docs for string join 2025-05-28 17:09:13 +02:00
Daniel Rainer
c2e2237e7c Add a test which fails on sphinx warning/failure 2025-05-28 15:32:13 +02:00
Daniel Rainer
98df97d317 Add CI check for outdated translations 2025-05-27 16:48:33 +02:00
Daniel Rainer
7ca57894cc Update translations via script
No actual translations are added.
2025-05-27 16:48:20 +02:00
Johannes Altmanninger
c7391d1026 Fix some invalid assertions parsing keys
For example the terminal sending « CSI 55296 ; 5 u » would crash fish.
2025-05-27 14:33:09 +02:00
Johannes Altmanninger
1963b0830d Merge pull request #11517 2025-05-27 13:15:34 +02:00
Johannes Altmanninger
74ce965f32 Merge pull request #11522 2025-05-27 13:15:34 +02:00
Johannes Altmanninger
27420aaf8b Merge pull request #11528 2025-05-27 13:15:34 +02:00
Johannes Altmanninger
52cdb7fd62 functions/history: error out immediately if "builtin read" failed
Didn't test all of them..

Closes #11532
2025-05-27 13:15:33 +02:00
exploide
18c4debbc0 __fish_complete_man: cope with gzipped man pages 2025-05-25 11:48:28 +02:00
Johannes Altmanninger
8617964d4d 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
2025-05-23 08:49:41 +02:00
wcbing
0d99859add completions/apt & apt-get: Let autoremove and autopurge take packages
- add complete for apt-get's autopurge
- continue #7095, add complete for apt/apt-get's autoremove and autopurge
2025-05-21 12:11:24 +08:00
nicole
0b8e0b8835 Add more completions to aptitude 2025-05-20 16:39:38 -03:00
Johannes Altmanninger
3867163193 Fixup history file EINTR loop to actually loop
Fixes d84e68dd4f (Retry history file flock() on EINTR, 2025-05-20).
2025-05-20 17:17:12 +02:00
Johannes Altmanninger
4d84e68dd4 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
2025-05-20 15:31:33 +02:00
Johannes Altmanninger
285a810814 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
2025-05-20 15:31:33 +02:00
Johannes Altmanninger
541a069a91 CI: fix detection of path to llvm-symbolizer
clang --version here outputs "clang version 19.1.7"
but it looks like that changed on GHA's Ubuntu runner:

	++ clang --version
	++ awk 'NR==1 { split($NF, version, "."); print version[1] }'
	+ llvm_version='(1ubuntu1)'

which leads to

	  The CHECK on line 7 wants:
	    abbr -a -- cuckoo somevalue # imported from a universal variable, see `help abbr`

	  but there was no remaining output to match.

	  additional output on stderr:1:111:
	    =================================================================
	    ==4680==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7bc287a5d402 at pc 0x55e597fa96b6 bp 0x7ffd2bc00700 sp 0x7ffd2bbffea8
	    READ of size 18 at 0x7bc287a5d402 thread T0
	    ==4680==WARNING: invalid path to external symbolizer!
	    ==4680==WARNING: Failed to use and restart external symbolizer!

Fix that, assuming that "clang --version" always matches the latest symbolizer
that is installed.  While at it, leave a "set -x" (which should be the
default for CI), and install llvm explicitly.
2025-05-20 14:28:38 +02:00
Johannes Altmanninger
e8864ef441 Fix stack-use-after-scope
I missed this in 7c2c7f5874 (Use uninit instead of zeroed, 2025-05-19).
See #11515
2025-05-20 14:18:04 +02:00
Johannes Altmanninger
2f708a7c0b Fix unused import 2025-05-20 12:49:25 +02:00
Johannes Altmanninger
b7a73710e2 Merge pull request #11515 2025-05-20 12:49:04 +02:00
Johannes Altmanninger
7a54ed66fb Merge pull request #11514 2025-05-20 12:39:04 +02:00
Johannes Altmanninger
99f4c09ed3 Merge pull request #11513 2025-05-20 12:39:04 +02:00
Johannes Altmanninger
e26b585ce5 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
2025-05-20 12:32:22 +02:00
王宇逸
7c2c7f5874 Use uninit instead of zeroed 2025-05-19 20:54:12 +08:00
Yuyi Wang
7b3a2900e9 Refactor *NullTerminatedArray
* Remove `strlen_safe` & `null_terminated_array_length` and use the provided method of `OwningNullTerminatedArray`.
* Remove unneeded traits and make `NullTerminatedArray` private.
2025-05-19 17:24:24 +08:00
Yuyi Wang
7a79366f91 Use CStr instead of strlen to improve readability 2025-05-19 16:47:09 +08:00
Yuyi Wang
223b98f2ff Fix build.rs to support cross-compiling to cygwin (#11512)
2719ae4 adds a special cfg for cygwin to avoid annoying warnings. As cygwin target is usually cross-compiled, cfg! is not enough to detect the correct target. This PR uses CARGO_CFG_TARGET_OS env var instead.
2025-05-19 10:27:04 +02:00
Yuyi Wang
01560bf195 Remove libc sem completely on non-linux (#11511)
As it's only used on Linux, we can cfg it out completely on other platforms. It also enables test_topic_monitor_torture on NetBSD & Cygwin.
2025-05-19 10:26:47 +02:00
Daniel Rainer
7fe34ea401 Move and rename messages template file
There is no reason to have this file clutter the repo root.
Move it into the `po` directory, and give it a more descriptive name.

Inspired by this discussion:
https://github.com/fish-shell/fish-shell/pull/11463#discussion_r2083453275

I use `template.po` instead of `message.po-template` to be more compatible with
automatic filetype detection. (e.g. vim/nvim detect the former as a po file, but
the latter as a conf file)
2025-05-18 21:31:00 -07:00
Johannes Altmanninger
36f035b52c Merge pull request #11501 2025-05-16 07:36:03 +02:00
Johannes Altmanninger
0e8edab872 Fix typo 2025-05-16 07:35:43 +02:00
Johannes Altmanninger
448d630d0c Merge pull request #11500 2025-05-16 07:35:34 +02:00
Johannes Altmanninger
38fb2cfd6d Merge pull request #11499 2025-05-16 07:32:45 +02:00
Johannes Altmanninger
d68f8bdd3b 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
2025-05-16 07:31:26 +02:00
Johannes Altmanninger
80bafd5a22 Merge pull request #11486 2025-05-16 07:12:47 +02:00
Daniel Rainer
ae8c5eaab7 Fix rst formatting issues 2025-05-16 00:30:34 +02:00
Daniel Rainer
329d190fbf Update translation docs
This is done in accordance with the recent changes to our translation pipeline.
2025-05-15 22:35:05 +02:00
Daniel Rainer
e5fa047412 Mark format strings in po files
This allows msgfmt to detect issues with translations of format strings.
The detection used here is very simple. It just checks if a string contains '%',
and if it does, the entry in the po file is preceded by '#, c-format'.
Any entries with this marker are checked by msgfmt in our tests, so if an issue
arises, we will notice before it is merged.
2025-05-15 22:09:57 +02:00
Daniel Rainer
cb31887941 Do not hardcode xgettext output path
Instead output on stdout, which lets the caller decide what to do with it.
2025-05-13 21:18:39 +02:00
Johannes Altmanninger
04fd697ac9 CONTRIBUTING: update docs on how to create a new translation 2025-05-13 00:29:05 +02:00
Johannes Altmanninger
2558d13361 Merge pull request #11488 2025-05-13 00:21:49 +02:00
Daniel Rainer
02ccf25443 Prettify profiling for multi-line commands
The old version just prints the entire command being profiled as-is.
If such a command consists of more than one line, these lines do not have any
padding, and thus visually interfere with the timings.

This commit adds padding, such that all lines but the first one have padding
prepended, such that the original line content starts at the column in which the
first line starts.

This does not work perfectly for subcommands (in the profiling sense,
where the command starts with (regex) '-+>' instead of just '>').
In such cases, even if the command string is indented in the source, the command
will not start with whitespace. However, subsequent lines are not trimmed, so
the might be indented farther than they should be relative to the first line of
the command.
2025-05-13 00:11:33 +02:00
Johannes Altmanninger
a88acb9715 Merge pull request #11487 2025-05-13 00:01:11 +02:00
Johannes Altmanninger
8d3ad0c3c3 Merge pull request #11485 2025-05-13 00:01:11 +02:00
Johannes Altmanninger
660f52ee4f Merge pull request #11463 2025-05-13 00:01:11 +02:00
Johannes Altmanninger
594b8730d8 completions/git: fix regression causing wrong remote-branch completions
Fixes 54971621de (completions/git: show url as description for remote
completion, 2025-04-13).
Fixes #11482
2025-05-13 00:01:11 +02:00
Johannes Altmanninger
107e4d11de 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
2025-05-13 00:01:11 +02:00
Johannes Altmanninger
50500ec5b9 Fix typo causing wrong cursor position after Vi mode paste
Regressed in d51f669647 (Vi mode: avoid placing cursor beyond last character,
2024-02-14).
2025-05-12 22:57:20 +02:00
Daniel Rainer
3ccce609f0 Add script for updating translations
The purpose of this script is to simplify the translation-related workflow for
both developers and translators. It runs the xgettext, msgmerge, msgfmt pipeline
(or only parts of it, depending on the arguments), either for all languages, or
for one specific one.

Developers can use the script with the `--no-mo` flag to update the PO files for
all languages after changes to the Rust/fish sources, to keep the translations
up to date. Ideally, this would run automatically for all changes, such that
translations are always up to date, but for now, it would already be an
improvement to run this script before releasing a new version of fish.

Translators can use the script in the same way as developers, to get up to date
PO files. To see their translations in action, the script can be called with
`--only-mo`, which takes the current version of the PO files and generates MO
files from them, which get placed in a location which fish (built with `cargo
build`) can detect.
Translators might also find it useful to specify the language they want to work
on as a non-option argument. This argument should be the path to the po file
they want to work on. Specifying non-existing files to work on a new language is
allowed, but the files must be in the po directory and follow the naming
convention.
2025-05-12 22:49:30 +02:00
Alan Somers
bd26d4b61b Fix use of deprecated symbols in Nix 2025-05-12 13:28:56 -06:00
Alan Somers
7f4998ad9b Fix remote filesystem detection on FreeBSD
Need an extra include to get the definition of MNT_LOCAL

Fixes #11483
2025-05-12 13:18:21 -06:00
Daniel Rainer
122f39de66 Replace loop by pipeline
This simplifies the logic a bit and performs a better.

Performance improvements for extract_fish_script_messages (time in
microseconds):
- explicit regex: from 128241 to 83471 (speedup 1.5)
- implicit regex: from 682203 to 463635 (speedup 1.5)
2025-05-12 20:54:32 +02:00
Daniel Rainer
1df8fbff67 Replace long list by file
The replaces the `strs` list by a corresponding file, which eliminates the need
for looping over the list.

Use sed to transform strings into gettext po format entries.

Format the file with fish_indent and use more expressive variable name for the
file cargo expand writes to.

Performance improvements (in microseconds):
- sort+format rust strings: from 21750 to 11096 (speedup 2.0)
2025-05-12 20:35:41 +02:00
Daniel Rainer
ff5ff50183 Speed up constant string extraction
The fish builtin string functions are significantly slower than grep + sed.
The final replacement of \' to ' also does not make any sense here, because
single quotes appear unescaped in Rust strings.

Performance improvement: from 404880 to 44843 (speedup 9.0)

Profiling details (from separate runs):
Time (μs)   Sum (μs)  Command
       174     404880 > set -a strs (string match -rv 'BUILD_VERSION:|PACKAGE_NAME' <$tmpfile |
             string match -rg 'const [A-Z_]*: &str = "(.*)"' | string replace -a "\'" "'")
    404706     404706 -> string match -rv 'BUILD_VERSION:|PACKAGE_NAME' <$tmpfile |
             string match -rg 'const [A-Z_]*: &str = "(.*)"' | string replace -a "\'" "'"

       202      44843 > set -a strs (grep -Ev 'BUILD_VERSION:|PACKAGE_NAME' <$tmpfile |
             grep -E 'const [A-Z_]*: &str = "(.*)"' |
             sed -E -e 's/^.*const [A-Z_]*: &str = "(.*)".*$/\1/' -e "s_\\\'_'_g")
      4952      44641 -> grep -Ev 'BUILD_VERSION:|PACKAGE_NAME' <$tmpfile |
             grep -E 'const [A-Z_]*: &str = "(.*)"' |
             sed -E -e 's/^.*const [A-Z_]*: &str = "(.*)".*$/\1/' -e "s_\\\'_'_g"
     28716      28716 --> command grep --color=auto $argv
     10973      10973 --> command grep --color=auto $argv
2025-05-12 20:11:05 +02:00
Daniel Rainer
c0d93e4740 Do not use huge fish list
Using a file is significantly faster.

Profiling overview (times in microseconds):
- cargo expand: from 4959320 to 4503409 (speedup 1.1)
- gettext call pipeline: from 436996 to 13536 (speedup 32.3)
- static string pipeline: from 477429 to 404880 (speedup 1.18)
2025-05-12 18:12:37 +02:00
Daniel Rainer
55752729d6 Fix escaping in translation 2025-05-12 00:51:07 +02:00
Johannes Altmanninger
41dfb5147f Fix typo in set_color test 2025-05-11 22:55:48 +02:00
Johannes Altmanninger
156fa8081c Underline styles for double/dotted/dashed
My phone uses dotted underline to indicate errors; that seems nice, a bit
less aggressive than curly.  Unfortunately dotted underlines are not as well
supported in terminal emulators; sometimes they are barely visible.  So it's
unlikely that we want to use --underline=dotted for an important theme.
Add double and dashed too I guess, even though I don't have a concrete
use case..
2025-05-11 22:18:06 +02:00
Johannes Altmanninger
3081d0157b 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
2025-05-11 22:05:00 +02:00
Johannes Altmanninger
13e4736113 completions/commandline: don't offer deprecated option 2025-05-11 22:00:43 +02:00
Johannes Altmanninger
80e30ac756 Always treat brace at command start as compound statement
For backwards compatibility, fish does not treat "{echo,hello}" as a compound
statement but as brace expansion (effectively "echo hello").  We interpret
"{X...}" as compound statement only if X is whitespace or ';' (which is an
interesting solution).

A brace expansion at the very start of a command 
is usually pointless (space separation is shorter).
The exception are cases where the command name and the first few arguments
share a suffix.

	$ {,1,2,3,4}echo
	1echo 2echo 3echo 4echo

Not sure if anyone uses anything like that.  Perhaps we want to trade
compatibility for simplicity. I don't have a strong opinion on this.

Always parse the opening brace as first character of a command token as
compound statement.
Brace expansion can still be used with a trick like: «''{echo,foo}»

Closes #11477
2025-05-11 22:00:43 +02:00
Daniel Rainer
a86a4dfabf Remove source locations from translations
Source locations (file name and line number) where a string originates is not
required by gettext tooling. It can help translators to identify context,
but the value of this is reduced by our lack of context support, meaning that
all occurrences of a string will receive the same translation.
Translators can use `rg` or similar tools to find the source locations.
For further details see this thread:
https://github.com/fish-shell/fish-shell/pull/11463#discussion_r2079378627

The main advantage is that updates to the PO files are now only necessary when
the source strings change, which greatly reduces the diff noise.

A secondary benefit is that the string extraction logic is simplified.
We can now directly extract the strings from fish scripts,
and several issues are fixed alongside, mostly related to quoting.
The regex for extracting implicit messages from fish scripts has been tweaked to
ignore commented-out lines, and properly support lines starting with `and`/`or`.
2025-05-11 21:10:03 +02:00
Daniel Rainer
22bc8e12c9 Fix xgettext implicit regex
The old regex has the problem that it does not handle lines containing any
non-space characters in front of ` complete` (or ` function`), which results in
`string replace` leaving this part in the resulting string.
For example,
`and complete -d "foo"`
would turn into
`andN_ foo`
if passed to
`string replace --regex $regex 'N_ $1'` (where `$regex` is the `$implicit_regex`) variable.
Another issue are commented-out lines.
2025-05-11 21:10:03 +02:00
Peter Ammon
6c23c6f29b Add myself as SECURITY contact and reformat 2025-05-11 11:48:03 -07:00
Josef Andersson
39fd959eea Add initial security policy
Signed-off-by: Josef Andersson <janderssonse@proton.me>
2025-05-11 11:45:15 -07:00
Johannes Altmanninger
cc2ca60baa commandline.rst: deprecate --tokens-raw option
This was added without a use case.  Now there is a use case (#11084) that
needs it to include all tokens which the sister option "--tokens-expanded"
should not do.  The inconsistency is probably not worth it, given that this
"--tokens-raw" use case can be served by a future "read -zal --tokenize-raw".
2025-05-11 12:46:08 +02:00
Johannes Altmanninger
83f74f9332 builtin commandline: fix "-x" spuriously including redirection targets
completions frequently use

	argparse ... -- (commandline -xpc)

The "commandline -xpc" output
contains only string tokens.

A syntactically-valid process ("-p") consistes of only string tokens
and redirection tokens.  We skip all non-string tokens, but we do include
redirection targets, which are always strings.  This is weird, and confuses
completion scripts such as the one above.  Leave out redirection targets too.

Part of #11084
2025-05-11 12:46:08 +02:00
Johannes Altmanninger
58af4fa34c builtin commandline: rename tokenization mode 2025-05-11 12:46:08 +02:00
Daniel Rainer
f23501dbdc Add locale directory to config log 2025-05-11 09:27:35 +02:00
DaiLu Cao
035cd369c2 Supplement Chinese translation
Squashed commit of the following:

commit 23163d40bed2d97c72050990cf15db3944ce2ff0
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 24 10:11:04 2025 +0800

    Manually review up to line 1055 and modify all Chinese colons ':' to English ':' to prevent potential unknown errors.

commit dca5fb8182b94bffab5034dc5626b2b98d026b6f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 17 10:50:13 2025 +0800

    Manually proofread up to 340 lines

commit 4b2d91c1138f3c8dec15b68aeb0510f02e15a776
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Thu Apr 17 09:50:21 2025 +0800

    use msgfmt check and fix all error

commit e2470d81c01ab7bf46d3d6ffd0291a05d4b38e13
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Wed Apr 16 11:10:54 2025 +0800

    Fix translation error converting '\\n' to '\\ n' error

commit 7ff970d06ce950aee35e1fb0ec70338f7bd42c1d
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Wed Apr 16 10:53:38 2025 +0800

    Fix make error, local cargo test completed

commit 018dfa225530a85486903ef58d47f4c358956b0b
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 16:46:36 2025 +0800

    modification of make errors

commit cbebd506a500aecc0669dce7f08422fcfed5615f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:45:01 2025 +0800

    The second modification of make errors are all symbol problems

commit f75c3f7a2a84ffaea4eb642532b5a24da1c9154f
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:27:01 2025 +0800

    Re-add Chinese translation, try to solve the problem of make failing

commit 58551be20d261e3466a9e4ede290675f633e94a3
Author: DaiLu Cao <caodailu@foxmail.com>
Date:   Fri Apr 11 15:06:01 2025 +0800

    Supplement Chinese translation
2025-05-08 19:17:46 -07:00
Cuichen Li
3bef4863cf Revert "Work around $PATH issues under WSL (#10506)"
This reverts commit 3374692b91.
2025-05-08 18:35:56 -07:00
Daniel Rainer
2d58cfe4cb Remove line numbers from translation strings
This greatly reduces the number of changes necessary to the PO files when the
Rust/fish source files are updated. (Changes to the line number can be applied
automatically, but this adds a lot of noise to the git history.)

Due to the way we have been extracting Rust strings, differentiation between
the same source string in different contexts has not been possible regardless
of the change.

It seems that duplicate msgid entries are not permitted in PO files, so since we
do not use context to distinguish the strings we extract, there is no way to
have context-/location-dependent translations, so we might as well reduce the
git noise by eliminating line numbers.

Including source locations helps translators with understanding context.
Because we do not distinguish between contexts for a given source string,
this is of limited utility, but keeping file names at least allows to open the
relevant files and search them for the string. This might also be helpful to
identify translations which do not make sense in all context in which they are
used. (Although without adding context support, the only remedy would be to
remove the translation altogether, as far as I can tell.)

For extraction from Rust, additional issues are fixed:
- File name extraction from the grep results now works properly. Previously,
  lines not starting with whitespace resulted in missing or corrupted matches.
  (missing if the source line contains no colon followed by a whitespace,
  corrupted if it does, then the match included the part of the line in front of
  the colon, instead of just the location)
- Only a single source location per string was supported (`head -n1`). The new
  approach using sed does not have this limitation.
2025-05-08 18:15:56 +02:00
David Adam
df591a2e0f fish.spec/Debian packaging: drop man dependency in favour of groff 2025-05-08 22:16:33 +08:00
Johannes Altmanninger
ecefce2ea8 Fix "help printf" on --features=embed-data builds 2025-05-08 11:11:15 +02:00
Peter Ammon
786239d280 Changelog fix for #11465 2025-05-07 18:28:25 -07:00
Carl Andersson
7a668fb17e Unset SYSTEMD_COLORS for systemd completion
Fixes an issue where systemctl and other systemd commands completions are prefixed by ANSI color escape codes
2025-05-07 18:23:51 -07:00
Johannes Altmanninger
bf2f7ee6c0 Respect feature flags in fish_key_reader, fix display of "?" key
Commit daa692a20b (Remove unnecessary escaping for # and ~ inside key name
tokens, 2025-04-01) stopped escaping ? in fish_key_reader output.  This is
generally correct but not if the "qmark-noglob" feature flag is turned off.
Add that back, to be safe.

While at it, pass an environment variable more explicitly in a test.
2025-05-07 17:19:51 +02:00
Johannes Altmanninger
2f762e2da1 completions/cargo: re-use __fish_cargo
Technically this is in the autogenerated part, but I'm not sure how I can
re-generate it with today's cargo.
2025-05-07 17:17:09 +02:00
Benjamin VERGNAUD
11d8b83838 completions/cargo: enforce color off
Signed-off-by: Benjamin VERGNAUD <ben@bvergnaud.fr>
2025-05-06 15:39:39 +02:00
Yuyi Wang
c2eaef7273 Update nix to 0.30.1 (#11458)
After nix updated to 0.30, all functions related to file descriptor accepts impl AsFd, e.g., BorrowedFd. This PR is a minimal update. It tries to use impl AsFd as long as possible, but uses BorrowedFd in some places. Yes it introduces unsafe, but doesn't introduce new unsafe code.
2025-05-06 10:52:54 +02:00
Yuyi Wang
2f278f4bfa Update errno to 0.3.11 2025-05-06 10:44:18 +08:00
Ethan Fredsti
1e61e6492d fixed typo mentioned in issue #11454
I found the same typo mentioned in issue #11454 in this file and proposed the suggested change.
2025-05-04 19:52:06 -07:00
Peter Ammon
c993fd022c Rework fish AST implementation
This merges a large set of changes to the fish AST, with the intention of
making the code simpler.

There's no expected user-visible changes here, except for some minor
changes in the output of `fish_indent --dump-parse-tree`.

Ast parsing is about 50% faster measured via
`cargo +nightly bench  --features=benchmark bench_ast_construction`
and also uses less memory due to some size optimization.

The biggest change is removing the `Type` notion from `Node`. Previously
each Node had an integer type identified with it, like Type::Argument. This
was a relic from C++: types were natural in C++ and we could use LLVM-style
RTTI to identify Nodes, leveraging the fact that C++ has inheritance and so
Type could be at the same location in each Node.

This proved quite awkward in Rust which does not have inheritance. So
instead we switch to a new notion, Kind:

    pub enum Kind<'a> {
        Redirection(&'a Redirection),
        Token(&'a dyn Token),
        Keyword(&'a dyn Keyword),
        VariableAssignment(&'a VariableAssignment),
                ...

and a `&dyn Node` can now return its Kind. Basically leveraging Rust's enum
types.

Interesting lesson about the optimal way to construct ASTs in both
languages.
2025-05-04 19:45:36 -07:00
Peter Ammon
fe10f65587 ast: Box redirections in ArgumentOrRedirection
Redirections are bigger and less common.

Reduces ast size of __fish_complete_gpg.fish by ~28 KB.
2025-05-04 19:38:08 -07:00
Peter Ammon
b98c5ee897 ast: remove NodeSubTraits
This can be implemented directly in Node.
2025-05-04 19:37:25 -07:00
Peter Ammon
9ccff5ad5d ast: Clean up implement_acceptor_for_branch macro
We no longer need the field types to be passed to the macro.
2025-05-04 18:59:13 -07:00
Peter Ammon
55f70cbb6d ast: Clean up more macros
Factor some logic out of macros into a trait, to reduce the macro
complexity.
2025-05-04 18:59:13 -07:00
Peter Ammon
b7005e8378 ast: clean up NodeVisitorMut
This eliminates a bunch of the different functions from NodeVisitorMut.

It also removes the runtime polymorphism - now it's a generic instead of
using &dyn. The reason is that there's only one implementation of
NodeVisitorMut so there's no size savings from polymorphism.
2025-05-04 18:59:13 -07:00
Peter Ammon
1f79d48a48 ast: further macro cleanup 2025-05-04 18:59:13 -07:00
Peter Ammon
e9036774cb ast: simplify visitor_accept_field macro
This is a relic from when we used to support visiting in reverse order; we can
simplify this.
2025-05-04 18:59:13 -07:00
Peter Ammon
2cd185a4f1 ast: Eliminate ConcreteNode trait
Fold this into Node
2025-05-04 18:59:13 -07:00
Peter Ammon
bb92d82c3b ast: remove types 2025-05-04 18:59:13 -07:00
Peter Ammon
f9ba834788 ast: further migration from type to kind 2025-05-04 18:59:13 -07:00
Peter Ammon
d23b8af60d ast: More migration from type to kind 2025-05-04 18:59:13 -07:00
Peter Ammon
82eacb6d50 ast: Switch from type to kind in is_same_node 2025-05-04 18:59:13 -07:00
Peter Ammon
c62b09d5d1 ast: Switch from some types to kinds
Preparing to remove types entirely
2025-05-04 18:59:13 -07:00
Peter Ammon
ccfe949514 ast: make Ast generic
We can parse two different things via Ast:

1. A regular job list
2. A freestanding argument list, as used in `complete --arguments ...`

This second case is specific to one use.

Prior to this commit, we parsed the Ast and then "forgot" what we parsed,
storing a &dyn Node. Then we had to cast it to the right type, and assert,
and etc.

Make Ast generic over the Node type it parsed, and default the Node type to
JobList. This simplifies call sites.
2025-05-04 18:59:13 -07:00
Peter Ammon
ccc75d08f3 ast: remove all of the as_foo functions from Node
Kind has subsumed these.
2025-05-04 18:59:05 -07:00
Peter Ammon
dfac66082a ast: adopt Kind in yet more places 2025-05-04 18:59:05 -07:00
Peter Ammon
9ae01ae00d ast: adopt Kind in more places 2025-05-04 18:59:05 -07:00
Peter Ammon
51784b090d ast: adopt Kind in parse_util_detect_errors_in_ast 2025-05-04 18:59:05 -07:00
Peter Ammon
8115982485 ast: adopt Kind in highlighting 2025-05-04 18:59:05 -07:00
Peter Ammon
d88a656e9e ast: further adoption of Kind 2025-05-04 18:59:05 -07:00
Peter Ammon
d6ee4ec698 ast: Clean up BlockStatementHeader
Make this a real Node.
2025-05-04 18:59:05 -07:00
Peter Ammon
dbae271fe7 ast: remove StatementVariant
Statement is the new StatementVariant.
2025-05-04 18:59:05 -07:00
Peter Ammon
a4ec30f298 ast: Remove StatementVariant::None
We can do without this.
2025-05-04 18:59:05 -07:00
Peter Ammon
ee9cf33689 ast: Remove Node::category
This is now unused.
2025-05-04 18:59:05 -07:00
Peter Ammon
11b6bf31c0 ast: Minor cleanup of source ranges 2025-05-04 18:59:05 -07:00
Peter Ammon
4f0e11383e ast: Remove as_mut_foo() functions
Kinds have replaced these.
2025-05-04 18:59:05 -07:00
Peter Ammon
bf78309f79 ast: adopt Kinds in more places 2025-05-04 18:59:05 -07:00
Peter Ammon
01bd854f25 ast: introduce Kind and cast
This begins the process of replacing the underlying Node "type" notion with
Kind. A Kind is an Enum of all of the possible node types, except with
Token and Keyword collapsed into one.

The idea is, rather than this:

    if node.type() == Type::Argument {
	    let arg = node.as_argument().unwrap();
		...
	}

we can instead do this:

    if let Kind::Argument(arg) = node.kind() {
	    // we already have arg
	}

There is also a cast() function:

    let arg: Option<Argument> = node.cast()

which may be convenient in some places.

The big thing we lose is the ability to talk about a Node's type without
actually having a Node. But this turns out to not be an issue in practice.

Future commits will begin adopting Kind.
2025-05-04 18:59:05 -07:00
Peter Ammon
0348389195 ast: Remove as_mut_leaf
This was unused.
2025-05-04 18:28:25 -07:00
Peter Ammon
e05ecd6c7d ast: clean up lists
Make working with lists more natural
2025-05-04 18:28:25 -07:00
Peter Ammon
325232bec1 ast: remove the ability to traverse in reverse
Prior to this commit, each Node in the ast could accept a visitor and visit
children either in order or in reverse order. This reverse feature added a lot
of complexity and the only client is Traversal.

Switch Traversal to reverse the nodes itself and remove the reverse bool
elsewhere, leading to some code simplifications.
2025-05-04 17:09:00 -07:00
Peter Ammon
b78d168050 ast: eliminate ArgumentOrRedirectionVariant
Just use ArgumentOrRedirection directly. Continued simplification.
2025-05-04 17:09:00 -07:00
Peter Ammon
31edcf029b ast: factor out as_node
Shrink another macro.
2025-05-04 17:09:00 -07:00
Peter Ammon
27dc4b3c8a ast: Blanket implementation of NodeMut
Continue to shrink the implement_node! macro.

No functional changes expected.
2025-05-04 17:09:00 -07:00
Peter Ammon
77a4f38a13 ast: derive Category from Type
In the fish AST, each node falls into one of three "categories":

    1. A branch: contains child nodes
    2. A leaf: no child nodes, contains a source range
    3. A list: a sequence of child nodes and nothing more

Prior to this commit the category was explicit in the code for each Node type;
make it instead derived from the node's type. This continues to shrink our
macros.

No functional change expected.
2025-05-04 17:09:00 -07:00
Peter Ammon
e9d396615b ast: push try_source_range into default Node implementation
Minor refactoring, reducing macro size.
2025-05-04 17:09:00 -07:00
Peter Ammon
79ec558d08 ast: remove Default implementation
This doesn't make much conceptual sense, and isn't required.

Do some other miscellaneous cleanup.
2025-05-04 17:09:00 -07:00
Peter Ammon
719a5d2909 ast: remove stale parent pointer comment
It no longer applies.
2025-05-04 17:08:59 -07:00
Peter Ammon
93962c82df ast: store &dyn Node and not &dyn NodeMut
Minor simplifications.
2025-05-04 17:08:59 -07:00
Johannes Altmanninger
111922b60f Fix export test on macOS GHA runner
This system sets something like
$MANPATH: originally inherited as |/Applications/Xcode_15.4.app/...|
2025-05-04 18:19:42 +02:00
Johannes Altmanninger
cb92a5530f functions/export: fix for path variables
Commit f38646593c (Allow `export` to set colon-separated `PATH`, `CDPATH`
and `MANPATH`., 2017-02-10)
did something very weird for «export PATH=foo».
It essentially does

	set -gx PATH (string replace -- "$PATH" (string join ":" -- $PATH) foo)

which makes no sense.  It should set PATH to "foo", no need to involve the
existing value of $PATH.

Additionally, the string split / string join dance is unnecessary.  Nowadays,
builtin set already handles path variables as is needed here, so get rid of
this special case.

Fixes #11434
2025-05-04 18:06:18 +02:00
Johannes Altmanninger
dd4c04e2ff Fix empty soft-wrapped line not being removed before execution
Commit 7acc2b7 added an empty line to our screen representation if we are
wrapped. This regressed the fix for #6826.  In the attached test case, there is
a spurious empty line after the first one.  Adjust the fix to remove it again.

Patch-by: kerty <g.kabakov@inbox.ru>
https://github.com/fish-shell/fish-shell/pull/11153#issuecomment-2800087389
2025-05-04 12:50:12 +02:00
Johannes Altmanninger
6fec5ab320 completions/wpctl: fix when "settings" subcommand is not available
The error is printed to stdout, see
https://github.com/fish-shell/fish-shell/pull/11438#discussion_r2072455009
2025-05-04 12:06:01 +02:00
Johannes Altmanninger
ada9aff63e Merge pull request #11453 2025-05-04 12:01:06 +02:00
Johannes Altmanninger
1d63c1f188 Merge pull request #11399 2025-05-04 11:58:05 +02:00
Johannes Altmanninger
a12298152f Merge pull request #11448 2025-05-04 11:57:18 +02:00
Bergbok
83b10c3919 Rephrase set_color tutorial docs
Closes #11446
2025-05-04 11:56:14 +02:00
Johannes Altmanninger
4a3fc5211f Document workaround for making tab focus search field
Closes #11450
Closes #11449
2025-05-04 11:56:14 +02:00
239
9f80e1f225 completions/keybase: update to 6.4.0
Closes #11428
2025-05-04 11:56:14 +02:00
fabiojb
9a8d578142 completion(winetricks): redirect winetricks list-all sderr to /dev/null 2025-05-03 18:25:17 -03:00
Daniel Rainer
09eae92888 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.
2025-05-03 22:53:27 +02:00
Daniel Rainer
af6c3eb69f Ensure that strings do not get wrapped in po files 2025-05-03 16:07:20 +02:00
Daniel Rainer
dd5864ce13 Add quotes around gettext string
This should prevent occurrences of the search string from being found in other
locations (e.g. in a comment).

The whole approach of string extraction from Rust sources is sketchy,
but this at least prevents producing garbage when the content of a string
appears somewhere else unquoted.
2025-05-03 16:07:20 +02:00
Daniel Rainer
d31dc9ffd8 Fix fish script translation file generation
The previous version generates files which do not preserve the line number from
the original fish script file, resulting in translation not working.

The new approach is quite ugly, and might have some issues,
but at least it seems to work in some cases.
2025-05-03 16:07:03 +02:00
Daniel Rainer
d5e80d43d9 Extract function for gettext extraction
Extracting explicit and implicit messages works essentially the same way, which
is also reflected in the code being identical, except for the regex.

Extract the duplicated code into a function.
2025-05-03 16:03:03 +02:00
Johannes Altmanninger
0d59e89374 completions/wpctl: silence stderr
In case the command is missing, I guess
See https://github.com/fish-shell/fish-shell/pull/11438
2025-05-03 14:15:33 +02:00
Johannes Altmanninger
8b1f72c54b completions/tmutil: namespace 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
54a5ade57d Merge pull request #11394 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
7c25d6a1ba Merge pull request #11443 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
a5a5dc46e4 Merge pull request #11438 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
1687b3fe7a Merge pull request #11377 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
f3ddf793a3 Merge pull request #11381 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
647ae7da8c Merge pull request #11411 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
0950cd1598 Merge pull request #11422 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
a1b1bff97b Merge pull request #11441 2025-05-03 14:15:33 +02:00
Johannes Altmanninger
a95be351fb Merge pull request #11447 2025-05-03 14:15:33 +02:00
Axlefublr
91b9bbf651 fix single backticks 2025-05-03 19:26:07 +08:00
Johannes Altmanninger
c14e8c1939 Fix assertion error in set_color
This doesn't hold for e.g. TERM=linux-m fish -c 'set_color red'
2025-05-03 12:56:45 +02:00
Daniel Rainer
7e4c3b9fa7 Use workspace config in packages
- Apply lint config to entire workspace

- Inherit workspace config for fish-printf

- Allow stdlib printing in fish-printf tests

The current problem which is addressed by this is that warnings about C-String
literals are generated by clippy for code in fish-printf. These literals are not
available with the current MSRV 1.70, but previously the MSRV setting was not
inherited by fish-printf, causing the warning to appear.
2025-05-02 22:31:39 +02:00
Fabian Boehm
8048e38ea4 docs: Actually document commandline --input
This is a useful option and has been a thing for years.
2025-05-02 20:55:36 +02:00
Fabian Boehm
8a5a547d88 builtins/commandline: Correct error message 2025-05-02 20:54:29 +02:00
Johannes Altmanninger
48704dc612 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
2025-05-02 08:31:15 +02:00
Johannes Altmanninger
8abab0e2cc Explicit type for "$()" hack in parse_util_locate_cmdsub 2025-05-02 08:31:15 +02:00
Johannes Altmanninger
bd178c8ba8 Remove code clone in parse_util_locate_cmdsub 2025-05-02 08:31:15 +02:00
Johannes Altmanninger
cb719cd418 Remove dead code
Introduced in 149594f974 (Initial revision, 2005-09-20).
2025-05-02 08:31:15 +02:00
Johannes Altmanninger
1ff8f983c4 Remove obsolete Vi mode delete key workaround
As reported in
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$n20_uqiMqatEQcPG79Ca0c2_YvHBHTr-yCVXTEuze_Y

commit f5fac096c0 (Don't move cursor in delete-char, 2017-04-19) fixed the
behavior of Vi mode keys "delete" and "x" when the cursor is at the end of
the buffer, and commit d51f669647 (Vi mode: avoid placing cursor beyond
last character, 2024-02-14) generalized this fix.

This means that the delete-specific fix is no longer necessary. Remove it.

Note that if the cursor is at end of a line but not the last line, the
behavior of "delete" in Vi mode is still wrong.  It should stay on the line.
2025-05-02 06:05:31 +02:00
Johannes Altmanninger
e3517f69b3 Simplify check for bare builtin invocation 2025-05-02 06:05:31 +02:00
Fabian Boehm
f7bde1354d Only count it as a naked invocation at the end of the "file"
This is a weird confusion between the "end" and "terminate" token
types.

"end" is the end of the "line" - a newline or ";".

"terminate" is the end of the "file" - like pressing newline
interactively or having the file end.

So this would count things like `if` and `switch` as a "help"
invocation even if followed by a newline, e.g.

```fish
if; echo foo
```

and

```fish
switch
case foo
```

The result of that was that a naked "if" in a script file isn't an
error, but doesn't start a block either, so if you complete the block
it would count the "end" as superfluous, which sends you on a bit of a
hunt to figure out where the block start is missing.
2025-05-01 14:57:30 +02:00
Axlefublr
1d69226c58 preciser wording for builtin crossmode alt+p binding 2025-05-01 13:58:18 +08:00
Daniel Rainer
d5e71bc46e Fix diff_profiles.fish
This script was broken by the changes to profiling output in
9d904e1113.

The new version works with both the old and new profiling output, even when
mixed. The script output has been adjusted to match the new profiling style
better.

This also adds basic error handling for situations where the script is invoked
incorrectly and makes the file executable.
2025-04-30 19:41:45 +02:00
fabiojb
0d5ab2514c wpctl: add description for settings command options 2025-04-30 11:18:12 -03:00
David Adam
bf0a30b9a8 CHANGELOG: work on 4.1 2025-04-30 14:15:58 +08:00
fabiojb
b54042e512 wpctl: add completion for settings option 2025-04-29 17:11:01 -03:00
Anton Bilous
b7b1753716 Mention replace mode in fish_mode_prompt docs 2025-04-24 16:26:45 +03:00
Ilia Gogotchuri
c0f5fcb089 Update tofu.fish 2025-04-22 14:17:52 +04:00
Sam Doran
b9f2275349 Refine when file completions are offered and add a missing short arg 2025-04-19 01:59:47 -04:00
Sam Doran
0b97fa7114 Evaluate completion arguments when called
This makes the destinations update dynamically when they are added/removed.
Unquote the echo statement so that it is correctly paresd by the -a options.
2025-04-19 01:17:58 -04:00
Sam Doran
1a2958d42b No need to reset ID
The values are only echoed if ID matches, so it will always be correct.
2025-04-19 00:59:30 -04:00
Sam Doran
3e8308f6eb Argument not description 2025-04-19 00:54:18 -04:00
Sam Doran
ff987f5f76 Do not use test for evaluating string match
Also add `--` to ensure parameters don't get mixed up with the line itself.
2025-04-19 00:52:31 -04:00
Sam Doran
a6fdb41940 Update completion for tmutil
- Reorganize completions and options so they are easier to read.
- Add destination UUIDs to completetions as well as descriptions
- Add a few missing sub commands
2025-04-16 11:59:24 -04:00
kpbaks
54971621de completions/git: show url as description for remote completion 2025-04-16 09:56:45 +02:00
exploide
b6c5f3dc38 completions: improved ip completions
added completions for ip tuntap
standardize help completion
2025-04-12 16:26:15 +02:00
174 changed files with 554155 additions and 730880 deletions

View File

@@ -19,7 +19,7 @@ jobs:
- uses: dtolnay/rust-toolchain@1.70
- name: Install deps
run: |
sudo apt install gettext libpcre2-dev python3-pexpect tmux
sudo apt install gettext libpcre2-dev python3-pexpect python3-sphinx tmux
# Generate a locale that uses a comma as decimal separator.
sudo locale-gen fr_FR.UTF-8
- name: cmake
@@ -32,6 +32,17 @@ jobs:
- name: make fish_run_tests
run: |
make -C build VERBOSE=1 fish_run_tests
- uses: dtolnay/rust-toolchain@stable
- name: translation updates
run: |
# Required for our custom xgettext implementation.
cargo install --locked --version 1.0.106 cargo-expand
# Generate PO files. This should not result it a change in the repo if all translations are
# up to date.
# Ensure that fish is available as an executable.
PATH="$PWD/build:$PATH" build_tools/update_translations.fish --no-mo
# Show diff output. Fail if there is any.
git --no-pager diff --exit-code || { echo 'There are uncommitted changes after regenerating the gettext PO files. Make sure to update them via `build_tools/update_translations.fish --no-mo` after changing source files.'; exit 1; }
ubuntu-32bit-static-pcre2:
@@ -82,13 +93,14 @@ jobs:
- name: Install deps
run: |
sudo apt install gettext libpcre2-dev python3-pexpect tmux
sudo apt install llvm # for llvm-symbolizer
- name: cmake
env:
CC: clang
run: |
mkdir build && cd build
# Rust's ASAN requires the build system to explicitly pass a --target triple. We read that
# value from CMake variable Rust_CARGO_TARGET (shared with corrosion).
# value from CMake variable Rust_CARGO_TARGET.
cmake .. -DASAN=1 -DRust_CARGO_TARGET=x86_64-unknown-linux-gnu -DCMAKE_BUILD_TYPE=Debug
- name: make
run: |
@@ -104,8 +116,8 @@ jobs:
# UPDATE: this can cause spurious leak reports for __cxa_thread_atexit_impl() under glibc.
LSAN_OPTIONS: verbosity=0:log_threads=0:use_tls=1:print_suppressions=0
run: |
llvm_version=$(clang --version | awk 'NR==1 { split($NF, version, "."); print version[1] }')
export ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-$llvm_version
set -x
export ASAN_SYMBOLIZER_PATH=$(command -v /usr/bin/llvm-symbolizer* | sort -n | head -1)
export LSAN_OPTIONS="$LSAN_OPTIONS:suppressions=$PWD/build_tools/lsan_suppressions.txt"
make -C build VERBOSE=1 fish_run_tests

3
.gitignore vendored
View File

@@ -38,7 +38,8 @@ Desktop.ini
Thumbs.db
ehthumbs.db
messages.pot
po/template.po
*.mo
.directory
.fuse_hidden*

View File

@@ -1,6 +1,8 @@
fish 4.1.0 (released ???)
=========================
.. ignore for 4.1: 10929 10940 10948 10955 10965 10975 10989 10990 10998 11028 11052 11055 11069 11071 11079 11092 11098 11104 11106 11110 11140 11146 11148 11150 11214 11218 11259 11288 11299 11328 11350 11373 11395 11417 11419
Notable improvements and fixes
------------------------------
- Compound commands (``begin; echo 1; echo 2; end``) can now be now be abbreviated using braces (``{ echo1; echo 2 }``), like in other shells.
@@ -19,7 +21,7 @@ Notable improvements and fixes
Deprecations and removed features
---------------------------------
- Tokens like ``{ echo, echo }`` in command position are no longer interpreted as brace expansion but as compound command.
- Tokens like ``{echo,echo}`` or ``{ echo, echo }`` in command position are no longer interpreted as brace expansion but as compound command.
- Terminfo-style key names (``bind -k``) are no longer supported. They had been superseded by the native notation since 4.0,
and currently they would map back to information from terminfo, which does not match what terminals would send with the kitty keyboard protocol (:issue:`11342`).
- fish no longer reads the terminfo database, so its behavior is no longer affected by the :envvar:`TERM` environment variable (:issue:`11344`).
@@ -64,17 +66,14 @@ New or improved bindings
Completions
^^^^^^^^^^^
- ``git`` completions now show the remote url as a description when completing remotes.
- ``systemctl`` completions no longer print escape codes if ``SYSTEMD_COLORS`` is set (:issue:`11465`).
Improved terminal support
^^^^^^^^^^^^^^^^^^^^^^^^^
- Support for curly underlines in `fish_color_*` variables and :doc:`set_color <cmds/set_color>` (:issue:`10957`).
- Support for double, curly, dotted and dashed underlines in `fish_color_*` variables and :doc:`set_color <cmds/set_color>` (:issue:`10957`).
- Underlines can now be colored independent of text (:issue:`7619`).
- Errors are now highlighted with curly underlines in the default themes.
For compatibility with terminals that interpret the curly-underline escape sequence in an unexpected way,
the default themes enable this only if the terminal advertises support for the ``Su`` capability via XTGETTCAP.
- New documentation page `Terminal Compatibility <terminal-compatibility.html>`_ (also accessible via ``man fish-terminal-compatibility``) lists required and optional terminal control sequences used by fish.
- :doc:`status <cmds/status>` learned the ``xtgettcap`` subcommand, to query terminfo capabilities via XTGETTCAP commands.
- :doc:`status <cmds/status>` learned the ``xtversion`` subcommand, to show the terminal's name and version (as reported by via the XTVERSION command).
Other improvements
------------------

View File

@@ -286,37 +286,68 @@ Contributing Translations
Fish uses the GNU gettext library to translate messages from English to
other languages.
Creating and updating translations requires the Gettext tools, including
``xgettext``, ``msgfmt`` and ``msgmerge``. Translation sources are
Translation sources are
stored in the ``po`` directory, named ``LANG.po``, where ``LANG`` is the
two letter ISO 639-1 language code of the target language (eg ``de`` for
German).
two letter ISO 639-1 language code of the target language (e.g. ``de`` for
German). A region specifier can also be used (e.g. ``pt_BR`` for Brazilian Portuguese).
To create a new translation:
Adding translations for a new language
--------------------------------------
* generate a ``messages.pot`` file by running ``build_tools/fish_xgettext.fish`` from
the source tree
* copy ``messages.pot`` to ``po/LANG.po``
Creating new translations requires the Gettext tools.
More specifically, you will need ``msguniq`` and ``msgmerge`` for creating translations for a new
language.
In addition, the ``cargo-expand`` tool is required.
If you have ``cargo`` installed, run::
To update a translation:
cargo install --locked --version 1.0.106 cargo-expand
* generate a ``messages.pot`` file by running
``build_tools/fish_xgettext.fish`` from the source tree
to install ``cargo-expand`` (Note that other versions might not work correctly with our scripts).
To create a new translation, run::
* update the existing translation by running
``msgmerge --update --no-fuzzy-matching po/LANG.po messages.pot``
build_tools/update_translations.fish po/LANG.po
The ``--no-fuzzy-matching`` is important as we have had terrible experiences with gettext's "fuzzy" translations in the past.
By default, this also creates ``mo`` files, which contain the information from the ``po`` files in a
binary format.
Fish uses these files for translating at runtime.
They are not tracked in version control, but they can help translators check if their translations
show up correctly.
If you build fish locally (``cargo build``), and then run the resulting binary,
it will make use of the ``mo`` files generated by the script.
Use the ``LANG`` environment variable to tell fish which language to use, e.g.::
LANG=pt_BR.utf8 target/debug/fish
If you do not care about the ``mo`` files you can pass the ``--no-mo`` flag to the
``update_translations.fish`` script.
Modifying existing translations
-------------------------------
If you want to work on translations for a language which already has a corresponding ``po`` file, it
is sufficient to edit this file. No other changes are necessary.
To see your translations in action you can run::
build_tools/update_translations.fish --only-mo po/LANG.po
to update the binary ``mo`` used by fish. Check the information for adding new languages for a
description on how you can get fish to use these files.
Running this script requires a fish executable and the gettext ``msgfmt`` tool.
Editing PO files
----------------
Many tools are available for editing translation files, including
command-line and graphical user interface programs. For simple use, you can just use your text editor.
command-line and graphical user interface programs. For simple use, you can use your text editor.
Open up the po file, for example ``po/sv.po``, and you'll see something like::
msgid "%ls: No suitable job\n"
msgstr ""
msgstr ""
The ``msgid`` here is the "name" of the string to translate, typically the english string to translate. The second line (``msgstr``) is where your translation goes.
The ``msgid`` here is the "name" of the string to translate, typically the English string to translate.
The second line (``msgstr``) is where your translation goes.
For example::
@@ -329,11 +360,17 @@ Also any escaped characters, like that ``\n`` newline at the end, should be kept
Our tests run ``msgfmt --check-format /path/to/file``, so they would catch mismatched placeholders - otherwise fish would crash at runtime when the string is about to be used.
Be cautious about blindly updating an existing translation file. Trivial
changes to an existing message (eg changing the punctuation) will cause
existing translations to be removed, since the tools do literal string
matching. Therefore, in general, you need to carefully review any
recommended deletions.
Be cautious about blindly updating an existing translation file.
``msgid`` strings should never be updated manually, only by running the appropriate script.
Modifications to strings in source files
----------------------------------------
If a string changes in the sources, the old translations will no longer work.
They will be preserved in the ``po`` files, but commented-out (starting with ``#~``).
If you add/remove/change a translatable strings in a source file,
run ``build_tools/update_translations.fish`` to propagate this to all translation files (``po/*.po``).
This is only relevant for developers modifying the source files of fish or fish scripts.
Setting Code Up For Translations
--------------------------------

26
Cargo.lock generated
View File

@@ -89,9 +89,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "errno"
version = "0.3.10"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e"
dependencies = [
"libc",
"windows-sys",
@@ -126,6 +126,8 @@ name = "fish-printf"
version = "0.2.1"
dependencies = [
"libc",
"unicode-segmentation",
"unicode-width",
"widestring",
]
@@ -173,9 +175,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.169"
version = "0.2.172"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a"
checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa"
[[package]]
name = "lock_api"
@@ -216,9 +218,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nix"
version = "0.29.0"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
checksum = "74523f3a35e05aba87a1d978330aef40f67b0304ac79c1c00b294c9830543db6"
dependencies = [
"bitflags",
"cfg-if",
@@ -546,6 +548,18 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
[[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 = "unix_path"
version = "1.0.1"

View File

@@ -40,7 +40,7 @@ libc = "0.2"
# disabling default features uses the stdlib instead, but it doubles the time to rewrite the history
# files as of 22 April 2024.
lru = "0.13.0"
nix = { version = "0.29.0", default-features = false, features = [
nix = { version = "0.30.1", default-features = false, features = [
"event",
"inotify",
"resource",
@@ -99,7 +99,7 @@ embed-data = ["dep:rust-embed"]
asan = []
tsan = []
[lints]
[workspace.lints]
rust.non_camel_case_types = "allow"
rust.non_upper_case_globals = "allow"
rust.unknown_lints = "allow"
@@ -113,3 +113,6 @@ clippy.needless_lifetimes = "allow"
# In the future, they might change to flag other methods of printing.
clippy.print_stdout = "deny"
clippy.print_stderr = "deny"
[lints]
workspace = true

35
SECURITY.md Normal file
View File

@@ -0,0 +1,35 @@
# Security Reporting
If you wish to report a security vulnerability privately, we appreciate your diligence. Please follow the guidelines below to submit your report.
## Reporting
To report a security vulnerability, please provide the following information:
1. **PROJECT**
- Include the URL of the project repository - Example: <https://github.com/fish-shell/fish-shell>
2. **PUBLIC**
- Indicate whether this vulnerability has already been publicly discussed or disclosed.
- If so, provide relevant links.
3. **DESCRIPTION**
- Provide a detailed description of the security vulnerability.
- Include as much information as possible to help us understand and address the issue.
Send this information, along with any additional relevant details, to <rf@fishshell.com>.
## Confidentiality
We kindly ask you to keep the report confidential until a public announcement is made.
## Notes
- Vulnerabilities will be handled on a best-effort basis.
- You may request an advance copy of the patched release, but we cannot guarantee early access before the public release.
- You will be notified via email simultaneously with the public announcement.
- We will respond within a few weeks to confirm whether your report has been accepted or rejected.
Thank you for helping to improve the security of our project!

View File

@@ -143,9 +143,9 @@ fn detect_apple(_: &Target) -> Result<bool, Box<dyn Error>> {
Ok(cfg!(any(target_os = "ios", target_os = "macos")))
}
#[allow(unexpected_cfgs)]
fn detect_cygwin(_: &Target) -> Result<bool, Box<dyn Error>> {
Ok(cfg!(target_os = "cygwin"))
// Cygwin target is usually cross-compiled.
Ok(std::env::var("CARGO_CFG_TARGET_OS").unwrap() == "cygwin")
}
/// Detect if we're being compiled for a BSD-derived OS, allowing targeting code conditionally with

14
build_tools/diff_profiles.fish Normal file → Executable file
View File

@@ -5,6 +5,12 @@
#
# Usage: ./diff_profiles.fish profile1.log profile2.log > profile_diff.log
if test (count $argv) -ne 2;
echo "Incorrect number of arguments."
echo "Usage: "(status filename)" profile1.log profile2.log"
exit 1
end
set -l profile1 (cat $argv[1])
set -l profile2 (cat $argv[2])
@@ -15,13 +21,13 @@ while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no]
set -l line1 $profile1[$line_no]
set -l line2 $profile2[$line_no]
if not string match -qr '^\d+\t\d+' $line1
if not string match -qr '^\s*\d+\s+\d+' $line1
echo $line1
continue
end
set -l results1 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line1)
set -l results2 (string match -r '^(\d+)\t(\d+)\s+(.*)' $line2)
set -l results1 (string match -r '^\s*(\d+)\s+(\d+)\s+(.*)' $line1)
set -l results2 (string match -r '^\s*(\d+)\s+(\d+)\s+(.*)' $line2)
# times from both files
set -l time1 $results1[2..3]
@@ -42,5 +48,5 @@ while set -l next_line_no (math $line_no + 1) && set -q profile1[$next_line_no]
set diff[1] (math $time1[1] - $time2[1])
set diff[2] (math $time1[2] - $time2[2])
echo $diff[1] $diff[2] $remainder1
printf '%10d %10d %s\n' $diff[1] $diff[2] $remainder1
end

View File

@@ -1,68 +1,101 @@
#!/usr/bin/env fish
#
# Tool to generate messages.pot
# Tool to generate gettext messages template file.
# Writes to stdout.
# Create temporary directory for these operations. OS X `mktemp` is somewhat restricted, so this block
# works around that - based on share/functions/funced.fish.
set -q TMPDIR
or set -l TMPDIR /tmp
set -l tmpdir (mktemp -d $TMPDIR/fish.XXXXXX)
or exit 1
begin
# Write header. This is required by msguniq.
# Note that this results in the file being overwritten.
# This is desired behavior, to get rid of the results of prior invocations
# of this script.
begin
echo 'msgid ""'
echo 'msgstr ""'
echo '"Content-Type: text/plain; charset=UTF-8\n"'
echo ""
end
# This is a gigantic crime.
# xgettext still does not support rust *at all*, so we use cargo-expand to get all our wgettext invocations.
set -l expanded (cargo expand --lib; for f in fish{,_indent,_key_reader}; cargo expand --bin $f; end)
set -l cargo_expanded_file (mktemp)
# This is a gigantic crime.
# We use cargo-expand to get all our wgettext invocations.
# This might be replaced once we have a tool which properly handles macro expansions.
begin
cargo expand --lib
for f in fish fish_indent fish_key_reader
cargo expand --bin $f
end
end >$cargo_expanded_file
# Extract any gettext call
set -l strs (printf '%s\n' $expanded | grep -A1 wgettext_static_str |
grep 'widestring::internals::core::primitive::str =' |
string match -rg '"(.*)"' | string match -rv '^%ls$|^$' |
# escaping difference between gettext and cargo-expand: single-quotes
string replace -a "\'" "'" | sort -u)
set -l rust_string_file (mktemp)
# Extract any constants
set -a strs (string match -rv 'BUILD_VERSION:|PACKAGE_NAME' -- $expanded |
string match -rg 'const [A-Z_]*: &str = "(.*)"' | string replace -a "\'" "'")
# Extract any gettext call
grep -A1 wgettext_static_str <$cargo_expanded_file |
grep 'widestring::internals::core::primitive::str =' |
string match -rg '"(.*)"' |
string match -rv '^%ls$|^$' |
# escaping difference between gettext and cargo-expand: single-quotes
string replace -a "\'" "'" >$rust_string_file
# We construct messages.pot ourselves instead of forcing this into msgmerge or whatever.
# The escaping so far works out okay.
for str in $strs
# grep -P needed for string escape to be compatible (PCRE-style),
# -H gives the filename, -n the line number.
# If you want to run this on non-GNU grep: Don't.
echo "#:" (grep -PHn -r -- (string escape --style=regex -- $str) src/ |
head -n1 | string replace -r ':\s.*' '')
echo "msgid \"$str\""
echo 'msgstr ""'
end >messages.pot
# Extract any constants
grep -Ev 'BUILD_VERSION:|PACKAGE_NAME' <$cargo_expanded_file |
grep -E 'const [A-Z_]*: &str = "(.*)"' |
sed -E -e 's/^.*const [A-Z_]*: &str = "(.*)".*$/\1/' -e "s_\\\'_'_g" >>$rust_string_file
# This regex handles descriptions for `complete` and `function` statements. These messages are not
# particularly important to translate. Hence the "implicit" label.
set -l implicit_regex '(?:^| +)(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
rm $cargo_expanded_file
# This regex handles explicit requests to translate a message. These are more important to translate
# than messages which should be implicitly translated.
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
# Sort the extracted strings and remove duplicates.
# Then, transform them into the po format.
# If a string contains a '%' it is considered a format string and marked with a '#, c-format'.
# This allows msgfmt to identify issues with translations whose format string does not match the
# original.
sort -u $rust_string_file |
sed -E -e '/%/ i\
#, c-format
' -e 's/^(.*)$/msgid "\1"\nmsgstr ""\n/'
mkdir -p $tmpdir/implicit/share/completions $tmpdir/implicit/share/functions
mkdir -p $tmpdir/explicit/share/completions $tmpdir/explicit/share/functions
rm $rust_string_file
for f in share/config.fish share/completions/*.fish share/functions/*.fish
# Extract explicit attempts to translate a message. That is, those that are of the form
# `(_ "message")`.
string replace --filter --regex $explicit_regex '$1' <$f | string unescape \
| string replace --all '"' '\\"' | string replace -r '(.*)' 'N_ "$1"' >$tmpdir/explicit/$f
function extract_fish_script_messages --argument-names regex
# Handle `complete` / `function` description messages. The `| fish` is subtle. It basically
# avoids the need to use `source` with a command substitution that could affect the current
# shell.
string replace --filter --regex $implicit_regex '$1' <$f | string unescape \
| string replace --all '"' '\\"' | string replace -r '(.*)' 'N_ "$1"' >$tmpdir/implicit/$f
end
# Using xgettext causes more trouble than it helps.
# This is due to handling of escaping in fish differing from formats xgettext understands
# (e.g. POSIX shell strings).
# We work around this issue by manually writing the file content.
xgettext -j -k -kN_ -LShell --from-code=UTF-8 -cDescription --no-wrap -o messages.pot $tmpdir/{ex,im}plicit/share/*/*.fish
# Steps:
# 1. We extract strings to be translated from the relevant files and drop the rest. This step
# depends on the regex matching the entire line, and the first capture group matching the
# string.
# 2. We unescape. This gets rid of some escaping necessary in fish strings.
# 3. The resulting strings are sorted alphabetically. This step is optional. Not sorting would
# result in strings from the same file appearing together. Removing duplicates is also
# optional, since msguniq takes care of that later on as well.
# 4. Single backslashes are replaced by double backslashes. This results in the backslashes
# being interpreted as literal backslashes by gettext tooling.
# 5. Double quotes are escaped, such that they are not interpreted as the start or end of
# a msgid.
# 6. We transform the string into the format expected in a PO file.
cat share/config.fish share/completions/*.fish share/functions/*.fish |
string replace --filter --regex $regex '$1' |
string unescape |
sort -u |
sed -E -e 's_\\\\_\\\\\\\\_g' -e 's_"_\\\\"_g' -e 's_^(.*)$_msgid "\1"\nmsgstr ""\n_'
end
# Remove the tmpdir from the location to avoid churn
sed -i 's_^#: /.*/share/_#: share/_' messages.pot
# This regex handles explicit requests to translate a message. These are more important to translate
# than messages which should be implicitly translated.
set -l explicit_regex '.*\( *_ (([\'"]).+?(?<!\\\\)\\2) *\).*'
extract_fish_script_messages $explicit_regex
rm -r $tmpdir
# This regex handles descriptions for `complete` and `function` statements. These messages are not
# particularly important to translate. Hence the "implicit" label.
set -l implicit_regex '^(?:\s|and |or )*(?:complete|function).*? (?:-d|--description) (([\'"]).+?(?<!\\\\)\\2).*'
extract_fish_script_messages $implicit_regex
end |
# At this point, all extracted strings have been written to stdout,
# starting with the ones taken from the Rust sources,
# followed by strings explicitly marked for translation in fish scripts,
# and finally the strings from fish scripts which get translated implicitly.
# Because we do not eliminate duplicates across these categories,
# we do it here, since other gettext tools expect no duplicates.
msguniq --no-wrap

View File

@@ -0,0 +1,88 @@
#!/usr/bin/env fish
# Updates the files used for gettext translations.
# By default, the whole xgettext, msgmerge, msgfmt pipeline runs,
# which extracts the messages from the source files into $template_file,
# updates the PO files for each language from that
# (changed line numbers, added messages, removed messages),
# and finally generates a machine-readable MO file for each language,
# which is stored in share/locale/$LANG/LC_MESSAGES/fish.mo (relative to the repo root).
#
# Use cases:
# For developers:
# - Run with args `--no-mo` to update all PO files after making changes to Rust/fish
# sources.
# For translators:
# - Run with `--no-mo` first, to ensure that the strings you are translating are up to date.
# - Specify the language you want to work on as an argument, which must be a file in the po/
# directory. You can specify a language which does not have translations yet by specifying the
# name of a file which does not yet exist. Make sure to follow the naming convention.
# The sort utility is locale-sensitive.
# Ensure that sorting output is consistent by setting LC_ALL here.
set -gx LC_ALL C.UTF-8
set -l build_tools (status dirname)
set -l template_file $build_tools/../po/template.po
set -l po_dir $build_tools/../po
set -l extract
set -l po
set -l mo
argparse --exclusive 'no-mo,only-mo' 'no-mo' 'only-mo' -- $argv
or exit $status
if test -z $argv[1]
# Update everything if not specified otherwise.
set -g po_files $po_dir/*.po
else
set -l po_dir_id (stat --format='%d:%i' -- $po_dir)
for arg in $argv
set -l arg_dir_id (stat --format='%d:%i' -- (dirname $arg))
if test $po_dir_id != $arg_dir_id
echo "Argument $arg is not a file in the directory $(realpath $po_dir)."
echo "Non-option arguments must specify paths to files in this directory."
echo ""
echo "If you want to add a new language to the translations not the following:"
echo "The filename must identify a language, with a two letter ISO 639-1 language code of the target language (e.g. 'pt' for Portuguese), and use the file extension '.po'."
echo "Optionally, you can specify a regional variant (e.g. 'pt_BR')."
echo "So valid filenames are of the shape 'll.po' or 'll_CC.po'."
exit 1
end
if not basename $arg | grep -qE '^[a-z]{2}(_[A-Z]{2})?\.po$'
echo "Filename does not match the expected format ('ll.po' or 'll_CC.po')."
exit 1
end
end
set -g po_files $argv
end
if set -l --query _flag_no_mo
set -l --erase mo
end
if set -l --query _flag_only_mo
set -l --erase extract
set -l --erase po
end
if set -l --query extract
$build_tools/fish_xgettext.fish >$template_file
or exit 1
end
for po_file in $po_files
if set -l --query po
if test -e $po_file
msgmerge --update --no-fuzzy-matching --no-wrap --backup=none $po_file $template_file
else
cp $template_file $po_file
end
end
if set -l --query mo
set -l locale_dir $build_tools/../share/locale
set -l out_dir $locale_dir/(basename $po_file .po)/LC_MESSAGES
mkdir -p $out_dir
msgfmt --check-format --output-file=$out_dir/fish.mo $po_file
end
end

1
debian/control vendored
View File

@@ -27,7 +27,6 @@ Depends: bsdextrautils | bsdmainutils,
gettext-base,
# for nroff and preconv
groff-base,
man-db,
# for terminal definitions
ncurses-base,
# for kill

View File

@@ -425,6 +425,24 @@ Launch ``git diff`` and repaint the commandline afterwards when :kbd:`ctrl-g` is
bind ctrl-g 'git diff' repaint
Swap :kbd:`tab` and :kbd:`shift-tab`, making tab focus the search field.
But if the search field is already active, keep the behavior (:kbd:`tab` cycles forward, :kbd:`shift-tab` backward).::
bind tab '
if commandline --search-field >/dev/null
commandline -f complete
else
commandline -f complete-and-search
end
'
bind shift-tab '
if commandline --search-field >/dev/null
commandline -f complete-and-search
else
commandline -f complete
end
'
.. _cmd-bind-termlimits:
Terminal Limitations

View File

@@ -74,6 +74,9 @@ The following options change what part of the commandline is printed or updated:
**--search-field**
Use the pager search field instead of the command line. Returns false if the search field is not shown.
**--input=INPUT**
Operate on this string instead of the commandline. Useful for using options like **--tokens-expanded**.
The following options change the way ``commandline`` prints the current commandline buffer:
**-c** or **--cut-at-cursor**
@@ -87,10 +90,7 @@ The following options change the way ``commandline`` prints the current commandl
Perform argument expansion on the selection and print one argument per line.
Command substitutions are not expanded but forwarded as-is.
**--tokens-raw**
Print arguments in the selection as they appear on the command line, one per line.
**-o** or **tokenize**
**-o**, **tokenize**, **--tokens-raw**
Deprecated; do not use.
If ``commandline`` is called during a call to complete a given string using ``complete -C STRING``, ``commandline`` will consider the specified string to be the current contents of the command line.

View File

@@ -10,7 +10,7 @@ Synopsis
fish_config [browse]
fish_config prompt (choose | list | save | show)
fish_config theme (choose | demo | dump | list | save | show | update)
fish_config theme (choose | demo | dump | list | save | show)
Description
-----------
@@ -40,9 +40,6 @@ Available subcommands for the ``theme`` command:
- ``list`` lists the names of the available sample themes.
- ``save`` saves the given theme to :ref:`universal variables <variables-universal>`.
- ``show`` shows what the given sample theme (or all) would look like.
- ``update`` updates any ``fish_color_*`` and ``fish_pager_color_*`` variables whose value contains
"--track=THEME". They are set to the latest version of that theme, and the tracking
option is preserved. Note that ``fish_config theme update`` is run at fish startup.
The **-h** or **--help** option displays help about using this command.

View File

@@ -22,7 +22,7 @@ Description
The ``fish_mode_prompt`` function outputs the mode indicator for use in vi mode.
The default ``fish_mode_prompt`` function will output indicators about the current vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, or ``visual``.
The default ``fish_mode_prompt`` function will output indicators about the current vi editor mode displayed to the left of the regular prompt. Define your own function to customize the appearance of the mode indicator. The ``$fish_bind_mode variable`` can be used to determine the current mode. It will be one of ``default``, ``insert``, ``replace_one``, ``replace``, or ``visual``.
You can also define an empty ``fish_mode_prompt`` function to remove the vi mode indicators::
@@ -51,6 +51,9 @@ Example
case replace_one
set_color --bold green
echo 'R'
case replace
set_color --bold bryellow
echo 'R'
case visual
set_color --bold brmagenta
echo 'V'

View File

@@ -57,13 +57,7 @@ The following options are available:
Sets reverse mode.
**-u** or **--underline**, or **-uSTYLE** or **--underline=STYLE**
Set the underline mode; supported styles are **single** (default) and **curly**.
**--track=THEME**
Ignored. Included by default in universally-scoped color variables to tell fish to update
them as the associated theme changes.
This flag can be set for all variables when loading a theme with the `--track`` option, that is
:doc:`fish_config theme save THEME --track <fish_config>`.
Set the underline mode; supported styles are **single** (default), **double**, **curly**, **dotted** and **dashed**.
**-h** or **--help**
Displays help about using this command.

View File

@@ -33,8 +33,6 @@ Synopsis
status buildinfo
status get-file FILE
status list-files [PATH]
status xtgettcap TERMINFO-CAPABILITY
status xtversion
Description
-----------
@@ -119,13 +117,6 @@ The following operations (subcommands) are available:
This lists the files embedded in the fish binary at compile time. Only files where the path starts with the optional *FILE* argument are shown.
Returns 0 if something was printed, 1 otherwise.
**xtgettcap** *TERMINFO-CAPABILITY*
Query the terminal for a terminfo capability via XTGETTCAP.
Returns 0 if the capability is present and 1 otherwise.
**xtversion**
Show the terminal name and version (XTVERSION).
Notes
-----

View File

@@ -8,8 +8,8 @@ Synopsis
.. synopsis::
string join [-q | --quiet] SEP [STRING ...]
string join0 [-q | --quiet] [STRING ...]
string join [-q | --quiet] [-n | --no-empty] [--] SEP [STRING ...]
string join0 [-q | --quiet] [-n | --no-empty] [--] [STRING ...]
.. END SYNOPSIS
@@ -18,11 +18,28 @@ Description
.. BEGIN DESCRIPTION
``string join`` joins its *STRING* arguments into a single string separated by *SEP*, which can be an empty string. Exit status: 0 if at least one join was performed, or 1 otherwise. If ``-n`` or ``--no-empty`` is specified, empty strings are excluded from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
Joins its *STRING* arguments into a single string separated by *SEP* (for ``string join``) or by the
zero byte (NUL) (for ``string join0``).
Exit status: 0 if at least one join was performed, or 1 otherwise.
``string join0`` joins its *STRING* arguments into a single string separated by the zero byte (NUL), and adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``. Exit status: 0 if at least one join was performed, or 1 otherwise.
**-n**, **--no-empty**
Exclude empty strings from consideration (e.g. ``string join -n + a b "" c`` would expand to ``a+b+c`` not ``a+b++c``).
Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work. Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends. This is a limitation of Unix' argument passing.
**-q**, **--quiet**
Do not print the strings, only set the exit status as described above.
**WARNING**:
Insert a ``--`` before positional arguments to prevent them from being interpreted as flags.
Otherwise, any strings starting with ``-`` will be treated as flag arguments, meaning they will most likely result in the command failing.
This is also true if you specify a variable which expands to such a string instead of a literal string.
If you don't need to append flag arguments at the end of the command,
just always use ``--`` to avoid unwelcome surprises.
``string join0`` adds a trailing NUL. This is most useful in conjunction with tools that accept NUL-delimited input, such as ``sort -z``.
Because Unix uses NUL as the string terminator, passing the output of ``string join0`` as an *argument* to a command (via a :ref:`command substitution <expand-command-substitution>`) won't actually work.
Fish will pass the correct bytes along, but the command won't be able to tell where the argument ends.
This is a limitation of Unix' argument passing.
.. END DESCRIPTION
@@ -43,4 +60,14 @@ Examples
>_ string join '' a b c
abc
>_ set -l markdown_list '- first' '- second' '- third'
# Strings with leading hyphens (also in variable expansions) are interpreted as flag arguments by default.
>_ string join \n $markdown_list
string join: - first: unknown option
# Use '--' to prevent this.
>_ string join -- \n $markdown_list
- first
- second
- third
.. END EXAMPLES

View File

@@ -11,7 +11,7 @@ Synopsis
string collect [-a | --allow-empty] [-N | --no-trim-newlines] [STRING ...]
string escape [-n | --no-quoted] [--style=] [STRING ...]
string join [-q | --quiet] [-n | --no-empty] SEP [STRING ...]
string join0 [-q | --quiet] [STRING ...]
string join0 [-q | --quiet] [-n | --no-empty] [STRING ...]
string length [-q | --quiet] [STRING ...]
string lower [-q | --quiet] [STRING ...]
string match [-a | --all] [-e | --entire] [-i | --ignore-case]
@@ -27,7 +27,7 @@ Synopsis
[-r | --regex] [-q | --quiet] PATTERN REPLACE [STRING ...]
string shorten [(-c | --char) CHARS] [(-m | --max) INTEGER]
[-N | --no-newline] [-l | --left] [-q | --quiet] [STRING ...]
string split [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
string split [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
[-q | --quiet] [-r | --right] SEP [STRING ...]
string split0 [(-f | --fields) FIELDS] [(-m | --max) MAX] [-n | --no-empty]
[-q | --quiet] [-r | --right] [STRING ...]

View File

@@ -354,7 +354,7 @@ Some bindings are common across Emacs and vi mode, because they aren't text edit
- :kbd:`alt-o` opens the file at the cursor in a pager. If the cursor is in command position and the command is a script, it will instead open that script in your editor. The editor is chosen from the first available of the ``$VISUAL`` or ``$EDITOR`` variables.
- :kbd:`alt-p` adds the string ``&| less;`` to the end of the job under the cursor. The result is that the output of the command will be paged.
- :kbd:`alt-p` adds the string ``&| less;`` to the end of the job under the cursor. The result is that the output of the command will be paged. If you set the ``PAGER`` variable, its value is used instead of ``less``.
- :kbd:`alt-w` prints a short description of the command under the cursor.

View File

@@ -917,6 +917,12 @@ If there is nothing between a brace and a comma or two commas, it's interpreted
To use a "," as an element, :ref:`quote <quotes>` or :ref:`escape <escapes>` it.
The very first character of a command token is never interpreted as expanding brace, because it's the beginning of a :ref:`compound statement <cmd-begin>`::
> {echo hello, && echo world}
hello,
world
.. _cartesian-product:
Combining lists

View File

@@ -120,10 +120,22 @@ Optional Commands
- smul
- Enter underline mode.
-
* - ``\e[4:2m``
- Su
- Enter double underline mode.
- kitty
* - ``\e[4:3m``
- Su
- Enter curly underline mode.
- kitty
* - ``\e[4:4m``
- Su
- Enter dotted underline mode.
- kitty
* - ``\e[4:5m``
- Su
- Enter dashed underline mode.
- kitty
* - ``\e[7m``
- rev
- Enter reverse video mode (swap foreground and background colors).
@@ -177,9 +189,7 @@ Optional Commands
- Su
- Reset underline color to the default (follow the foreground color).
- kitty
* - .. _indn:
``\e[ Ps S``
* - ``\e[ Ps S``
- indn
- Scroll forward Ps lines.
-
@@ -271,12 +281,6 @@ Optional Commands
- FinalTerm
* - ``\eP+q Pt \e\\``
-
- Request terminfo capability (XTGETTCAP).
The parameter is the capability's hex-encoded terminfo code.
To advertise a capability, the response must of the form
``\eP1+q Pt \e\\`` or ``\eP1+q Pt = Pt \e\\``.
In either variant the first parameter must be the hex-encoded terminfo code.
In the second variant, fish ignores the part after the equals sign.
At startup, fish checks for the presence of the `indn <#indn>`_ string capability.
- XTerm, kitty, foot, wezterm, contour
- Request terminfo capability (XTGETTCAP). The parameter is the capability's hex-encoded terminfo code.
Specifically, fish asks for the ``indn`` string capability. At the time of writing string capabilities are supported by kitty and foot.
- XTerm, kitty, foot

View File

@@ -115,7 +115,7 @@ These colors, and many more, can be changed by running ``fish_config``, or by mo
For example, if you want to disable (almost) all coloring::
fish_config theme choose none
fish_config theme choose None
This picks the "none" theme. To see all themes::
@@ -631,12 +631,12 @@ You can define your own prompt from the command line:
Then, if you are happy with it, you can save it to disk by typing ``funcsave fish_prompt``. This saves the prompt in ``~/.config/fish/functions/fish_prompt.fish``. (Or, if you want, you can create that file manually from the start.)
Multiple lines are OK. Colors can be set via :doc:`set_color <cmds/set_color>`, passing it named ANSI colors, or hex RGB values::
Multiple lines are OK. Colors can be set via :doc:`set_color <cmds/set_color>` by passing it named ANSI colors, or hex RGB values::
function fish_prompt
set_color purple
date "+%m/%d/%y"
set_color F00
set_color FF0000
echo (pwd) '>' (set_color normal)
end

View File

@@ -31,13 +31,12 @@ BuildRequires: glibc-langpack-en
BuildRequires: python3 procps
%if 0%{?suse_version}
Requires: terminfo-base
Requires: terminfo-base groff
%else
Requires: ncurses-base
Requires: ncurses-base groff-base
%endif
Requires: file
Requires: python3
Requires: man
Requires: procps
# Although the build scripts mangle the version number to be RPM compatible

180954
po/de.po

File diff suppressed because it is too large Load Diff

181905
po/en.po

File diff suppressed because it is too large Load Diff

186931
po/fr.po

File diff suppressed because it is too large Load Diff

180106
po/pl.po

File diff suppressed because it is too large Load Diff

180882
po/pt_BR.po

File diff suppressed because it is too large Load Diff

181439
po/sv.po

File diff suppressed because it is too large Load Diff

185464
po/zh_CN.po

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
[package]
name = "fish-printf"
edition = "2021"
edition.workspace = true
rust-version.workspace = true
version = "0.2.1"
repository = "https://github.com/fish-shell/fish-shell"
description = "printf implementation, based on musl"
@@ -9,3 +10,8 @@ license = "MIT"
[dependencies]
libc = "0.2.155"
widestring = { version = "1.0.2", optional = true }
unicode-segmentation = "1.12.0"
unicode-width = "0.2.0"
[lints]
workspace = true

1
printf/clippy.toml Normal file
View File

@@ -0,0 +1 @@
allow-print-in-tests = true

View File

@@ -71,7 +71,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
}
};
@@ -735,6 +736,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::*;

0
reader
View File

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 update upgrade dselect-upgrade dist-upgrade install remove purge source build-dep check clean autoclean changelog
if contains -- $i update upgrade dselect-upgrade dist-upgrade install remove purge autoremove autopurge source build-dep check clean autoclean changelog
return 1
end
end
@@ -11,7 +11,7 @@ end
function __fish_apt_use_package -d 'Test if apt command should have packages as potential completion'
for i in (commandline -xpc)
if contains -- $i contains install remove purge build-dep changelog
if contains -- $i contains install remove purge autoremove autopurge build-dep changelog
return 0
end
end
@@ -34,7 +34,8 @@ complete -f -n __fish_apt_no_subcommand -c apt-get -a build-dep -d 'Install/remo
complete -f -n __fish_apt_no_subcommand -c apt-get -a check -d 'Update cache and check dependencies'
complete -f -n __fish_apt_no_subcommand -c apt-get -a clean -d 'Clean local caches and packages'
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoclean -d 'Clean packages no longer be downloaded'
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoremove -d 'Remove automatically installed packages'
complete -f -n __fish_apt_no_subcommand -c apt-get -a autoremove -d 'Remove packages no longer needed as dependencies'
complete -f -n __fish_apt_no_subcommand -c apt-get -a autopurge -d 'Remove packages no longer needed as dependencies and delete their config files'
complete -c apt-get -l no-install-recommends -d 'Do not install recommended packages'
complete -c apt-get -l no-install-suggests -d 'Do not install suggested packages'
complete -c apt-get -s d -l download-only -d 'Download Only'

View File

@@ -6,8 +6,8 @@ if [ "$(uname -s)" = Darwin -a "$(command -s apt)" = /usr/bin/apt ]
exit 1
end
set -l all_subcmds update upgrade full-upgrade search list install show remove edit-sources purge changelog autoremove depends rdepends
set -l pkg_subcmds install upgrade full-upgrade show search purge changelog policy depends rdepends autoremove
set -l all_subcmds update upgrade full-upgrade search list install show remove edit-sources purge changelog autoremove autopurge depends rdepends
set -l pkg_subcmds install upgrade full-upgrade show search purge changelog policy depends rdepends autoremove autopurge
set -l installed_pkg_subcmds remove
set -l handle_file_pkg_subcmds install
@@ -114,7 +114,7 @@ __fish_apt_subcommand changelog -r -d 'Download and display package changelog'
# Autoremove
__fish_apt_subcommand autoremove -d 'Remove packages no longer needed as dependencies'
# Autoremove
# Autopurge
__fish_apt_subcommand autopurge -d 'Remove packages no longer needed as dependencies and delete their config files'
# Clean

View File

@@ -11,7 +11,7 @@ end
function __fish_apt_use_package -d 'Test if aptitude command should have packages as potential completion'
for i in (commandline -xpc)
if contains -- $i changelog full-upgrade download forbid-version hold install keep-all markauto purge reinstall remove show unhold unmarkauto
if contains -- $i changelog full-upgrade download forbid-version hold install keep-all markauto purge reinstall remove show showrc unhold unmarkauto why why-not versions
return 0
end
end
@@ -38,15 +38,19 @@ complete -f -n __fish_apt_no_subcommand -c aptitude -a markauto -d 'Mark package
complete -f -n __fish_apt_no_subcommand -c aptitude -a purge -d 'Remove and delete all associated configuration and data files'
complete -f -n __fish_apt_no_subcommand -c aptitude -a reinstall -d 'Reinstall the packages'
complete -f -n __fish_apt_no_subcommand -c aptitude -a remove -d 'Remove the packages'
complete -f -n __fish_apt_no_subcommand -c aptitude -a showsrc -d 'Display detailed information about the source packages (apt wrapper)'
complete -f -n __fish_apt_no_subcommand -c aptitude -a show -d 'Display detailed information about the packages'
complete -f -n __fish_apt_no_subcommand -c aptitude -a unhold -d 'Consider the packages by future upgrade commands'
complete -f -n __fish_apt_no_subcommand -c aptitude -a unmarkauto -d 'Mark packages as manually installed'
complete -f -n __fish_apt_no_subcommand -c aptitude -a search -d 'Search for packages matching one of the patterns'
complete -f -n __fish_apt_no_subcommand -c aptitude -a help -d 'Display brief summary of the available commands and options'
complete -f -n __fish_apt_no_subcommand -c aptitude -a why -d 'Explain why a particular package should be installed'
complete -f -n __fish_apt_no_subcommand -c aptitude -a why-not -d 'Explain why a particular package cannot be installed'
complete -f -n __fish_apt_no_subcommand -c aptitude -a versions -d 'Displays the versions of specified packages'
complete -c aptitude -s D -l show-deps -d 'Show explanations of automatic installations and removals'
complete -c aptitude -s d -l download-only -d 'Download Only'
complete -c aptitude -s f -l fix-broken -d 'Correct broken dependencies'
complete -c aptitude -s d -l download-only -d 'Download only'
complete -c aptitude -s f -l fix-broken -d 'Aggressively try to fix broken packages'
complete -c aptitude -l purge-unused -d 'Purge packages that are not required by any installed package'
complete -c aptitude -s P -l prompt -d 'Always display a prompt'
complete -c aptitude -s R -l without-recommends -d 'Do not treat recommendations as dependencies'
@@ -60,6 +64,7 @@ complete -c aptitude -l version -d 'Display the version of aptitude and compile
complete -c aptitude -l visual-preview -d 'Start up the visual interface and display its preview screen'
complete -c aptitude -s y -l assume-yes -d 'Assume the answer yes for all question prompts'
complete -c aptitude -s Z -d 'Show how much disk space will be used or freed'
complete -c aptitude -s u -d 'Download new package lists on startup (terminal interface only)'
complete -r -c aptitude -s F -l display-format -d 'Specify the format to be used by the search command'
complete -r -c aptitude -s t -l target-release -d 'Set the release from which packages should be installed'
complete -r -c aptitude -s O -l sort -d 'Specify the order for the output from the search command'

View File

@@ -1,20 +1,25 @@
# Tab completion for cargo (https://github.com/rust-lang/cargo).
## --- WRITTEN MANUALLY ---
set -l __fish_cargo_subcommands (cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
function __fish_cargo
cargo --color=never $argv
end
set -l __fish_cargo_subcommands (__fish_cargo --list 2>&1 | string replace -rf '^\s+([^\s]+)\s*(.*)' '$1\t$2' | string escape)
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"
for x in bench b build c check rustc t test
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -a "(cargo bench --bench 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bench -a "(__fish_cargo bench --bench 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -n "__fish_seen_subcommand_from $x" -l lib -d 'Only this package\'s library'
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -a "(cargo test --test 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l test -a "(__fish_cargo test --test 2>&1 | string replace -rf '^\s+' '')"
end
for x in bench b build c check r run rustc t test
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -a "(cargo run --bin 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(cargo run --example 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l bin -a "(__fish_cargo run --bin 2>&1 | string replace -rf '^\s+' '')"
complete -c cargo -x -n "__fish_seen_subcommand_from $x" -l example -a "(__fish_cargo run --example 2>&1 | string replace -rf '^\s+' '')"
end
# If using rustup, get the list of installed targets from there. Otherwise print all targets.
@@ -38,18 +43,18 @@ end
function __fish_cargo_features
if command -q jq
cargo read-manifest | jq -r '.features | keys | .[]' | __fish_concat_completions
__fish_cargo read-manifest | jq -r '.features | keys | .[]' | __fish_concat_completions
else if set -l python (__fish_anypython)
cargo read-manifest | command $python -Sc "import sys, json"\n"print(*json.load(sys.stdin)['features'].keys(), sep='\n')" | __fish_concat_completions
__fish_cargo read-manifest | command $python -Sc "import sys, json"\n"print(*json.load(sys.stdin)['features'].keys(), sep='\n')" | __fish_concat_completions
end
end
function __fish_cargo_packages
if command -q jq
cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[] | .name' | __fish_concat_completions
__fish_cargo metadata --no-deps --format-version 1 | jq -r '.packages | .[] | .name' | __fish_concat_completions
else if set -l python (__fish_anypython)
cargo metadata --no-deps --format-version 1 |
command $python -Sc "import sys, json"\n"print(*[x['name'] for x in json.load(sys.stdin)['packages']], sep='\n')"
__fish_cargo metadata --no-deps --format-version 1 |
command $python -Sc "import sys, json"\n"print(*[x['name'] for x in json.load(sys.stdin)['packages']], sep='\n')"
end
end
complete -c cargo -n '__fish_seen_subcommand_from run test build debug check clippy' -s p -l package \
@@ -60,7 +65,7 @@ complete -c cargo -n '__fish_seen_subcommand_from run test build debug check cli
complete -c cargo -n __fish_use_subcommand -l explain -d 'Run `rustc --explain CODE`'
complete -c cargo -n __fish_use_subcommand -l color -d 'Coloring: auto, always, never'
complete -c cargo -n __fish_use_subcommand -l config -d 'Override a configuration value (unstable)'
complete -c cargo -n __fish_use_subcommand -s Z -d 'Unstable (nightly-only) flags to Cargo, see \'cargo -Z help\' for details' -xa '(cargo -Z help | string replace -rf \'^\s*-Z (\S+)\s+(.*)\' \'$1\t$2\')'
complete -c cargo -n __fish_use_subcommand -s Z -d 'Unstable (nightly-only) flags to Cargo, see \'cargo -Z help\' for details' -xa '(__fish_cargo -Z help | string replace -rf \'^\s*-Z (\S+)\s+(.*)\' \'$1\t$2\')'
complete -c cargo -n __fish_use_subcommand -s V -l version -d 'Print version info and exit'
complete -c cargo -n __fish_use_subcommand -l list -d 'List installed commands'
complete -c cargo -n __fish_use_subcommand -s v -l verbose -d 'Use verbose output (-vv very verbose/build.rs output)'
@@ -718,7 +723,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" -fa '(__fish_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'
@@ -841,8 +846,8 @@ if command -q cargo-asm
# Warning: this will build the project and can take time! We make sure to only call it if it's not a switch so completions
# for --foo will always be fast.
if command -q timeout
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(timeout 1 cargo asm)"
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(timeout 1 __fish_cargo asm)"
else
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(cargo asm)"
complete -c cargo -n "__fish_seen_subcommand_from asm; and not __fish_is_switch" -xa "(__fish_cargo asm)"
end
end

View File

@@ -13,7 +13,6 @@ complete -c commandline -s b -l current-buffer -d "Select entire command line (d
complete -c commandline -s c -l cut-at-cursor -d "Only return that part of the command line before the cursor"
complete -c commandline -s f -l function -d "Inject readline functions to reader"
complete -c commandline -s x -l tokens-expanded -d "Print a list of expanded tokens"
complete -c commandline -l tokens-raw -d "Print a list of raw tokens"
complete -c commandline -s I -l input -d "Specify command to operate on"
complete -c commandline -s C -l cursor -d "Set/get cursor position, not buffer contents"

View File

@@ -1,6 +1,6 @@
complete fish_config -f
set -l prompt_commands choose save show list
set -l theme_commands choose demo dump save show list update
set -l theme_commands choose demo dump save show list
complete fish_config -n __fish_use_subcommand -a prompt -d 'View and pick from the sample prompts'
complete fish_config -n "__fish_seen_subcommand_from prompt; and not __fish_seen_subcommand_from $prompt_commands" \
-a choose -d 'View and pick from the sample prompts'
@@ -16,7 +16,6 @@ complete fish_config -n __fish_use_subcommand -a browse -d 'Open the web-based U
complete fish_config -n __fish_use_subcommand -a theme -d 'View and pick from the sample themes'
complete fish_config -n '__fish_seen_subcommand_from theme; and __fish_seen_subcommand_from choose save show' -a '(fish_config theme list)'
complete fish_config -n '__fish_seen_subcommand_from theme; and __fish_seen_subcommand_from save' -l track -d 'Add --track to color variables to apply future theme updates'
complete fish_config -n "__fish_seen_subcommand_from theme; and not __fish_seen_subcommand_from $theme_commands" \
-a choose -d 'View and pick from the sample themes'
complete fish_config -n "__fish_seen_subcommand_from theme; and not __fish_seen_subcommand_from $theme_commands" \
@@ -29,5 +28,3 @@ complete fish_config -n "__fish_seen_subcommand_from theme; and not __fish_seen_
-a demo -d 'Show example in the current theme'
complete fish_config -n "__fish_seen_subcommand_from theme; and not __fish_seen_subcommand_from $theme_commands" \
-a dump -d 'Print the current theme in .theme format'
complete fish_config -n "__fish_seen_subcommand_from theme; and not __fish_seen_subcommand_from $theme_commands" \
-a update -d "Update universal colors that have the tracking flag set"

View File

@@ -16,7 +16,8 @@ function __fish_git
end
end
# Using 'command git' to avoid interactions for aliases from git to (e.g.) hub
command git $global_args $saved_args 2>/dev/null
set -l git $__fish_git_timeout git
command $git $global_args $saved_args 2>/dev/null
end
# Print an optspec for argparse to handle git's options that are independent of any subcommand.
@@ -52,8 +53,8 @@ end
function __fish_git_branches
# This is much faster than using `git branch` and avoids dealing with localized "detached HEAD" messages.
# We intentionally only sort local branches by recency. See discussion in #9248.
__fish_git for-each-ref --format='%(refname:strip=2)%09Local Branch' --sort=-committerdate refs/heads/ 2>/dev/null
__fish_git for-each-ref --format='%(refname:strip=2)%09Remote Branch' refs/remotes/ 2>/dev/null
__fish_git_local_branches
__fish_git_remote_branches
end
function __fish_git_submodules
@@ -65,14 +66,18 @@ function __fish_git_local_branches
__fish_git for-each-ref --format='%(refname:strip=2)%09Local Branch' --sort=-committerdate refs/heads/ 2>/dev/null
end
function __fish_git_remote_branches
__fish_git_timeout=(string split ' ' -- (command -v timeout)' 0.200') __fish_git for-each-ref --format='%(refname:strip=2)%09Remote Branch' refs/remotes/ 2>/dev/null
end
function __fish_git_unique_remote_branches
# `git checkout` accepts remote branches without the remote part
# if they are unambiguous.
# E.g. if only alice has a "frobulate" branch
# `git checkout frobulate` is equivalent to `git checkout -b frobulate --track alice/frobulate`.
__fish_git for-each-ref --format="%(refname:strip=3)" \
__fish_git_timeout=(string split ' ' -- (command -v timeout)' 0.200') __fish_git for-each-ref --format="%(refname:strip=3)" \
--sort="refname:strip=3" \
"refs/remotes/*/$match*" "refs/remotes/*/*/**" 2>/dev/null | uniq -u
refs/remotes/ 2>/dev/null | uniq -u
end
function __fish_git_tags
@@ -82,7 +87,8 @@ end
function __fish_git_heads
set -l gitdir (__fish_git rev-parse --git-dir 2>/dev/null)
or return # No git dir, no need to even test.
for head in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD
for head in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD REVERT_HEAD \
CHERRY_PICK_HEAD BISECT_HEAD AUTO_MERGE
if test -f $gitdir/$head
echo $head
end
@@ -96,7 +102,35 @@ function __fish_git_refs
end
function __fish_git_remotes
__fish_git remote 2>/dev/null
# Example of output parsed:
# "remote.upstream.url git@github.com:fish-shell/fish-shell.git" -> "upstream\tgit@github.com:fish-shell/fish-shell.git"
__fish_git config --get-regexp 'remote\.[a-z]+\.url' | string replace -rf 'remote\.(.*)\.url (.*)' '$1\t$2'
end
set -g __fish_git_extra_recent_commits false
set -g __fish_git_unqualified_unique_remote_branches false
set -g __fish_git_filter_non_pushable 'string join \n'
function __fish_git_add_revision_completion
set -l c complete -f -c git $argv -n 'not contains -- -- (commandline -xpc)' -ka
# The following dynamic, order-preserved (-k) completions will be shown in reverse order (see #9221)
$c "(__fish_git_recent_commits \$(
if $__fish_git_extra_recent_commits
begin
echo HEAD
git for-each-ref --sort=-committerdate --format='%(refname)' 2>/dev/null \
refs/tags refs/heads
end | string join ' '
end
) | $__fish_git_filter_non_pushable)"
$c "(__fish_git_tags)" -d Tag
$c "(__fish_git_heads | $__fish_git_filter_non_pushable)" -d Head
$c "(__fish_git_remotes | $__fish_git_filter_non_pushable)" -d 'Remote alias'
$c "(__fish_git_remote_branches | $__fish_git_filter_non_pushable)"
if $__fish_git_unqualified_unique_remote_branches
$c "(__fish_git_unique_remote_branches | $__fish_git_filter_non_pushable)" -d 'Unique Remote Branch'
end
$c "(__fish_git_local_branches)" -d 'Local Branch'
end
function __fish_git_files
@@ -647,6 +681,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
@@ -784,7 +819,7 @@ end
# Suggest branches for the specified remote - returns 1 if no known remote is specified
function __fish_git_branch_for_remote
set -l remotes (__fish_git_remotes)
set -l remotes (__fish_git remote 2>/dev/null)
set -l remote
set -l cmd (commandline -xpc)
for r in $remotes
@@ -1034,7 +1069,7 @@ complete -f -c git -n '__fish_git_using_command fetch' -l shallow-since -d 'Deep
complete -f -c git -n '__fish_git_using_command fetch' -l shallow-exclude -d 'Deepen history of shallow clone, excluding rev'
complete -f -c git -n '__fish_git_using_command fetch' -l unshallow -d 'Convert to a complete repository'
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)'
__fish_git_add_revision_completion -n '__fish_git_using_command fetch' -l negotiation-tip -d 'Only report commits reachable from these tips' -x
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'
@@ -1087,10 +1122,8 @@ complete -f -c git -n "__fish_git_using_command remote" -n "__fish_seen_subcomma
### show
complete -f -c git -n __fish_git_needs_command -a show -d 'Show the last commit of a branch'
complete -f -c git -n '__fish_git_using_command show' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command show' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_tags)' -d Tag
complete -f -c git -n '__fish_git_using_command show' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_commits)'
complete -f -c git -n '__fish_git_using_command show' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_complete_stashes)'
__fish_git_add_revision_completion -n '__fish_git_using_command show'
complete -f -c git -n __fish_git_needs_rev_files -n 'not contains -- -- (commandline -xpc)' -xa '(__fish_git_complete_rev_files)'
complete -F -c git -n '__fish_git_using_command show' -n 'contains -- -- (commandline -xpc)'
complete -f -c git -n '__fish_git_using_command show' -l format -d 'Pretty-print the contents of the commit logs in a given format' -a '(__fish_git_show_opt format)'
@@ -1179,13 +1212,12 @@ complete -c git -n '__fish_git_using_command am' -l show-current-patch -a 'diff
### checkout
complete -F -c git -n '__fish_git_using_command checkout' -n 'contains -- -- (commandline -xpc)'
complete -f -c git -n __fish_git_needs_command -a checkout -d 'Checkout and switch to a branch'
begin
set -lx __fish_git_extra_recent_commits true
set -lx __fish_git_unqualified_unique_remote_branches true
__fish_git_add_revision_completion -n '__fish_git_using_command checkout'
end
# The following dynamic, order-preserved (-k) completions will be shown in reverse order (see #9221)
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_recent_commits --all)'
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_tags)' -d Tag
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_heads)' -d Head
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch'
complete -f -c git -n '__fish_git_using_command checkout' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_branches)'
# In the presence of changed files, `git checkout ...` assumes highest likelihood is intent to restore so this comes last (aka shown first).
complete -f -c git -n '__fish_git_using_command checkout' -ka '(__fish_git_files modified deleted modified-staged-deleted)'
@@ -1422,9 +1454,7 @@ complete -x -c git -n '__fish_git_using_command daemon' -l access-hook -d 'Hook
### describe
complete -c git -n __fish_git_needs_command -a describe -d 'Give an object a human readable name'
complete -f -c git -n '__fish_git_using_command describe' -ka '(__fish_git_tags)' -d Tag
complete -f -c git -n '__fish_git_using_command describe' -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command describe' -ka '(__fish_git_heads)' -d Head
__fish_git_add_revision_completion -n '__fish_git_using_command describe'
complete -f -c git -n '__fish_git_using_command describe' -l dirty -d 'Describe the state of the working tree, append dirty if there are local changes'
complete -f -c git -n '__fish_git_using_command describe' -l broken -d 'Describe the state of the working tree, append -broken instead of erroring'
complete -f -c git -n '__fish_git_using_command describe' -l all -d 'Use all tags, not just annotated'
@@ -1444,7 +1474,10 @@ complete -f -c git -n '__fish_git_using_command describe' -l first-parent -d 'Fo
complete -c git -n __fish_git_needs_command -a diff -d 'Show changes between commits and working tree'
complete -c git -n '__fish_git_using_command diff' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_ranges)'
complete -c git -n '__fish_git_using_command diff' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_complete_stashes)'
complete -c git -n '__fish_git_using_command diff' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_recent_commits --all)'
begin
set -lx __fish_git_extra_recent_commits true
__fish_git_add_revision_completion -n '__fish_git_using_command diff'
end
complete -c git -n '__fish_git_using_command diff' -l cached -d 'Show diff of changes in the index'
complete -c git -n '__fish_git_using_command diff' -l staged -d 'Show diff of changes in the index'
complete -c git -n '__fish_git_using_command diff' -l no-index -d 'Compare two paths on the filesystem'
@@ -1775,7 +1808,7 @@ complete -f -c git -n '__fish_git_using_command maintenance' -l schedule -d 'Run
### merge
complete -f -c git -n __fish_git_needs_command -a merge -d 'Join multiple development histories'
complete -f -c git -n '__fish_git_using_command merge' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command merge'
complete -f -c git -n '__fish_git_using_command merge' -l commit -d "Autocommit the merge"
complete -f -c git -n '__fish_git_using_command merge' -l no-commit -d "Don't autocommit the merge"
complete -f -c git -n '__fish_git_using_command merge' -s e -l edit -d 'Edit auto-generated merge message'
@@ -1811,7 +1844,7 @@ complete -f -c git -n '__fish_git_using_command merge' -l no-autostash -d 'Do no
### merge-base
complete -f -c git -n __fish_git_needs_command -a merge-base -d 'Find a common ancestor for a merge'
complete -f -c git -n '__fish_git_using_command merge-base' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command merge-base'
complete -f -c git -n '__fish_git_using_command merge-base' -s a -l all -d 'Output all merge bases for the commits, instead of just one'
complete -f -c git -n '__fish_git_using_command merge-base' -l octopus -d 'Compute the best common ancestors of all supplied commits'
complete -f -c git -n '__fish_git_using_command merge-base' -l independent -d 'Print a minimal subset of the supplied commits with the same ancestors'
@@ -1929,9 +1962,11 @@ complete -f -c git -n '__fish_git_using_command range-diff' -l no-dual-color -d
### push
complete -f -c git -n __fish_git_needs_command -a push -d 'Push changes elsewhere'
complete -f -c git -n '__fish_git_using_command push' -n 'not __fish_git_branch_for_remote' -a '(__fish_git_remotes)' -d 'Remote alias'
complete -f -c git -n '__fish_git_using_command push' -n __fish_git_branch_for_remote -ka '(__fish_git_tags)' -d Tag
complete -f -c git -n '__fish_git_using_command push' -n __fish_git_branch_for_remote -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command push' -n __fish_git_branch_for_remote -ka '(__fish_git_heads)'
begin
# TODO
set -lx __fish_git_filter_non_pushable 'string replace -r "(\t.*)?\$" ":\$1"'
__fish_git_add_revision_completion -n '__fish_git_using_command push' -n __fish_git_branch_for_remote
end
# The "refspec" here is an optional "+" to signify a force-push
complete -f -c git -n '__fish_git_using_command push' -n __fish_git_branch_for_remote -n 'string match -q "+*" -- (commandline -ct)' -ka '+(__fish_git_branches | string replace -r \t".*" "")' -d 'Force-push branch'
# git push REMOTE :BRANCH deletes BRANCH on remote REMOTE
@@ -1958,11 +1993,7 @@ complete -f -c git -n '__fish_git_using_command push' -l progress -d 'Force prog
### rebase
complete -f -c git -n __fish_git_needs_command -a rebase -d 'Reapply commit sequence on a new base'
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_remotes)' -d 'Remote alias'
complete -f -c git -n '__fish_git_using_command rebase' -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_heads)' -d Head
complete -f -c git -n '__fish_git_using_command rebase' -ka '(__fish_git_tags)' -d Tag -k
complete -f -c git -n '__fish_git_using_command rebase' -a '(__fish_git_recent_commits)' -k
__fish_git_add_revision_completion -n '__fish_git_using_command rebase'
complete -f -c git -n '__fish_git_using_command rebase' -n __fish_git_is_rebasing -l continue -d 'Restart the rebasing process'
complete -f -c git -n '__fish_git_using_command rebase' -n __fish_git_is_rebasing -l abort -d 'Abort the rebase operation'
complete -f -c git -n '__fish_git_using_command rebase' -n __fish_git_is_rebasing -l edit-todo -d 'Edit the todo list'
@@ -1987,7 +2018,7 @@ complete -f -c git -n '__fish_git_using_command rebase' -l no-autosquash -d 'No
complete -f -c git -n '__fish_git_using_command rebase' -l autostash -d 'Before starting rebase, stash local changes, and apply stash when done'
complete -f -c git -n '__fish_git_using_command rebase' -l no-autostash -d 'Do not stash local changes before starting rebase'
complete -f -c git -n '__fish_git_using_command rebase' -l no-ff -d 'No fast-forward'
complete -f -c git -n '__fish_git_using_command rebase' -l onto -d 'Rebase current branch onto given upstream or newbase' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command rebase' -l onto -d 'Rebase current branch onto given upstream or newbase' -r
complete -f -c git -n '__fish_git_using_command rebase' -l update-refs -d 'Update any branches that point to commits being rebased'
complete -f -c git -n '__fish_git_using_command rebase' -l no-update-refs -d 'Don\'t update any branches that point to commits being rebased'
# This actually takes script for $SHELL, but completing that is... complicated.
@@ -2006,7 +2037,7 @@ complete -c git -n __fish_git_needs_command -a reset -d 'Reset current HEAD to t
complete -f -c git -n '__fish_git_using_command reset' -l hard -d 'Reset the index and the working tree'
complete -f -c git -n '__fish_git_using_command reset' -l soft -d 'Reset head without touching the index or the working tree'
complete -f -c git -n '__fish_git_using_command reset' -l mixed -d 'The default: reset the index but not the working tree'
complete -c git -n '__fish_git_using_command reset' -n 'not contains -- -- (commandline -xpc)' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command reset'
# reset can either undo changes to versioned modified files,
# or remove files from the staging area.
# Deleted files seem to need a "--" separator.
@@ -2038,7 +2069,10 @@ complete -f -c git -n '__fish_git_using_command switch' -ka '(__fish_git_unique_
complete -f -c git -n '__fish_git_using_command switch' -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command switch' -s c -l create -d 'Create a new branch'
complete -f -c git -n '__fish_git_using_command switch' -s C -l force-create -d 'Force create a new branch'
complete -f -c git -n '__fish_git_using_command switch' -s d -l detach -rka '(__fish_git_recent_commits --all)'
begin
set -lx __fish_git_extra_recent_commits true
__fish_git_add_revision_completion -n '__fish_git_using_command switch' -s d -l detach -r
end
complete -f -c git -n '__fish_git_using_command switch' -s d -l detach -d 'Switch to a commit for inspection and discardable experiment' -rka '(__fish_git_refs)'
complete -f -c git -n '__fish_git_using_command switch' -l guess -d 'Guess branch name from remote branch (default)'
complete -f -c git -n '__fish_git_using_command switch' -l no-guess -d 'Do not guess branch name from remote branch'
@@ -2063,9 +2097,7 @@ complete -f -c git -n __fish_git_needs_command -a rev-list -d 'List commits in c
### rev-parse
complete -f -c git -n __fish_git_needs_command -a rev-parse -d 'Parse revision names or give repo information'
complete -f -c git -n '__fish_git_using_command rev-parse' -ka '(__fish_git_branches)'
complete -f -c git -n '__fish_git_using_command rev-parse' -a '(__fish_git_heads)' -d Head
complete -c git -n '__fish_git_using_command rev-parse' -ka '(__fish_git_tags)' -d Tag
__fish_git_add_revision_completion -n '__fish_git_using_command rev-parse'
complete -c git -n '__fish_git_using_command rev-parse' -l abbrev-ref -d 'Output non-ambiguous short object names'
### revert
@@ -2115,7 +2147,7 @@ complete -f -c git -n '__fish_git_using_command stripspace' -s c -l comment-line
### tag
complete -f -c git -n __fish_git_needs_command -a tag -d 'Create, list, delete or verify a tag object signed with GPG'
complete -f -c git -n '__fish_git_using_command tag' -n '__fish_not_contain_opt -s d' -n '__fish_not_contain_opt -s v' -n 'test (count (commandline -xpc | string match -r -v \'^-\')) -eq 3' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command tag' -n '__fish_not_contain_opt -s d' -n '__fish_not_contain_opt -s v' -n 'test (count (commandline -xpc | string match -r -v \'^-\')) -eq 3'
complete -f -c git -n '__fish_git_using_command tag' -s a -l annotate -d 'Make an unsigned, annotated tag object'
complete -f -c git -n '__fish_git_using_command tag' -s s -l sign -d 'Make a GPG-signed tag'
complete -f -c git -n '__fish_git_using_command tag' -s d -l delete -d 'Remove a tag'
@@ -2176,11 +2208,10 @@ complete -f -c git -n "__fish_git_using_command worktree" -n "not __fish_seen_su
complete -f -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add move remove' -s f -l force -d 'Override safeguards'
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add'
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -ka '(__fish_git_branches)'
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -ka '(__fish_git_heads)' -d Head
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -ka '(__fish_git_tags)' -d Tag
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -ka '(__fish_git_unique_remote_branches)' -d 'Unique Remote Branch'
complete -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -ka '(__fish_git_local_branches)'
begin
set -lx __fish_git_unqualified_unique_remote_branches true
__fish_git_add_revision_completion -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add'
end
complete -x -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -s b -d 'Create a new branch'
complete -x -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -s B -d 'Create a new branch even if it already exists'
complete -f -c git -n '__fish_git_using_command worktree' -n '__fish_seen_subcommand_from add' -l detach -d 'Detach HEAD in the new working tree'
@@ -2216,11 +2247,7 @@ complete -f -c git -n '__fish_git_using_command stash' -n __fish_git_stash_not_u
complete -f -c git -n '__fish_git_using_command stash' -n __fish_git_stash_not_using_subcommand -a branch -d 'Create a new branch from a stash'
complete -f -c git -n '__fish_git_using_command stash' -n __fish_git_stash_not_using_subcommand -a push -d 'Create a new stash with given files'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command apply' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command branch' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command drop' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command pop' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command show' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command apply branch drop pop show' -ka '(__fish_git_complete_stashes)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command push' -a '(__fish_git_files modified deleted modified-staged-deleted)'
complete -f -c git -n '__fish_git_using_command stash' -n '__fish_git_stash_using_command push' -s a -l all -d 'Stash ignored and untracked files'
@@ -2237,7 +2264,7 @@ complete -f -c git -n __fish_git_needs_command -a config -d 'Set and read git co
### format-patch
complete -f -c git -n __fish_git_needs_command -a format-patch -d 'Generate patch series to send upstream'
complete -f -c git -n '__fish_git_using_command format-patch' -ka '(__fish_git_branches)'
__fish_git_add_revision_completion -n '__fish_git_using_command format-patch'
complete -c git -n '__fish_git_using_command format-patch' -s o -l output-directory -xa '(__fish_complete_directories)'
complete -f -c git -n '__fish_git_using_command format-patch' -s p -l no-stat -d "Generate plain patches without diffstat"
complete -f -c git -n '__fish_git_using_command format-patch' -s s -l no-patch -d "Suppress diff output"
@@ -2599,3 +2626,8 @@ for file in (path filter -xZ $PATH/git-* | path basename)
complete -c git -f -n "__fish_git_using_command $cmd" -a "(__fish_git_complete_custom_command $cmd)"
set -a __fish_git_custom_commands_completion $file
end
functions --erase __fish_git_add_revision_completion
set -eg __fish_git_extra_recent_commits
set -eg __fish_git_unqualified_unique_remote_branches
set -eg __fish_git_filter_non_pushable

View File

@@ -260,10 +260,12 @@ function __fish_complete_ip
case address
# We're still _on_ the second word, which is the subcommand
if not set -q cmd[3]
printf '%s\t%s\n' add "Add new protocol address" \
printf '%s\t%s\n' \
add "Add new protocol address" \
delete "Delete protocol address" \
show "Look at protocol addresses" \
flush "Flush protocol addresses"
flush "Flush protocol addresses" \
help "Display help"
else
switch $cmd[2]
# Change and replace are undocumented (apart from mentions in the BNF)
@@ -339,7 +341,8 @@ function __fish_complete_ip
end
case link
if not set -q cmd[3]
printf '%s\t%s\n' add "Add virtual link" \
printf '%s\t%s\n' \
add "Add virtual link" \
delete "Delete virtual link" \
set "Change device attributes" \
show "Display device attributes" \
@@ -430,18 +433,20 @@ function __fish_complete_ip
end
case show
case help
__fish_ip_types
end
end
case neighbour
if not set -q cmd[3]
printf '%s\t%s\n' help "Show help" \
printf '%s\t%s\n' \
add "Add new neighbour entry" \
delete "Delete neighbour entry" \
change "Change neighbour entry" \
replace "Add or change neighbour entry" \
show "List neighbour entries" \
flush "Flush neighbour entries" \
get "Lookup neighbour entry"
get "Lookup neighbour entry" \
help "Display help"
else
switch $cmd[2]
case add del delete change replace
@@ -505,7 +510,8 @@ function __fish_complete_ip
get "Get a single route" \
save "Save routing table to stdout" \
showdump "Show saved routing table from stdin" \
restore "Restore routing table from stdin"
restore "Restore routing table from stdin" \
help "Display help"
else
# TODO: switch on $cmd[2] and complete subcommand specific arguments
# for now just complete most useful arguments for the last token
@@ -524,7 +530,8 @@ function __fish_complete_ip
flush "Flush rules" \
show "List rules" \
save "Save rules to stdout" \
restore "Restore rules from stdin"
restore "Restore rules from stdin" \
help "Display help"
else
# TODO: switch on $cmd[2] and complete subcommand specific arguments
# for now just complete most useful arguments for the last token
@@ -579,6 +586,27 @@ function __fish_complete_ip
end
end
end
case tuntap
if not set -q cmd[3]
printf '%s\t%s\n' \
add "Add a new tun or tap device" \
del "Delete a tun or tap device" \
show "Show tun and tap devices" \
help "Display help"
else
switch $cmd[-2]
case dev
__fish_ip_device
case mode
printf '%s\n' tun tap
case user
__fish_complete_users
case group
__fish_complete_groups
case '*'
printf '%s\n' dev mode user group one_queue pi vnet_hdr multi_queue name
end
end
end
end

View File

@@ -1,4 +1,4 @@
#Keybase 5.6.1
# Keybase 6.4.0
function __fish_keybase_line_ends_with
set -l line (commandline -pxc | string match -v -r '^-')
@@ -9,123 +9,132 @@ function __fish_keybase_line_ends_with
end
end
#variables
# variables
set -l ends __fish_keybase_line_ends_with
set -l seen __fish_seen_subcommand_from
#L1
set -l keybase account blocks bot chat config ctl currency decrypt deprovision device encrypt follow fs git h help id kvstore list-followers list-following log login logout oneshot paperkey passphrase pgp ping prove rekey selfprovision service sign signup sigs status team track unfollow untrack update verify version wallet whoami
#L2
set -l keybase_account contact-settings delete email h help lockdown recover-username upload-avatar
set -l keybase_blocks h help list-users list-teams
# 1
set -l keybase account apicall audit base62 blocks bot btc ca chat config ctl currency db decrypt deprovision device dir dismiss dismiss-category dump-keyfamily dump-push-notifications encrypt fnmr follow fs git h help home id interesting-people kvstore list-followers list-following log login logout network-stats oneshot paperkey passphrase pgp ping pprof prove push rekey riit script selfprovision service sign signup sigs status team track unfollow unlock untrack upak update upload-avatar verify version wallet web-auth-token whoami wot
# 2
set -l keybase_account contact-settings delete email h help lockdown phonenumber recover-username reset-cancel upload-avatar
set -l keybase_audit box h help
set -l keybase_base62 decode encode h help
set -l keybase_blocks h help list-teams list-users
set -l keybase_bot h help signup token
set -l keybase_chat add-bot-member add-to-channel api api-listen bot-member-settings clear-commands conv-info create-channel default-channels delete-channel delete-history download edit-bot-member featured-bots h help hide join-channel leave-channel list list-channels list-members list-unread ls lsur min-writer-role mute notification-settings read readd-member remove-bot-member rename-channel report retention-policy search search-bots search-regexp send upload
set -l keybase_chat add-bot-member add-to-channel api api-listen archive archive-delete archive-list archive-pause archive-resume bot-member-settings clear-commands conv-info create-channel default-channels delete-channel delete-history download edit-bot-member emoji-add emoji-addalias emoji-list emoji-remove featured-bots forward-message h help hide join-channel leave-channel list list-channels list-members list-unread ls lsur mark-as-read min-writer-role mute notification-settings read readd-member remove-bot-member remove-from-channel rename-channel report retention-policy search search-bots search-regexp send upload
set -l keybase_config get h help info set
set -l keybase_ctl app-exit autostart h help init log-rotate redirector reload restart start stop wait watchdog watchdog2
set -l keybase_ctl app-exit autostart h help init log-rotate redirector reload restart start stop wait wants-systemd watchdog watchdog2
set -l keybase_currency add h help
set -l keybase_db clean delete get h help keys-with-prefix nuke put
set -l keybase_device add h help list remove
set -l keybase_fs clear-conflicts cp debug finish-resolving-conflicts get-status h help history kill ln ls mkdir mv ps quota read recover reset rm set-debug-level stat sync uploads write
set -l keybase_git create delete gc h help lfs-config list settings
set -l keybase_fs archive cancel-uploads clear-conflicts cp debug finish-resolving-conflicts get-status h help history index-progress kill ln ls mkdir mv ps quota read recover reset reset-index rm search set-debug-level stat sync uploads write
set -l keybase_git archive create delete gc h help lfs-config list settings
set -l keybase_help advanced gpg keyring tor
set -l keybase_kvstore api h help
set -l keybase_log h help send
set -l keybase_log h help profile send
set -l keybase_passphrase change check h help recover remember set
set -l keybase_pgp decrypt drop encrypt export gen h help import list pull pull-private purge push-private select sign update verify
set -l keybase_pprof cpu h heap help trace
set -l keybase_rekey h help paper status
set -l keybase_sigs h help list revoke
set -l keybase_team accept-invite add-member add-members-bulk api bot-settings create delete edit-member h help ignore-request leave list-members list-memberships list-requests remove-member rename request-access search settings show-tree
set -l keybase_team accept-invite add-member add-members-bulk api bot-settings create delete edit-member ftl generate-invite-token generate-invitelink h help ignore-request leave list-members list-memberships list-requests profile-load remove-member rename request-access search settings show-tree
set -l keybase_update check check-in-use notify
set -l keybase_wallet accounts add-trustline api asset-search balances cancel cancel-request change-trustline-limit delete-trustline detail details export get-inflation get-started h help history import list lookup merge popular-assets reclaim rename request send send-path-payment set-currency set-inflation set-primary sign
#L3
set -l keybase_wallet accounts balances detail details export h help list
set -l keybase_wot accept h help list reject vouch
# 3
set -l keybase_account_email add delete edit h help list send-verification-email set-primary set-visibility
set -l keybase_account_phonenumber add delete edit h help list set-visibility verify
set -l keybase_bot_token create delete h help list
set -l keybase_fs_archive cancel check check dismiss h help start status
set -l keybase_fs_debug deobfuscate dump h help obfuscate
set -l keybase_fs_sync disable enable h help show
#...
#global options
complete -c keybase -f -n "$ends keybase" -l api-dump-unsafe
complete -c keybase -f -n "$ends keybase" -l api-timeout
complete -c keybase -f -n "$ends keybase" -l api-uri-path-prefix
complete -c keybase -f -n "$ends keybase" -l app-start-mode
complete -c keybase -f -n "$ends keybase" -l auto-fork
complete -c keybase -f -n "$ends keybase" -l bg-identifier-disabled
complete -c keybase -f -n "$ends keybase" -l chat-db
complete -c keybase -f -n "$ends keybase" -l code-signing-kids
complete -c keybase -f -n "$ends keybase" -l config-file -s c
complete -c keybase -f -n "$ends keybase" -l db
complete -c keybase -f -n "$ends keybase" -l debug -s d
complete -c keybase -f -n "$ends keybase" -l debug-journeycard
complete -c keybase -f -n "$ends keybase" -l disable-bg-conv-loader
complete -c keybase -f -n "$ends keybase" -l disable-cert-pinning
complete -c keybase -f -n "$ends keybase" -l disable-merkle-auditor
complete -c keybase -f -n "$ends keybase" -l disable-search-indexer
complete -c keybase -f -n "$ends keybase" -l disable-team-auditor
complete -c keybase -f -n "$ends keybase" -l disable-team-box-auditor
complete -c keybase -f -n "$ends keybase" -l display-raw-untrusted-output
complete -c keybase -f -n "$ends keybase" -l ek-log-file
complete -c keybase -f -n "$ends keybase" -l enable-bot-lite-mode
complete -c keybase -f -n "$ends keybase" -l extra-net-logging
complete -c keybase -f -n "$ends keybase" -l features
complete -c keybase -f -n "$ends keybase" -l force-linux-keyring
complete -c keybase -f -n "$ends keybase" -l generate-bash-completion
complete -c keybase -f -n "$ends keybase" -l gpg
complete -c keybase -f -n "$ends keybase" -l gpg-options
complete -c keybase -f -n "$ends keybase" -l gpgdir
complete -c keybase -f -n "$ends keybase" -l gui-config-file
complete -c keybase -f -n "$ends keybase" -l help -s h
complete -c keybase -f -n "$ends keybase" -l home -s H
complete -c keybase -f -n "$ends keybase" -l leveldb-num-files
complete -c keybase -f -n "$ends keybase" -l local-rpc-debug-unsafe
complete -c keybase -f -n "$ends keybase" -l log-file
complete -c keybase -f -n "$ends keybase" -l log-format
complete -c keybase -f -n "$ends keybase" -l log-prefix
complete -c keybase -f -n "$ends keybase" -l merkle-kids
complete -c keybase -f -n "$ends keybase" -l no-auto-fork -s F
complete -c keybase -f -n "$ends keybase" -l no-debug
complete -c keybase -f -n "$ends keybase" -l paramproof-kit
complete -c keybase -f -n "$ends keybase" -l pgpdir
complete -c keybase -f -n "$ends keybase" -l pid-file
complete -c keybase -f -n "$ends keybase" -l pinentry
complete -c keybase -f -n "$ends keybase" -l proof-cache-size
complete -c keybase -f -n "$ends keybase" -l prove-bypass
complete -c keybase -f -n "$ends keybase" -l proxy
complete -c keybase -f -n "$ends keybase" -l proxy-type
complete -c keybase -f -n "$ends keybase" -l push-disabled
complete -c keybase -f -n "$ends keybase" -l push-save-interval
complete -c keybase -f -n "$ends keybase" -l push-server-uri
complete -c keybase -f -n "$ends keybase" -l pvl-kit
complete -c keybase -f -n "$ends keybase" -l read-deleted-sigchain
complete -c keybase -f -n "$ends keybase" -l remember-passphrase
complete -c keybase -f -n "$ends keybase" -l run-mode
complete -c keybase -f -n "$ends keybase" -l scraper-timeout
complete -c keybase -f -n "$ends keybase" -l secret-keyring
complete -c keybase -f -n "$ends keybase" -l server -s s
complete -c keybase -f -n "$ends keybase" -l session-file
complete -c keybase -f -n "$ends keybase" -l slow-gregor-conn
complete -c keybase -f -n "$ends keybase" -l socket-file
complete -c keybase -f -n "$ends keybase" -l standalone
complete -c keybase -f -n "$ends keybase" -l timers
complete -c keybase -f -n "$ends keybase" -l tor-hidden-address
complete -c keybase -f -n "$ends keybase" -l tor-mode
complete -c keybase -f -n "$ends keybase" -l tor-proxy
complete -c keybase -f -n "$ends keybase" -l updater-config-file
complete -c keybase -f -n "$ends keybase" -l use-default-log-file
complete -c keybase -f -n "$ends keybase" -l use-root-config-file
complete -c keybase -f -n "$ends keybase" -l user-cache-size
complete -c keybase -f -n "$ends keybase" -l vdebug
complete -c keybase -f -n "$ends keybase" -l version -s v
# global options
complete -c keybase -f -n "$ends keybase" -l api-dump-unsafe -d "Dump API call internals (may leak secrets)"
complete -c keybase -f -n "$ends keybase" -l api-timeout -d "Set the HTTP timeout for API calls to the keybase API server"
complete -c keybase -f -n "$ends keybase" -l api-uri-path-prefix -d "Specify an alternate API URI path prefix"
complete -c keybase -f -n "$ends keybase" -l app-start-mode -d "Specify 'service' to auto-start UI app, or anything else to disable"
complete -c keybase -f -n "$ends keybase" -l auto-fork -d "Enable auto-fork of background service"
complete -c keybase -f -n "$ends keybase" -l bg-identifier-disabled -d "Supply to disable the BG identifier loop"
complete -c keybase -f -n "$ends keybase" -l chat-db -d "Specify an alternate local Chat DB location"
complete -c keybase -f -n "$ends keybase" -l code-signing-kids -d "Set of code signing key IDs (colon-separated)"
complete -c keybase -f -n "$ends keybase" -l config-file -s c -d "Specify an (alternate) master config file"
complete -c keybase -f -n "$ends keybase" -l db -d "Specify an alternate local DB location"
complete -c keybase -f -n "$ends keybase" -l debug -s d -d "Enable debugging mode"
complete -c keybase -f -n "$ends keybase" -l debug-journeycard -d "Enable experimental journey cards"
complete -c keybase -f -n "$ends keybase" -l disable-bg-conv-loader -d "Disable background conversation loading"
complete -c keybase -f -n "$ends keybase" -l disable-cert-pinning -d "WARNING: Do not use unless necessary!"
complete -c keybase -f -n "$ends keybase" -l disable-merkle-auditor -d "Disable background probabilistic merkle audit"
complete -c keybase -f -n "$ends keybase" -l disable-search-indexer -d "Disable chat search background indexer"
complete -c keybase -f -n "$ends keybase" -l disable-team-auditor -d "Disable auditing of teams"
complete -c keybase -f -n "$ends keybase" -l disable-team-box-auditor -d "Disable box auditing of teams"
complete -c keybase -f -n "$ends keybase" -l display-raw-untrusted-output -d "Display output from users without escaping terminal codes"
complete -c keybase -f -n "$ends keybase" -l ek-log-file -d "Specify a log file for the keybase ephemeral key log"
complete -c keybase -f -n "$ends keybase" -l enable-bot-lite-mode -d "Enable bot lite mode. Disables non-critical background services"
complete -c keybase -f -n "$ends keybase" -l extra-net-logging -d "Do additional debug logging during network requests"
complete -c keybase -f -n "$ends keybase" -l features -d "Specify experimental feature flags"
complete -c keybase -f -n "$ends keybase" -l force-linux-keyring -d "Require the use of the OS keyring"
complete -c keybase -f -n "$ends keybase" -l generate-bash-completion -d ""
complete -c keybase -f -n "$ends keybase" -l gpg -d "Path to GPG client (optional for exporting keys)"
complete -c keybase -f -n "$ends keybase" -l gpg-options -d "Options to use when calling GPG"
complete -c keybase -f -n "$ends keybase" -l gpgdir -d "Specify a PGP directory (default is ~/.gnupg)"
complete -c keybase -f -n "$ends keybase" -l gui-config-file -d "Specify a path to the GUI config file"
complete -c keybase -f -n "$ends keybase" -l help -s h -d "Show help"
complete -c keybase -f -n "$ends keybase" -l home -s H -d "Specify an (alternate) home directory"
complete -c keybase -f -n "$ends keybase" -l leveldb-num-files -d "Specify the max number of files LevelDB may open"
complete -c keybase -f -n "$ends keybase" -l local-rpc-debug-unsafe -d "Use to debug local RPC (may leak secrets)"
complete -c keybase -f -n "$ends keybase" -l log-file -d "Specify a log file for the keybase service"
complete -c keybase -f -n "$ends keybase" -l log-format -d "Log format (default, plain, file, fancy)"
complete -c keybase -f -n "$ends keybase" -l log-prefix -d "Specify a prefix for a unique log file name"
complete -c keybase -f -n "$ends keybase" -l merkle-kids -d "Set of admissible Merkle Tree fingerprints (colon-separated)"
complete -c keybase -f -n "$ends keybase" -l no-auto-fork -s F -d "Disable auto-fork of background service"
complete -c keybase -f -n "$ends keybase" -l no-debug -d "Suppress debugging mode; takes precedence over --debug"
complete -c keybase -f -n "$ends keybase" -l paramproof-kit -d "Specify an alternate local parameterized proof kit file location"
complete -c keybase -f -n "$ends keybase" -l pgpdir -d "Specify a PGP directory (default is ~/.gnupg)"
complete -c keybase -f -n "$ends keybase" -l pid-file -d "Location of the keybased pid-file (to ensure only one running daemon)"
complete -c keybase -f -n "$ends keybase" -l pinentry -d "Specify a path to find a pinentry program"
complete -c keybase -f -n "$ends keybase" -l proof-cache-size -d "Number of proof entries to cache"
complete -c keybase -f -n "$ends keybase" -l prove-bypass -d "Prove even disabled proof services"
complete -c keybase -f -n "$ends keybase" -l proxy -d "Specify a proxy to ship all Web requests over"
complete -c keybase -f -n "$ends keybase" -l proxy-type -d "Set the proxy type; One of: socks,http_connect"
complete -c keybase -f -n "$ends keybase" -l push-disabled -d "Disable push server connection (which is on by default)"
complete -c keybase -f -n "$ends keybase" -l push-save-interval -d "Set the interval between saves of the push cache (in seconds)"
complete -c keybase -f -n "$ends keybase" -l push-server-uri -d "Specify a URI for contacting the Keybase push server"
complete -c keybase -f -n "$ends keybase" -l pvl-kit -d "Specify an alternate local PVL kit file location"
complete -c keybase -f -n "$ends keybase" -l read-deleted-sigchain -d "Allow admins to read deleted sigchains for debugging"
complete -c keybase -f -n "$ends keybase" -l remember-passphrase -d "Remember keybase passphrase"
complete -c keybase -f -n "$ends keybase" -l run-mode -d "Run mode (devel, staging, prod)"
complete -c keybase -f -n "$ends keybase" -l scraper-timeout -d "Set the HTTP timeout for external proof scrapers"
complete -c keybase -f -n "$ends keybase" -l secret-keyring -d "Location of the Keybase secret-keyring (P3SKB-encoded)"
complete -c keybase -f -n "$ends keybase" -l server -s s -d "Specify server API"
complete -c keybase -f -n "$ends keybase" -l session-file -d "Specify an alternate session data file"
complete -c keybase -f -n "$ends keybase" -l slow-gregor-conn -d "Slow responses from gregor for testing"
complete -c keybase -f -n "$ends keybase" -l socket-file -d "Location of the keybased socket-file"
complete -c keybase -f -n "$ends keybase" -l standalone -d "Use the client without any daemon support"
complete -c keybase -f -n "$ends keybase" -l timers -d "Specify 'a' for API; 'r' for RPCs; and 'x' for eXternal API calls"
complete -c keybase -f -n "$ends keybase" -l tor-hidden-address -d "Set TOR address of keybase server"
complete -c keybase -f -n "$ends keybase" -l tor-mode -d "Set TOR mode to be 'leaky', 'none', or 'strict'"
complete -c keybase -f -n "$ends keybase" -l tor-proxy -d "Set TOR proxy; when Tor mode is on; defaults to localhost:9050"
complete -c keybase -f -n "$ends keybase" -l updater-config-file -d "Specify a path to the updater config file"
complete -c keybase -f -n "$ends keybase" -l use-default-log-file -d "Log to the default log file in $XDG_CACHE_HOME, or ~/.cache if unset"
complete -c keybase -f -n "$ends keybase" -l use-root-config-file -d "Use the default root config on Linux only"
complete -c keybase -f -n "$ends keybase" -l user-cache-size -d "Number of User entries to cache"
complete -c keybase -f -n "$ends keybase" -l vdebug -d "Verbose debugging; takes a comma-joined list of levels and tags"
complete -c keybase -f -n "$ends keybase" -l version -s v -d "Print the version"
#commands
#L1
# commands
# 1
complete -c keybase -f -n "not $ends keybase"
complete -c keybase -f -n "$ends keybase" -a "$keybase"
#L2
# 2
complete -c keybase -f -n "$ends keybase account" -a "$keybase_account"
complete -c keybase -f -n "$ends keybase audit" -a "$keybase_audit"
complete -c keybase -f -n "$ends keybase base62" -a "$keybase_base62"
complete -c keybase -f -n "$ends keybase blocks" -a "$keybase_blocks"
complete -c keybase -f -n "$ends keybase bot" -a "$keybase_bot"
complete -c keybase -f -n "$ends keybase chat" -a "$keybase_chat"
complete -c keybase -f -n "$ends keybase config" -a "$keybase_config"
complete -c keybase -f -n "$ends keybase ctl" -a "$keybase_ctl"
complete -c keybase -f -n "$ends keybase currency" -a "$keybase_currency"
complete -c keybase -f -n "$ends keybase db" -a "$keybase_db"
complete -c keybase -f -n "$ends keybase device" -a "$keybase_device"
complete -c keybase -f -n "$ends keybase fs" -a "$keybase_fs"
complete -c keybase -f -n "$ends keybase git" -a "$keybase_git"
@@ -135,19 +144,22 @@ complete -c keybase -f -n "$ends keybase kvstore" -a "$keybase_kvstore"
complete -c keybase -f -n "$ends keybase log" -a "$keybase_log"
complete -c keybase -f -n "$ends keybase passphrase" -a "$keybase_passphrase"
complete -c keybase -f -n "$ends keybase pgp" -a "$keybase_pgp"
complete -c keybase -f -n "$ends keybase pprof" -a "$keybase_pprof"
complete -c keybase -f -n "$ends keybase rekey" -a "$keybase_rekey"
complete -c keybase -f -n "$ends keybase sigs" -a "$keybase_sigs"
complete -c keybase -f -n "$ends keybase team" -a "$keybase_team"
complete -c keybase -f -n "$ends keybase update" -a "$keybase_update"
complete -c keybase -f -n "$ends keybase wallet" -a "$keybase_wallet"
#...
#L3
complete -c keybase -f -n "$ends keybase wot" -a "$keybase_wot"
# 3
complete -c keybase -f -n "$ends keybase account email" -a "$keybase_account_email"
complete -c keybase -f -n "$ends keybase account phonenumber" -a "$keybase_account_phonenumber"
complete -c keybase -f -n "$ends keybase bot token" -a "$keybase_bot_token"
complete -c keybase -f -n "$ends keybase fs archive" -a "$keybase_fs_archive"
complete -c keybase -f -n "$ends keybase fs debug" -a "$keybase_fs_debug"
complete -c keybase -f -n "$ends keybase fs sync" -a "$keybase_fs_sync"
#...
#command options
# command options
complete -c keybase -f -n "$ends keybase account upload-avatar" -l skip-chat-message -s s
complete -c keybase -f -n "$ends keybase account upload-avatar" -l team
#...
# ...

View File

@@ -133,7 +133,7 @@ complete -c set -n '__fish_set_is_color true false' -a --dim -x
complete -c set -n '__fish_set_is_color true false' -a --italics -x
complete -c set -n '__fish_set_is_color true true' -a --reverse -x
complete -c set -n '__fish_set_is_color true false' -a --underline -x
complete -c set -n '__fish_set_is_color true false' -a --underline=curly -x
complete -c set -n '__fish_set_is_color true false' -a--underline={double,curly,dotted,dashed} -x
# Locale completions
complete -c set -n '__fish_set_is_locale; and not __fish_seen_argument -s e -l erase' -x -a '(command -sq locale; and locale -a)' -d Locale

View File

@@ -5,7 +5,6 @@ complete -c set_color -s o -l bold -d 'Make font bold'
complete -c set_color -s i -l italics -d Italicise
complete -c set_color -s d -l dim -d 'Dim text'
complete -c set_color -s r -l reverse -d 'Reverse color text'
complete -c set_color -s u -l underline -d 'Underline style' -a 'single curly'
complete -c set_color -s u -l underline -d 'Underline style' -a 'single double curly dotted dashed'
complete -c set_color -s h -l help -d 'Display help and exit'
complete -c set_color -s c -l print-colors -d 'Print a list of all accepted color names'
complete -c set_color -l track -xa '(fish_config theme list)' -d 'Ignored. Used in color variables to follow theme changes'

View File

@@ -27,9 +27,7 @@ set -l __fish_status_all_commands \
list-files \
print-stack-trace \
stack-trace \
test-feature \
xtgettcap \
xtversion
test-feature
# These are the recognized flags.
complete -c status -s h -l help -d "Display help and exit"
@@ -66,8 +64,6 @@ complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_com
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a get-file -d "Print an embedded file from the fish binary"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a list-files -d "List embedded files contained in the fish binary"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a fish-path -d "Print the path to the current instance of fish"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a xtgettcap -d "Query the terminal for a terminfo capability"
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a xtversion -d "Show terminal name and version"
# The job-control command changes fish state.
complete -f -c status -n "not __fish_seen_subcommand_from $__fish_status_all_commands" -a job-control -d "Set which jobs are under job control"

View File

@@ -1,61 +1,135 @@
# completion for tmutil (macOS)
complete -f -c tmutil -n __fish_use_subcommand -a addexclusion -d 'Add an exclusion not to back up a file'
complete -f -c tmutil -n '__fish_seen_subcommand_from addexclusion' -s v -d 'Volume exclusion'
complete -f -c tmutil -n '__fish_seen_subcommand_from addexclusion' -s p -d 'Path exclusion'
complete -r -c tmutil -n __fish_use_subcommand -a associatedisk -d 'Bind a snapshot volume directory to the specified local disk'
complete -r -c tmutil -n __fish_use_subcommand -a calculatedrift -d 'Determine the amount of change between snapshots'
complete -r -c tmutil -n __fish_use_subcommand -a compare -d 'Perform a backup diff'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s a -d 'Compare all supported metadata'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s n -d 'No metadata comparison'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s @ -d 'Compare extended attributes'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s c -d 'Compare creation times'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s d -d 'Compare file data forks'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s e -d 'Compare ACLs'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s f -d 'Compare file flags'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s g -d 'Compare GIDs'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s m -d 'Compare file modes'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s s -d 'Compare sizes'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s t -d 'Compare modification times'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s u -d 'Compare UIDs'
complete -r -c tmutil -n '__fish_seen_subcommand_from compare' -s D -d 'Limit traversal depth to depth levels from the beginning of iteration'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s E -d 'Dont take exclusions into account'
complete -r -c tmutil -n '__fish_seen_subcommand_from compare' -s I -d 'Ignore path'
complete -f -c tmutil -n '__fish_seen_subcommand_from compare' -s U -d 'Ignore logical volume identity'
complete -r -c tmutil -n __fish_use_subcommand -a delete -d 'Delete one or more snapshots'
complete -r -c tmutil -n __fish_use_subcommand -a deletelocalsnapshots -d 'Delete all local Time Machine snapshots for the specified date (formatted YYYY-MM-DD-HHMMSS)'
complete -f -c tmutil -n __fish_use_subcommand -a destinationinfo -d 'Print information about destinations'
complete -f -c tmutil -n __fish_use_subcommand -a disable -d 'Turn off automatic backups'
complete -f -c tmutil -n __fish_use_subcommand -a disablelocal -d 'Turn off local Time Machine snapshots'
complete -f -c tmutil -n __fish_use_subcommand -a enable -d 'Turn on automatic backups'
complete -f -c tmutil -n __fish_use_subcommand -a enablelocal -d 'Turn on local Time Machine snapshots'
complete -r -c tmutil -n __fish_use_subcommand -a inheritbackup -d 'Claim a machine directory or sparsebundle for use by the current machine'
complete -f -c tmutil -n __fish_use_subcommand -a isexcluded -d 'Determine if a file, directory, or volume are excluded from backups'
complete -f -c tmutil -n __fish_use_subcommand -a latestbackup -d 'Print the path to the latest snapshot'
complete -c tmutil -n __fish_use_subcommand -a listlocalsnapshotdates -d 'List the creation dates of all local Time Machine snapshots'
complete -r -c tmutil -n __fish_use_subcommand -a listlocalsnapshots -d 'List local Time Machine snapshots of the specified volume'
complete -f -c tmutil -n __fish_use_subcommand -a listbackups -d 'Print paths for all snapshots'
complete -f -c tmutil -n __fish_use_subcommand -a localsnapshot -d 'Create new local Time Machine snapshot of APFS volume in TM backup'
complete -f -c tmutil -n __fish_use_subcommand -a machinedirectory -d 'Print the path to the current machine directory'
complete -f -c tmutil -n __fish_use_subcommand -a removedestination -d 'Removes a backup destination'
complete -f -c tmutil -n __fish_use_subcommand -a removeexclusion -d 'Remove an exclusion'
complete -f -c tmutil -n '__fish_seen_subcommand_from removeexclusion' -s v -d 'Volume exclusion'
complete -f -c tmutil -n '__fish_seen_subcommand_from removeexclusion' -s p -d 'Path exclusion'
complete -f -c tmutil -n __fish_use_subcommand -a restore -d 'Restore an item'
complete -r -c tmutil -n '__fish_seen_subcommand_from restore' -s v
complete -r -c tmutil -n __fish_use_subcommand -a setdestination -d 'Set a backup destination'
complete -f -c tmutil -n '__fish_seen_subcommand_from setdestination' -s a -d 'Add to the list of destinations'
complete -f -c tmutil -n '__fish_seen_subcommand_from setdestination' -s p -d 'Enter the password at a non-echoing interactive prompt'
complete -f -c tmutil -n __fish_use_subcommand -a snapshot -d 'Create new local Time Machine snapshot'
complete -f -c tmutil -n __fish_use_subcommand -a startbackup -d 'Begin a backup if one is not already running'
complete -f -c tmutil -n '__fish_seen_subcommand_from startbackup' -s a -l auto -d 'Automatic mode'
complete -f -c tmutil -n '__fish_seen_subcommand_from startbackup' -s b -l block -d 'Block until finished'
complete -f -c tmutil -n '__fish_seen_subcommand_from startbackup' -s r -l rotation -d 'Automatic rotation'
complete -r -c tmutil -n '__fish_seen_subcommand_from startbackup' -s d -l destination -d 'Backup destination'
complete -f -c tmutil -n __fish_use_subcommand -a stopbackup -d 'Cancel a backup currently in progress'
complete -r -c tmutil -n __fish_use_subcommand -a thinlocalsnapshots -d 'Thin local Time Machine snapshots for the specified volume'
complete -r -c tmutil -n __fish_use_subcommand -a uniquesize -d 'Analyze the specified path and determine its unique size'
complete -r -c tmutil -n __fish_use_subcommand -a verifychecksums -d 'Verify snapshot'
complete -f -c tmutil -n __fish_use_subcommand -a version -d 'Print version'
function __fish_tmutil_destination_ids
for line in $(tmutil destinationinfo)
if string match -q '*===*' -- $line
# New section so clear out variables
set -f name ''
set -f kind ''
continue
end
complete -f -c tmutil -n '__fish_seen_subcommand_from destinationinfo isexcluded compare' -s X -d 'Print as XML'
if string match -q -r '^Name' -- $line
# Got the destination name
set -f name "$(string match -r -g '^Name\s+:\s+(.*)$' $line | string trim)"
continue
end
if string match -q -r '^Kind' -- $line
# Got the destination name
set -f kind "$(string match -r -g '^Kind\s+:\s+(\w+)' $line | string trim)"
continue
end
if string match -q -r '^ID' -- $line
# Got the destination ID
set -f ID "$(string match -r -g '^ID\s+:\s+(.*)$' $line | string trim)"
echo $ID\t$name $kind
continue
end
end
end
complete -c tmutil -n __fish_use_subcommand -a status -d 'Display Time Machine status'
complete -c tmutil -f -n '__fish_seen_subcommand_from status'
complete -c tmutil -f -n __fish_use_subcommand -a addexclusion -d 'Add an exclusion not to back up a file'
complete -c tmutil -r -n '__fish_seen_subcommand_from addexclusion' -s v -d 'Volume exclusion'
complete -c tmutil -r -n '__fish_seen_subcommand_from addexclusion' -s p -d 'Path exclusion'
complete -c tmutil -r -n __fish_use_subcommand -a associatedisk -d 'Bind a snapshot volume directory to the specified local disk'
complete -c tmutil -r -n __fish_use_subcommand -a calculatedrift -d 'Determine the amount of change between snapshots'
complete -c tmutil -r -n __fish_use_subcommand -a compare -d 'Perform a backup diff'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s a -d 'Compare all supported metadata'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s n -d 'No metadata comparison'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s @ -d 'Compare extended attributes'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s c -d 'Compare creation times'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s d -d 'Compare file data forks'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s e -d 'Compare ACLs'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s f -d 'Compare file flags'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s g -d 'Compare GIDs'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s m -d 'Compare file modes'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s s -d 'Compare sizes'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s t -d 'Compare modification times'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s u -d 'Compare UIDs'
complete -c tmutil -r -n '__fish_seen_subcommand_from compare' -s D -d 'Limit traversal depth to depth levels from the beginning of iteration'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s E -d 'Dont take exclusions into account'
complete -c tmutil -r -n '__fish_seen_subcommand_from compare' -s I -d 'Ignore path'
complete -c tmutil -f -n '__fish_seen_subcommand_from compare' -s U -d 'Ignore logical volume identity'
complete -c tmutil -r -n __fish_use_subcommand -a delete -d 'Delete one or more snapshots'
complete -c tmutil -r -n '__fish_seen_subcommand_from delete' -s d -d 'Backup mount point'
complete -c tmutil -r -f -n '__fish_seen_subcommand_from delete' -s t -d Timestamp
complete -c tmutil -r -n '__fish_seen_subcommand_from delete' -s p -d Path
complete -c tmutil -r -n __fish_use_subcommand -a deletelocalsnapshots -d 'Delete all local Time Machine snapshots for the specified date (formatted YYYY-MM-DD-HHMMSS)'
complete -c tmutil -r -n __fish_use_subcommand -a deleteinprogress -d 'Delete all in-progress backups for a machine directory'
complete -c tmutil -f -n __fish_use_subcommand -a destinationinfo -d 'Print information about destinations'
complete -c tmutil -f -n __fish_use_subcommand -a disable -d 'Turn off automatic backups'
complete -c tmutil -f -n __fish_use_subcommand -a disablelocal -d 'Turn off local Time Machine snapshots'
complete -c tmutil -f -n __fish_use_subcommand -a enable -d 'Turn on automatic backups'
complete -c tmutil -f -n __fish_use_subcommand -a enablelocal -d 'Turn on local Time Machine snapshots'
complete -c tmutil -r -n __fish_use_subcommand -a inheritbackup -d 'Claim a machine directory or sparsebundle for use by the current machine'
complete -c tmutil -r -n __fish_use_subcommand -a isexcluded -d 'Determine if a file, directory, or volume are excluded from backups'
complete -c tmutil -f -n __fish_use_subcommand -a latestbackup -d 'Print the path to the latest snapshot'
complete -c tmutil -f -n __fish_use_subcommand -a listlocalsnapshotdates -d 'List the creation dates of all local Time Machine snapshots'
complete -c tmutil -r -n __fish_use_subcommand -a listlocalsnapshots -d 'List local Time Machine snapshots of the specified volume'
complete -c tmutil -f -n __fish_use_subcommand -a listbackups -d 'Print paths for all snapshots'
complete -c tmutil -f -n __fish_use_subcommand -a localsnapshot -d 'Create new local Time Machine snapshot of APFS volume in TM backup'
complete -c tmutil -f -n __fish_use_subcommand -a machinedirectory -d 'Print the path to the current machine directory'
complete -c tmutil -f -n __fish_use_subcommand -a removedestination -d 'Removes a backup destination'
complete -c tmutil -f -n '__fish_seen_subcommand_from removedestination' -a '$(__fish_tmutil_destination_ids)'
complete -c tmutil -f -n __fish_use_subcommand -a removeexclusion -d 'Remove an exclusion'
complete -c tmutil -f -n '__fish_seen_subcommand_from removeexclusion' -s v -d 'Volume exclusion'
complete -c tmutil -f -n '__fish_seen_subcommand_from removeexclusion' -s p -d 'Path exclusion'
complete -c tmutil -f -n __fish_use_subcommand -a restore -d 'Restore an item'
complete -c tmutil -r -n '__fish_seen_subcommand_from restore' -s v
complete -c tmutil -r -n __fish_use_subcommand -a setdestination -d 'Set a backup destination'
complete -c tmutil -f -n '__fish_seen_subcommand_from setdestination' -s a -d 'Add to the list of destinations'
complete -c tmutil -f -n '__fish_seen_subcommand_from setdestination' -s p -d 'Enter the password at a non-echoing interactive prompt'
complete -c tmutil -f -n __fish_use_subcommand -a snapshot -f -d 'Create new local Time Machine snapshot'
complete -c tmutil -f -n __fish_use_subcommand -a startbackup -d 'Begin a backup if one is not already running'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s a -l auto -d 'Automatic mode'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s b -l block -d 'Block until finished'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s r -l rotation -d 'Automatic rotation'
complete -c tmutil -f -n '__fish_seen_subcommand_from startbackup' -s d -l destination -r -a '$(__fish_tmutil_destination_ids)' -d 'Backup destination'
complete -c tmutil -f -n __fish_use_subcommand -a stopbackup -d 'Cancel a backup currently in progress'
complete -c tmutil -r -n __fish_use_subcommand -a thinlocalsnapshots -d 'Thin local Time Machine snapshots for the specified volume'
complete -c tmutil -r -n __fish_use_subcommand -a uniquesize -d 'Analyze the specified path and determine its unique size'
complete -c tmutil -r -n __fish_use_subcommand -a verifychecksums -d 'Verify snapshot'
complete -c tmutil -f -n __fish_use_subcommand -a version -d 'Print version'
complete -c tmutil -f -n __fish_use_subcommand -a setquota -d 'Set the quota for the destination in gigabytes'
complete -c tmutil -f -n '__fish_seen_subcommand_from setquota' -r -a '$(__fish_tmutil_destination_ids)'
complete -c tmutil -f -n '__fish_seen_subcommand_from destinationinfo isexcluded compare status' -s X -d 'Print as XML'
complete -c tmutil -f -n '__fish_seen_subcommand_from latestbackup listbackups' -s m -d 'Destination volume to list backups from'
complete -c tmutil -f -n '__fish_seen_subcommand_from latestbackup listbackups' -s t -d 'Attempt to mount the backups and list their mounted paths'
complete -c tmutil -f -n '__fish_seen_subcommand_from latestbackup listbackups' -s d -d 'Backup mount point'

View File

@@ -1,6 +1,7 @@
# Returns 0 if the command has not had a subcommand yet
# Does not currently account for -chdir
function __fish_terraform_needs_command
function __fish_tofu_needs_command
set -l cmd (commandline -xpc)
if test (count $cmd) -eq 1
@@ -10,19 +11,19 @@ function __fish_terraform_needs_command
return 1
end
function __fish_terraform_workspaces
function __fish_tofu_workspaces
tofu workspace list | string replace -r "^[\s\*]*" ""
end
# general options
complete -f -c tofu -n "not __fish_terraform_needs_command" -o version -d "Print version information"
complete -f -c tofu -n "not __fish_tofu_needs_command" -o version -d "Print version information"
complete -f -c tofu -o help -d "Show help"
### apply/destroy
set -l apply apply destroy
complete -f -c tofu -n __fish_terraform_needs_command -a apply -d "Build or change infrastructure"
complete -f -c tofu -n __fish_terraform_needs_command -a destroy -d "Destroy infrastructure"
complete -f -c tofu -n __fish_tofu_needs_command -a apply -d "Build or change infrastructure"
complete -f -c tofu -n __fish_tofu_needs_command -a destroy -d "Destroy infrastructure"
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o auto-approve -d "Skip interactive approval"
complete -r -c tofu -n "__fish_seen_subcommand_from $apply" -o backup -d "Path to backup the existing state file"
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o compact-warnings -d "Show only error summaries"
@@ -31,17 +32,17 @@ complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o lock-timeout -d "
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o input=true -d "Ask for input for variables if not directly set"
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o no-color -d "If specified, output won't contain any color"
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o parallelism -d "Limit the number of concurrent operations"
complete -r -c tofu -n "__fish_seen_subcommand_from $apply" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from $apply" -o state -d "Path to a OpenTofu state file"
complete -r -c tofu -n "__fish_seen_subcommand_from $apply" -o state-out -d "Path to write state"
### console
complete -f -c tofu -n __fish_terraform_needs_command -a console -d "Interactive console for Terraform interpolations"
complete -r -c tofu -n "__fish_seen_subcommand_from console" -o state -d "Path to a Terraform state file"
complete -f -c tofu -n "__fish_seen_subcommand_from console" -o var -d "Set a variable in the Terraform configuration"
complete -f -c tofu -n __fish_tofu_needs_command -a console -d "Interactive console for OpenTofu interpolations"
complete -r -c tofu -n "__fish_seen_subcommand_from console" -o state -d "Path to a OpenTofu state file"
complete -f -c tofu -n "__fish_seen_subcommand_from console" -o var -d "Set a variable in the OpenTofu configuration"
complete -r -c tofu -n "__fish_seen_subcommand_from console" -o var-file -d "Set variables from a file"
### fmt
complete -f -c tofu -n __fish_terraform_needs_command -a fmt -d "Rewrite config files to canonical format"
complete -f -c tofu -n __fish_tofu_needs_command -a fmt -d "Rewrite config files to canonical format"
complete -f -c tofu -n "__fish_seen_subcommand_from fmt" -o list=false -d "Don't list files whose formatting differs"
complete -f -c tofu -n "__fish_seen_subcommand_from fmt" -o write=false -d "Don't write to source files"
complete -f -c tofu -n "__fish_seen_subcommand_from fmt" -o diff -d "Display diffs of formatting changes"
@@ -50,21 +51,22 @@ complete -f -c tofu -n "__fish_seen_subcommand_from fmt" -o no-color -d "If spec
complete -f -c tofu -n "__fish_seen_subcommand_from fmt" -o recursive -d "Also process files in subdirectories"
### get
complete -f -c tofu -n __fish_terraform_needs_command -a get -d "Download and install modules for the configuration"
complete -f -c tofu -n __fish_tofu_needs_command -a get -d "Download and install modules for the configuration"
complete -f -c tofu -n "__fish_seen_subcommand_from get" -o update -d "Check modules for updates"
complete -f -c tofu -n "__fish_seen_subcommand_from get" -o no-color -d "If specified, output won't contain any color"
### graph
complete -f -c tofu -n __fish_terraform_needs_command -a graph -d "Create a visual graph of Terraform resources"
complete -f -c tofu -n __fish_tofu_needs_command -a graph -d "Create a visual graph of OpenTofu resources"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o plan -d "Use specified plan file instead of current directory"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o draw-cycles -d "Highlight any cycles in the graph"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o type=plan -d "Output plan graph"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o type=plan-refresh-only -d "Output plan graph assuming refresh only"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o type=plan-destroy -d "Output plan graph assuming destroy"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o type=apply -d "Output apply graph"
complete -f -c tofu -n "__fish_seen_subcommand_from graph" -o consice -d "Shorten the plan output"
### import
complete -f -c tofu -n __fish_terraform_needs_command -a import -d "Import existing infrastructure into Terraform"
complete -f -c tofu -n __fish_tofu_needs_command -a import -d "Import existing infrastructure into OpenTofu"
complete -r -c tofu -n "__fish_seen_subcommand_from import" -o backup -d "Path to backup the existing state file"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o config -d "Path to a directory of configuration files"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o allow-missing-config -d "Allow import without resource block"
@@ -72,13 +74,13 @@ complete -f -c tofu -n "__fish_seen_subcommand_from import" -o input=false -d "D
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o lock=false -d "Don't hold a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o lock-timeout -d "Duration to retry a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o no-color -d "If specified, output won't contain any color"
complete -r -c tofu -n "__fish_seen_subcommand_from import" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from import" -o state -d "Path to a OpenTofu state file"
complete -r -c tofu -n "__fish_seen_subcommand_from import" -o state-out -d "Path to write state"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o var -d "Set a variable in the Terraform configuration"
complete -f -c tofu -n "__fish_seen_subcommand_from import" -o var -d "Set a variable in the OpenTofu configuration"
complete -r -c tofu -n "__fish_seen_subcommand_from import" -o var-file -d "Set variables from a file"
### init
complete -f -c tofu -n __fish_terraform_needs_command -a init -d "Initialize a new or existing Terraform configuration"
complete -f -c tofu -n __fish_tofu_needs_command -a init -d "Initialize a new or existing OpenTofu configuration"
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o backend=false -d "Disable backend initialization"
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o cloud=false -d "Disable backend initialization"
complete -r -c tofu -n "__fish_seen_subcommand_from init" -o backend-config -d "Backend configuration"
@@ -95,24 +97,25 @@ complete -r -c tofu -n "__fish_seen_subcommand_from init" -o migrate-state -d "R
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o upgrade -d "Install latest dependencies, ignoring lockfile"
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o lockfile=readonly -d "Set dependency lockfile mode to readonly"
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o ignore-remote-version -d "Ignore local and remote backend compatibility check"
complete -f -c tofu -n "__fish_seen_subcommand_from init" -o json -d "Print output in JSON"
### login
complete -f -c tofu -n __fish_terraform_needs_command -a login -d "Retrieves auth token for the given hostname"
complete -f -c tofu -n __fish_tofu_needs_command -a login -d "Retrieves auth token for the given hostname"
complete -f -c tofu -n "__fish_seen_subcommand_from login" -a "(__fish_print_hostnames)"
### logout
complete -f -c tofu -n __fish_terraform_needs_command -a logout -d "Removes auth token for the given hostname"
complete -f -c tofu -n __fish_tofu_needs_command -a logout -d "Removes auth token for the given hostname"
complete -f -c tofu -n "__fish_seen_subcommand_from logout" -a "(__fish_print_hostnames)"
### output
complete -f -c tofu -n __fish_terraform_needs_command -a output -d "Read an output from a state file"
complete -f -c tofu -n __fish_tofu_needs_command -a output -d "Read an output from a state file"
complete -r -c tofu -n "__fish_seen_subcommand_from output" -o state -d "Path to the state file to read"
complete -f -c tofu -n "__fish_seen_subcommand_from output" -o no-color -d "If specified, output won't contain any color"
complete -f -c tofu -n "__fish_seen_subcommand_from output" -o json -d "Print output in JSON format"
complete -f -c tofu -n "__fish_seen_subcommand_from output" -o raw -d "Print raw strings directly"
### plan
complete -f -c tofu -n __fish_terraform_needs_command -a plan -d "Generate and show an execution plan"
complete -f -c tofu -n __fish_tofu_needs_command -a plan -d "Generate and show an execution plan"
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o compact-warnings -d "Show only error summaries"
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o detailed-exitcode -d "Return detailed exit codes"
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o input=true -d "Ask for input for variables if not directly set"
@@ -121,7 +124,7 @@ complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o lock-timeout -d "Du
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o no-color -d "If specified, output won't contain any color"
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o out -d "Write a plan file to the given path"
complete -f -c tofu -n "__fish_seen_subcommand_from plan" -o parallelism -d "Limit the number of concurrent operations"
complete -r -c tofu -n "__fish_seen_subcommand_from plan" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from plan" -o state -d "Path to a OpenTofu state file"
### plan customization options are reusable across apply, destroy, and plan
set -l plan apply destroy plan
@@ -131,82 +134,86 @@ complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o refresh-only -d "S
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o refresh=false -d "Skip checking for external changes"
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o replace -d "Force replacement of resource using its address"
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o target -d "Resource to target"
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o var -d "Set a variable in the Terraform configuration"
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o exclude -d "Resource to ignore during plan"
complete -f -c tofu -n "__fish_seen_subcommand_from $plan" -o var -d "Set a variable in the OpenTofu configuration"
complete -r -c tofu -n "__fish_seen_subcommand_from $plan" -o var-file -d "Set variables from a file"
### providers
complete -f -c tofu -n __fish_terraform_needs_command -a providers -d "Print tree of modules with their provider requirements"
complete -f -c tofu -n __fish_tofu_needs_command -a providers -d "Print tree of modules with their provider requirements"
complete -f -c tofu -n "__fish_seen_subcommand_from providers" -a "lock mirror schema"
### refresh
complete -f -c tofu -n __fish_terraform_needs_command -a refresh -d "Update local state file against real resources"
complete -f -c tofu -n __fish_tofu_needs_command -a refresh -d "Update local state file against real resources"
complete -f -c tofu -n "__fish_seen_subcommand_from $apply" -o compact-warnings -d "Show only error summaries"
complete -r -c tofu -n "__fish_seen_subcommand_from refresh" -o backup -d "Path to backup the existing state file"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o input=true -d "Ask for input for variables if not directly set"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o lock=false -d "Don't hold a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o lock-timeout -d "Duration to retry a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o no-color -d "If specified, output won't contain any color"
complete -r -c tofu -n "__fish_seen_subcommand_from refresh" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from refresh" -o state -d "Path to a OpenTofu state file"
complete -r -c tofu -n "__fish_seen_subcommand_from refresh" -o state-out -d "Path to write state"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o target -d "Resource to target"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o var -d "Set a variable in the Terraform configuration"
complete -f -c tofu -n "__fish_seen_subcommand_from refresh" -o var -d "Set a variable in the OpenTofu configuration"
complete -r -c tofu -n "__fish_seen_subcommand_from refresh" -o var-file -d "Set variables from a file"
### show
complete -f -c tofu -n __fish_terraform_needs_command -a show -d "Inspect Terraform state or plan"
complete -f -c tofu -n __fish_tofu_needs_command -a show -d "Inspect OpenTofu state or plan"
complete -f -c tofu -n "__fish_seen_subcommand_from show" -o no-color -d "If specified, output won't contain any color"
complete -f -c tofu -n "__fish_seen_subcommand_from validate" -o json -d "Produce output in JSON format"
### state
complete -r -c tofu -n __fish_terraform_needs_command -a state -d "Advanced state management"
complete -r -c tofu -n __fish_tofu_needs_command -a state -d "Advanced state management"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a list -d "List resources in state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a ls -d "List resources in state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a mv -d "Move an item in the state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a move -d "Move an item in the state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a pull -d "Pull current state and output to stdout"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a push -d "Update remote state from local state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a replace-provider -d "Replace provider in the state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a rm -d "Remove instance from the state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a remove -d "Remove instance from the state"
complete -f -c tofu -n "__fish_seen_subcommand_from state" -a show -d "Show a resource in the state"
### taint
complete -f -c tofu -n __fish_terraform_needs_command -a taint -d "Manually mark a resource for recreation"
complete -f -c tofu -n __fish_tofu_needs_command -a taint -d "Manually mark a resource for recreation"
complete -f -c tofu -n "__fish_seen_subcommand_from taint" -o allow-missing -d "Succeed even if resource is missing"
complete -r -c tofu -n "__fish_seen_subcommand_from taint" -o backup -d "Path to backup the existing state file"
complete -f -c tofu -n "__fish_seen_subcommand_from taint" -o lock=false -d "Don't hold a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from taint" -o lock-timeout -d "Duration to retry a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from taint" -o ignore-remote-version -d "Ignore local and remote backend compatibility check"
complete -r -c tofu -n "__fish_seen_subcommand_from taint" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from taint" -o state -d "Path to a OpenTofu state file"
complete -r -c tofu -n "__fish_seen_subcommand_from taint" -o state-out -d "Path to write state"
### test
complete -f -c tofu -n __fish_terraform_needs_command -a test -d "Runs automated test of shared modules"
complete -f -c tofu -n __fish_tofu_needs_command -a test -d "Runs automated test of shared modules"
complete -f -c tofu -n "__fish_seen_subcommand_from test" -o compact-warnings -d "Show only error summaries"
complete -f -c tofu -n "__fish_seen_subcommand_from test" -o junit-xml -d "Also write test results to provided JUnit XML file"
complete -f -c tofu -n "__fish_seen_subcommand_from test" -o no-color -d "If specified, output won't contain any color"
### untaint
complete -f -c tofu -n __fish_terraform_needs_command -a untaint -d "Manually unmark a resource as tainted"
complete -f -c tofu -n __fish_tofu_needs_command -a untaint -d "Manually unmark a resource as tainted"
complete -f -c tofu -n "__fish_seen_subcommand_from untaint" -o allow-missing -d "Succeed even if resource is missing"
complete -r -c tofu -n "__fish_seen_subcommand_from untaint" -o backup -d "Path to backup the existing state file"
complete -f -c tofu -n "__fish_seen_subcommand_from untaint" -o lock=false -d "Don't hold a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from untaint" -o lock-timeout -d "Duration to retry a state lock"
complete -f -c tofu -n "__fish_seen_subcommand_from untaint" -o ignore-remote-version -d "Ignore local and remote backend compatibility check"
complete -r -c tofu -n "__fish_seen_subcommand_from untaint" -o state -d "Path to a Terraform state file"
complete -r -c tofu -n "__fish_seen_subcommand_from untaint" -o state -d "Path to a OpenTofu state file"
complete -r -c tofu -n "__fish_seen_subcommand_from untaint" -o state-out -d "Path to write state"
### validate
complete -f -c tofu -n __fish_terraform_needs_command -a validate -d "Validate the Terraform files"
complete -f -c tofu -n __fish_tofu_needs_command -a validate -d "Validate the OpenTofu files"
complete -f -c tofu -n "__fish_seen_subcommand_from validate" -o json -d "Produce output in JSON format"
complete -f -c tofu -n "__fish_seen_subcommand_from validate" -o no-color -d "If specified, output won't contain any color"
### version
complete -f -c tofu -n __fish_terraform_needs_command -a version -d "Print the Terraform version"
complete -f -c tofu -n __fish_tofu_needs_command -a version -d "Print the OpenTofu version"
### workspace
set -l workspace_commands list select new delete
complete -f -c tofu -n __fish_terraform_needs_command -a workspace -d "Workspace management"
complete -f -c tofu -n __fish_tofu_needs_command -a workspace -d "Workspace management"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && not __fish_seen_subcommand_from $workspace_commands" -a list -d "List workspaces"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && not __fish_seen_subcommand_from $workspace_commands" -a select -d "Select an workspace"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && not __fish_seen_subcommand_from $workspace_commands" -a new -d "Create a new workspace"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && not __fish_seen_subcommand_from $workspace_commands" -a delete -d "Delete an existing workspace"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && __fish_seen_subcommand_from select delete" -a "(__fish_terraform_workspaces)"
complete -f -c tofu -n "__fish_seen_subcommand_from workspace && __fish_seen_subcommand_from select delete" -a "(__fish_tofu_workspaces)"

View File

@@ -1,5 +1,5 @@
function __fish_winetricks__complete_verbs
winetricks list-all |
winetricks list-all 2>/dev/null |
string match --invert --regex '^==' |
string match --invert --regex '^(apps|dlls|fonts|games|settings)$' |
string replace --regex '(\S+)\s+(.+)' '$1\t$2'

View File

@@ -1,5 +1,9 @@
set -l commands status get-volume inspect set-default set-volume set-mute set-profile clear-default
if wpctl settings &>/dev/null
set --append commands settings
end
function __wpctl_get_nodes -a section -a type
set -l havesection
set -l havetype
@@ -38,6 +42,19 @@ function __wpctl_command_shape
end
end
function __wpctl_get_settings
set -l wpctl_settings (wpctl settings 2>/dev/null| string collect)
or return
string match --regex --all --quiet '\- Name: (?<wpctl_settings_name>.*)\n Desc: (?<wpctl_settings_desc>.*)' $wpctl_settings
for i in (seq (count $wpctl_settings_name))
set -l name $wpctl_settings_name[$i]
set -l desc (string shorten --max 60 $wpctl_settings_desc[$i])
echo $name\t$desc
end
end
complete -c wpctl -f
complete -c wpctl -s h -l help -d "Show help options"
@@ -48,6 +65,9 @@ complete -c wpctl -n "__fish_seen_subcommand_from inspect" -s a -l associated -d
complete -c wpctl -n "__fish_seen_subcommand_from set-volume" -s p -l pid -d "Selects all nodes associated to the given PID"
complete -c wpctl -n "__fish_seen_subcommand_from set-volume" -s l -l limit -d "Limit volume to below this value"
complete -c wpctl -n "__fish_seen_subcommand_from set-mute" -s p -l pid -d "Selects all nodes associated to the given PID"
complete -c wpctl -n "__fish_seen_subcommand_from settings" -s d -l delete -d "Deletes the saved setting value"
complete -c wpctl -n "__fish_seen_subcommand_from settings" -s s -l save -d "Saves the setting value"
complete -c wpctl -n "__fish_seen_subcommand_from settings" -s r -l reset -d "Resets the saved setting to its default value"
complete -c wpctl -n __wpctl_command_shape -a "$commands"
complete -c wpctl -n '__wpctl_command_shape "*"' -n "__fish_seen_subcommand_from get-volume inspect set-volume set-mute set-profile" -a "@DEFAULT_AUDIO_SOURCE@" -d "Default Microphone"
@@ -56,3 +76,4 @@ complete -c wpctl -n '__wpctl_command_shape "*"' -n "__fish_seen_subcommand_from
complete -c wpctl -n '__wpctl_command_shape "*"' -n "__fish_seen_subcommand_from get-volume inspect set-volume set-mute set-profile" -a "(__wpctl_get_nodes Audio Sources) (__wpctl_get_nodes Audio Sinks)"
complete -c wpctl -n '__wpctl_command_shape "*"' -n "__fish_seen_subcommand_from inspect set-profile" -a "(__wpctl_get_nodes Audio Sources) (__wpctl_get_nodes Audio Sinks) (__wpctl_get_nodes Video Source)"
complete -c wpctl -n '__wpctl_command_shape set-mute "*"' -a "0 1 toggle"
complete -c wpctl -n '__wpctl_command_shape settings' -a "(__wpctl_get_settings)"

View File

@@ -69,8 +69,8 @@ function __fish_complete_man
# Fish commands are not given by apropos
if not set -ql exclude_fish_commands
set -l files $__fish_data_dir/man/man1/*.1
string replace -r '.*/([^/]+)\.1$' '$1\t1: fish command' -- $files (status list-files man/man1/ 2>/dev/null)
set -l files $__fish_data_dir/man/man1/*.1*
string replace -r '.*/([^/]+)\.1(\.gz)?$' '$1\t1: fish command' -- $files (status list-files man/man1/ 2>/dev/null)
end
else
return 1

View File

@@ -30,13 +30,12 @@ if status is-interactive
# Commands to run in interactive sessions can go here
end" >$__fish_config_dir/config.fish
fish_config theme save "fish default" --yes --track
echo yes | fish_config theme save "fish default"
set -Ue fish_color_keyword fish_color_option
end
if test $__fish_initialized -lt 3800 && test "$fish_color_search_match[1]" = bryellow
set --universal fish_color_search_match[1] white
end
fish_config theme update
#
# Generate man page completions if not present.

View File

@@ -1,3 +0,0 @@
function __fish_in_gnu_screen
test -n "$STY" || contains -- $TERM screen screen-256color
end

View File

@@ -1,9 +0,0 @@
function __fish_in_terminal_multiplexer
set -l terminal_name "(status xtversion | string match -r '^\S*')"
string match -q -- tmux $terminal_name ||
__fish_in_gnu_screen ||
# Emacs does probably not support multiplexing between multiple parent
# terminals, but it is affected by the same issues. Same for Vim's
# :terminal TODO detect that before they implement XTGETTCAP.
contains -- $TERM dvtm-256color eterm eterm-color
end

View File

@@ -1,5 +1,5 @@
function __fish_print_commands --description "Print a list of documented fish commands"
if test -d $__fish_data_dir/man/man1/
if set -q __fish_data_dir[1] && test -d $__fish_data_dir/man/man1/
for file in $__fish_data_dir/man/man1/**.1*
string replace -r '.*/' '' -- $file |
string replace -r '.1(.gz)?$' '' |

View File

@@ -48,6 +48,9 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv shift-right forward-bigword
bind --preset $argv shift-left backward-bigword
bind --preset $argv alt-b prevd-or-backward-word
bind --preset $argv alt-f nextd-or-forward-word
set -l alt_right_aliases alt-right \e\[1\;9C # iTerm2 < 3.5.12
set -l alt_left_aliases alt-left \e\[1\;9D # iTerm2 < 3.5.12
if test (__fish_uname) = Darwin
@@ -77,11 +80,7 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv alt-l __fish_list_current_token
bind --preset $argv alt-o __fish_preview_current_file
bind --preset $argv alt-w __fish_whatis_current_token
bind --preset $argv ctrl-l (
if not __fish_in_gnu_screen && and __fish_xtgettcap indn
echo scrollback-push
end
) clear-screen
bind --preset $argv ctrl-l scrollback-push clear-screen
bind --preset $argv ctrl-c clear-commandline
bind --preset $argv ctrl-u backward-kill-line
bind --preset $argv ctrl-k kill-line

View File

@@ -1,4 +1,7 @@
function __fish_systemctl --description 'Call systemctl with some options from the current commandline'
# We don't want to complete with ANSI color codes
set -lu SYSTEMD_COLORS
# These options are all global - before or after subcommand/arguments.
# There's a bunch of long-only options in here, so we need to be creative with the mandatory short version.
set -l opts t/type= s-state= p/property= a/all

View File

@@ -1,4 +1,7 @@
function __fish_systemctl_services
# We don't want to complete with ANSI color codes
set -lu SYSTEMD_COLORS
if type -q systemctl
if __fish_contains_opt user
systemctl --user list-unit-files --full --no-legend --no-pager --plain --type=service 2>/dev/null $argv | string split -f 1 ' '

View File

@@ -1,6 +1,9 @@
# Like for running machines, I'm assuming machinectl doesn't allow spaces in image names
# This does not include the special image ".host" since it isn't valid for most operations
function __fish_systemd_machine_images
# We don't want to complete with ANSI color codes
set -lu SYSTEMD_COLORS
machinectl --no-legend --no-pager list-images | while read -l a b
echo $a
end

View File

@@ -1,5 +1,8 @@
# It seems machinectl will eliminate spaces from machine names so we don't need to handle that
function __fish_systemd_machines
# We don't want to complete with ANSI color codes
set -lu SYSTEMD_COLORS
machinectl --no-legend --no-pager list --all | while read -l a b
echo $a
end

View File

@@ -1,12 +0,0 @@
function __fish_xtgettcap --argument-names terminfo_code
if test $FISH_UNIT_TESTS_RUNNING = 1
return 1
end
set -l varname __fish_tcap_$terminfo_code
if not set -q $varname\[0\]
set --global $varname (
status xtgettcap $terminfo_code && echo true || echo false
)
end
test "$$varname" = true
end

View File

@@ -5,18 +5,13 @@ function export --description 'Set env variable. Alias for `set -gx` for bash co
end
for arg in $argv
set -l v (string split -m 1 "=" -- $arg)
set -l value
switch (count $v)
case 1
set -gx $v $$v
set value $$v[1]
case 2
if contains -- $v[1] PATH CDPATH MANPATH
set -l colonized_path (string replace -- "$$v[1]" (string join ":" -- $$v[1]) $v[2])
set -gx $v[1] (string split ":" -- $colonized_path)
else
# status is 1 from the contains check, and `set` does not change the status on success: reset it.
true
set -gx $v[1] $v[2]
end
set value $v[2]
end
set -gx $v[1] $value
end
end

View File

@@ -1,11 +1,5 @@
# Variables a theme is allowed to set
set -l theme_var_filter '^fish_(?:pager_)?color.*$'
function fish_config --description "Launch fish's web based configuration" \
--inherit-variable theme_var_filter
set -l _flag_track
argparse h/help track yes -- $argv
function fish_config --description "Launch fish's web based configuration"
argparse h/help -- $argv
or return
if set -q _flag_help
@@ -16,15 +10,6 @@ function fish_config --description "Launch fish's web based configuration" \
set -l cmd $argv[1]
set -e argv[1]
if set -q _flag_track[1] && not { test "$cmd" = theme && test "$argv[1]" = save }
echo >&2 fish_config: --track: unknown option
return 1
end
if set -q _flag_yes[1] && not { contains "$cmd" prompt theme && test "$argv[1]" = save }
echo >&2 fish_config: --yes: unknown option
return 1
end
set -q cmd[1]
or set cmd browse
@@ -80,6 +65,9 @@ function fish_config --description "Launch fish's web based configuration" \
return 1
end
# Variables a theme is allowed to set
set -l theme_var_filter '^fish_(?:pager_)?color.*$'
switch $cmd
case prompt
# prompt - for prompt switching
@@ -156,8 +144,8 @@ function fish_config --description "Launch fish's web based configuration" \
functions --erase fish_right_prompt
end
case save
if set -q _flag_yes[1] ||
{ read -P"Overwrite prompt? [y/N]" -l yesno; string match -riq 'y(es)?' -- $yesno }
read -P"Overwrite prompt? [y/N]" -l yesno
if string match -riq 'y(es)?' -- $yesno
echo Overwriting
# Skip the cp if unnecessary,
# or we'd throw an error on a stock fish.
@@ -286,10 +274,8 @@ function fish_config --description "Launch fish's web based configuration" \
set -l have_colors
if contains -- $cmd save
if not set -q _flag_yes &&
{ read -P"Overwrite your current theme? [y/N] " -l yesno
not string match -riq 'y(es)?' -- $yesno
}
read -P"Overwrite your current theme? [y/N] " -l yesno
if not string match -riq 'y(es)?' -- $yesno
echo Not overwriting >&2
return 1
end
@@ -306,7 +292,34 @@ function fish_config --description "Launch fish's web based configuration" \
# If we are choosing a theme or saving from a named theme, load the theme now.
# Otherwise, we'll persist the currently loaded/themed variables (in case of `theme save`).
if set -q argv[1]
__fish_config_theme_get $argv[1] | while read -lat toks
set -l files $dirs/$argv[1].theme
set -l file
for f in $files
if test -e "$f"
set file $f
break
end
end
if not set -q file[1]
if status list-files tools/web_config/themes/$argv[1].theme &>/dev/null
set file tools/web_config/themes/$argv[1].theme
else
echo "No such theme: $argv[1]" >&2
echo "Searched directories: $dirs" >&2
return 1
end
end
set -l content
if string match -qr '^tools/' -- $file
set content (status get-file $file)
else
read -z content < $file
end
printf %s\n $content | while read -lat toks
# The whitelist allows only color variables.
# Not the specific list, but something named *like* a color variable.
# This also takes care of empty lines and comment lines.
@@ -318,7 +331,7 @@ function fish_config --description "Launch fish's web based configuration" \
if test x"$scope" = x-U; and set -qg $toks[1]
set -eg $toks[1]
end
set $scope $toks $_flag_track=$argv[1]
set $scope $toks
set -a have_colors $toks[1]
end
@@ -330,7 +343,7 @@ function fish_config --description "Launch fish's web based configuration" \
# Erase conflicting global variables so we don't get a warning and
# so changes are observed immediately.
set -eg $c
set $scope $c $_flag_track=$argv[1]
set $scope $c
end
else
# We're persisting whatever current colors are loaded (maybe in the global scope)
@@ -352,8 +365,6 @@ function fish_config --description "Launch fish's web based configuration" \
# If we've made it this far, we've either found a theme file or persisted the current
# state (if any). In all cases we haven't failed, so return 0.
return 0
case update
__fish_config_theme_update $argv
case dump
# Write the current theme in .theme format, to stdout.
set -L | string match -r $theme_var_filter
@@ -363,100 +374,3 @@ function fish_config --description "Launch fish's web based configuration" \
end
end
end
function __fish_config_theme_get
set -l dirs $__fish_config_dir/themes $__fish_data_dir/tools/web_config/themes
set -l files $dirs/$argv[1].theme
set -l file
set -l is_default_theme false
for f in $files
if test -e "$f"
set file $f
if test $f = $__fish_data_dir/tools/web_config/themes/$argv[1].theme
set is_default_theme true
end
break
end
end
if not set -q file[1]
if status list-files tools/web_config/themes/$argv[1].theme &>/dev/null
set file tools/web_config/themes/$argv[1].theme
set is_default_theme true
else
echo "No such theme: $argv[1]" >&2
echo "Searched directories: $dirs" >&2
return 1
end
end
set -l content (
if string match -qr '^tools/' -- $file
status get-file $file
else
string join \n <$file
end
)
if $is_default_theme && not __fish_in_gnu_screen && not __fish_xtgettcap Su && not __fish_in_terminal_multiplexer
set content (string replace -- --underline=curly "" $content)
end
string join \n $content
end
function __fish_config_show_tracked_color_vars
set -l color_var $argv[1]
set -l _flag_track
argparse --ignore-unknown track= -- _set_color $argv[2..]
or return $status
if not set -q _flag_track[1]
return
end
if set -q _flag_track[2]
echo >&2 "fish_config: $color_var: --track option can only be specified once"
exit 1
end
if test (printf %s $_flag_track | count) -ne 0
echo >&2 "fish_config: $color_var: error: tracking theme name must not contain newlines"
exit 1
end
printf %s\n $color_var $_flag_track
end
function __fish_config_theme_update --inherit-variable theme_var_filter
if set -q argv[1]
echo "fish_config: too many arguments" >&2
return 1
end
set -l themes
set -l tracking_variables (
set --universal --long |
string match -r '^fish_(?:pager_)?color.*$' |
string replace -r '.*' '__fish_config_show_tracked_color_vars $0' |
source
)
or return $status
string join \n $tracking_variables |
while read --line _colorvar theme
if not contains -- $theme $themes
set -a themes $theme
end
end
for theme in $themes
set -l colorvars
string join \n $tracking_variables |
while read --line color_var t
if test $t = $theme
set -a colorvars $color_var
end
end
set -l theme_escaped (string escape -- $theme)
__fish_config_theme_get $theme |
string match -r -- "^(?:$(string join '|' $colorvars))\b .*" |
string replace -r '.*' "set -U \$0 --track=$theme_escaped" |
source
end
end

View File

@@ -61,8 +61,6 @@ function fish_default_key_bindings -d "emacs-like key binds"
bind --preset $argv alt-delete kill-token
bind --preset $argv ctrl-delete kill-word
end
bind --preset $argv alt-b prevd-or-backward-word
bind --preset $argv alt-f nextd-or-forward-word
bind --preset $argv alt-\< beginning-of-buffer
bind --preset $argv alt-\> end-of-buffer

View File

@@ -113,13 +113,10 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
bind -s --preset -M insert end end-of-line
bind -s --preset -M default end end-of-line
# Vi moves the cursor back if, after deleting, it is at EOL.
# To emulate that, move forward, then backward, which will be a NOP
# if there is something to move forward to.
bind -s --preset -M default x delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
bind -s --preset -M default x delete-char
bind -s --preset -M default X backward-delete-char
bind -s --preset -M insert delete delete-char forward-single-char backward-char
bind -s --preset -M default delete delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
bind -s --preset -M insert delete delete-char
bind -s --preset -M default delete delete-char
# Backspace deletes a char in insert mode, but not in normal/default mode.
bind -s --preset -M insert backspace backward-delete-char
@@ -238,7 +235,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# in vim p means paste *after* current character, so go forward a char before pasting
# also in vim, P means paste *at* current position (like at '|' with cursor = line),
# \ so there's no need to go back a char, just paste it without moving
bind -s --preset p 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_modefish_cursor_end_modeinclusive' yank
bind -s --preset p 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_mode inclusive' yank
bind -s --preset P yank
bind -s --preset g,p yank-pop
@@ -252,10 +249,10 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# Lowercase r, enters replace_one mode
#
bind -s --preset -m replace_one r repaint-mode
bind -s --preset -M replace_one -m default '' delete-char self-insert backward-char repaint-mode
bind -s --preset -M replace_one -m default enter 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default ctrl-j 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default ctrl-m 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default '' 'set -g fish_cursor_end_mode exclusive' delete-char self-insert backward-char repaint-mode 'set -g fish_cursor_end_mode inclusive'
bind -s --preset -M replace_one -m default enter 'set -g fish_cursor_end_mode exclusive' 'commandline -f delete-char; commandline -i \n; commandline -f backward-char' repaint-mode 'set -g fish_cursor_end_mode inclusive'
bind -s --preset -M replace_one -m default ctrl-j 'set -g fish_cursor_end_mode exclusive' 'commandline -f delete-char; commandline -i \n; commandline -f backward-char' repaint-mode 'set -g fish_cursor_end_mode inclusive'
bind -s --preset -M replace_one -m default ctrl-m 'set -g fish_cursor_end_mode exclusive' 'commandline -f delete-char; commandline -i \n; commandline -f backward-char' repaint-mode 'set -g fish_cursor_end_mode inclusive'
bind -s --preset -M replace_one -m default escape cancel repaint-mode
bind -s --preset -M replace_one -m default ctrl-\[ cancel repaint-mode

View File

@@ -95,6 +95,7 @@ function history --description "display or manipulate interactive command histor
set -l searchterm $argv
if not set -q argv[1]
read -P"Search term: " searchterm
or return $status
end
if test "$search_mode" = --exact
@@ -119,6 +120,7 @@ function history --description "display or manipulate interactive command histor
echo "Enter 'all' to delete all the matching entries."
echo
read --local --prompt "echo 'Delete which entries? '" choice
or return $status
echo ''
if test -z "$choice"
@@ -192,6 +194,7 @@ function history --description "display or manipulate interactive command histor
printf (_ "If you enter 'yes' your entire interactive command history will be erased\n")
read --local --prompt "echo 'Are you sure you want to clear history? (yes/no) '" choice
or return $status
if test "$choice" = yes
builtin history clear $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $argv
and printf (_ "Command history cleared!\n")
@@ -205,6 +208,7 @@ function history --description "display or manipulate interactive command histor
set -l newitem $argv
if not set -q argv[1]
read -P "Command: " newitem
or return $status
end
builtin history append $search_mode $show_time $max_count $_flag_case_sensitive $_flag_reverse $_flag_null -- $newitem

View File

@@ -10,7 +10,7 @@ fish_color_comment f7ca88
fish_color_cwd green
fish_color_cwd_root red
fish_color_end ba8baf
fish_color_error ab4642 --underline=curly
fish_color_error ab4642
fish_color_escape 86c1b9
fish_color_history_current --bold
fish_color_host normal

View File

@@ -10,7 +10,7 @@ fish_color_comment f7ca88
fish_color_cwd green
fish_color_cwd_root red
fish_color_end ba8baf
fish_color_error ab4642 --underline=curly
fish_color_error ab4642
fish_color_escape 86c1b9
fish_color_history_current --bold
fish_color_host normal

View File

@@ -10,7 +10,7 @@ fish_color_comment ffcc66
fish_color_cwd green
fish_color_cwd_root red
fish_color_end cc99cc
fish_color_error f2777a --underline=curly
fish_color_error f2777a
fish_color_escape 66cccc
fish_color_history_current --bold
fish_color_host normal

View File

@@ -9,7 +9,7 @@ fish_color_comment FF9640
fish_color_cwd green
fish_color_cwd_root red
fish_color_end FFB273
fish_color_error FF7400 --underline=curly
fish_color_error FF7400
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -21,7 +21,7 @@ fish_color_comment 6272a4
fish_color_cwd 50fa7b
fish_color_cwd_root red
fish_color_end ffb86c
fish_color_error ff5555 --underline=curly
fish_color_error ff5555
fish_color_escape ff79c6
fish_color_history_current --bold
fish_color_host bd93f9

View File

@@ -9,7 +9,7 @@ fish_color_comment FFE100
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 8D003B
fish_color_error EC3B86 --underline=curly
fish_color_error EC3B86
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -9,7 +9,7 @@ fish_color_comment B0B0B0
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 969696
fish_color_error FFA779 --underline=curly
fish_color_error FFA779
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -6,7 +6,7 @@ fish_color_command FF9400
fish_color_quote BF9C30
fish_color_redirection BF5B30
fish_color_end FF4C00
fish_color_error FFDD73 --underline=curly
fish_color_error FFDD73
fish_color_param FFC000
fish_color_comment A63100
fish_color_selection white --background=brblack --bold

View File

@@ -9,7 +9,7 @@ fish_color_comment 4e4e4e
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 767676
fish_color_error b2b2b2 --underline=curly
fish_color_error b2b2b2
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -6,7 +6,7 @@ fish_color_command ffffff
fish_color_quote a8a8a8
fish_color_redirection 808080
fish_color_end 949494
fish_color_error 585858 --underline=curly
fish_color_error 585858
fish_color_param d7d7d7
fish_color_comment bcbcbc
fish_color_selection white --background=brblack --bold

View File

@@ -9,7 +9,7 @@ fish_color_comment
fish_color_cwd normal
fish_color_cwd_root normal
fish_color_end
fish_color_error --underline=curly
fish_color_error
fish_color_escape
fish_color_history_current
fish_color_host normal

View File

@@ -11,7 +11,7 @@ fish_color_comment 4c566a --italics
fish_color_cwd 5e81ac
fish_color_cwd_root bf616a
fish_color_end 81a1c1
fish_color_error bf616a --underline=curly
fish_color_error bf616a
fish_color_escape ebcb8b
fish_color_history_current e5e9f0 --bold
fish_color_host a3be8c

View File

@@ -9,7 +9,7 @@ fish_color_comment 30BE30
fish_color_cwd green
fish_color_cwd_root red
fish_color_end FF7B7B
fish_color_error A40000 --underline=curly
fish_color_error A40000
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -9,7 +9,7 @@ fish_color_comment 5C9900
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 8EEB00
fish_color_error 60B9CE --underline=curly
fish_color_error 60B9CE
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -6,7 +6,7 @@ fish_color_command 164CC9
fish_color_quote 4C3499
fish_color_redirection 248E8E
fish_color_end 02BDBD
fish_color_error 9177E5 --underline=curly
fish_color_error 9177E5
fish_color_param 4319CC
fish_color_comment 007B7B
fish_color_selection white --background=brblack --bold

View File

@@ -10,7 +10,7 @@ fish_color_comment 586e75
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 268bd2
fish_color_error dc322f --underline=curly
fish_color_error dc322f
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -7,7 +7,7 @@ fish_color_command 586e75
fish_color_quote 839496
fish_color_redirection 6c71c4
fish_color_end 268bd2
fish_color_error dc322f --underline=curly
fish_color_error dc322f
fish_color_param 657b83
fish_color_comment 93a1a1
fish_color_selection white --background=brblack --bold

View File

@@ -10,7 +10,7 @@ fish_color_comment e7c547
fish_color_cwd green
fish_color_cwd_root red
fish_color_end c397d8
fish_color_error d54e53 --underline=curly
fish_color_error d54e53
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -7,7 +7,7 @@ fish_color_command b294bb
fish_color_quote b5bd68
fish_color_redirection 8abeb7
fish_color_end b294bb
fish_color_error cc6666 --underline=curly
fish_color_error cc6666
fish_color_param 81a2be
fish_color_comment f0c674
fish_color_selection white --background=brblack --bold

View File

@@ -10,7 +10,7 @@ fish_color_comment eab700
fish_color_cwd green
fish_color_cwd_root red
fish_color_end 8959a8
fish_color_error c82829 --underline=curly
fish_color_error c82829
fish_color_escape 00a6b2
fish_color_history_current --bold
fish_color_host normal

View File

@@ -7,7 +7,7 @@ fish_color_command 39BAE6
fish_color_quote C2D94C
fish_color_redirection FFEE99
fish_color_end F29668
fish_color_error FF3333 --underline=curly
fish_color_error FF3333
fish_color_param B3B1AD
fish_color_comment 626A73
fish_color_selection --background=E6B450 --bold

View File

@@ -10,7 +10,7 @@ fish_color_comment ABB0B6
fish_color_cwd 399EE6
fish_color_cwd_root red
fish_color_end ED9366
fish_color_error F51818 --underline=curly
fish_color_error F51818
fish_color_escape 4CBF99
fish_color_history_current --bold
fish_color_host normal

View File

@@ -10,7 +10,7 @@ fish_color_comment 5C6773
fish_color_cwd 73D0FF
fish_color_cwd_root red
fish_color_end F29E74
fish_color_error FF3333 --underline=curly
fish_color_error FF3333
fish_color_escape 95E6CB
fish_color_history_current --bold
fish_color_host normal

View File

@@ -9,7 +9,7 @@ fish_color_comment '888' '--italics'
fish_color_cwd 0A0
fish_color_cwd_root A00
fish_color_end 009900
fish_color_error F22 --underline=curly
fish_color_error F22
fish_color_escape 0AA
fish_color_history_current 0AA
fish_color_host normal

View File

@@ -11,7 +11,7 @@ fish_color_comment red
fish_color_cwd green
fish_color_cwd_root red
fish_color_end green
fish_color_error brred --underline=curly
fish_color_error brred
fish_color_escape brcyan
fish_color_history_current --bold
fish_color_host normal

View File

@@ -244,7 +244,7 @@ def parse_color(color_str):
underline = "single"
elif comp.startswith("--underline="):
underline = comp.stripprefix("--underline=")
elif comp.startswith("-u"): # Multiple short options like "-rbcurly" are not yet supported.
elif comp.startswith("-u"): # Multiple short options like "-rucurly" are not yet supported.
underline = comp.stripprefix("-u")
elif comp == "--italics" or comp == "-i":
italics = True

2641
src/ast.rs

File diff suppressed because it is too large Load Diff

View File

@@ -9,7 +9,9 @@
#[cfg(test)]
use crate::tests::prelude::*;
use crate::wchar::{wstr, WString, L};
use crate::wchar_ext::WExt;
use crate::wutil::{file_id_for_path, FileId, INVALID_FILE_ID};
use crate::FLOGF;
use lru::LruCache;
#[cfg(feature = "embed-data")]
use rust_embed::RustEmbed;
@@ -56,6 +58,12 @@ pub fn has_asset(_cmd: &str) -> bool {
false
}
#[derive(Clone, Copy, Eq, PartialEq)]
enum AssetDir {
Functions,
Completions,
}
pub enum AutoloadPath {
#[cfg(feature = "embed-data")]
Embedded(String),
@@ -63,7 +71,7 @@ pub enum AutoloadPath {
}
enum AutoloadResult {
Path(WString),
Path(AutoloadPath),
Loaded,
Pending,
None,
@@ -97,71 +105,33 @@ pub fn new(env_var_name: &'static wstr) -> Self {
/// mark_autoload_finished() with the same command. Note this does not actually execute any
/// code; it is the caller's responsibility to load the file.
pub fn resolve_command(&mut self, cmd: &wstr, env: &dyn Environment) -> Option<AutoloadPath> {
use crate::wchar_ext::WExt;
let mut possible_path = None;
if let Some(var) = env.get(self.env_var_name) {
match self.resolve_command_impl(cmd, var.as_list()) {
AutoloadResult::Path(path) => {
crate::FLOGF!(autoload, "Loading from path with var: %ls", path);
// HACK: Ignore generated_completions until we tried the embedded assets
if path
.find("/generated_completions/".chars().collect::<Vec<_>>())
.is_some()
{
possible_path = Some(path);
} else {
return Some(AutoloadPath::Path(path));
match self.resolve_command_impl(
cmd,
env.get(self.env_var_name)
.as_ref()
.map(|var| var.as_list())
.unwrap_or_default(),
) {
AutoloadResult::Path(path) => {
match &path {
#[cfg(feature = "embed-data")]
AutoloadPath::Embedded(_) => {
FLOGF!(autoload, "Embedded: %ls", cmd);
}
AutoloadPath::Path(path) => {
FLOGF!(
autoload,
"Loading %ls from var %ls from path %ls",
cmd,
self.env_var_name,
path
)
}
}
AutoloadResult::Loaded => return None,
AutoloadResult::Pending => return None,
AutoloadResult::None => (),
};
} else {
match self.resolve_command_impl(cmd, &[]) {
AutoloadResult::Path(path) => {
crate::FLOGF!(autoload, "Loading from path with var: %ls", path);
return Some(AutoloadPath::Path(path));
}
AutoloadResult::Loaded => return None,
AutoloadResult::Pending => return None,
AutoloadResult::None => (),
};
}
// HACK: In cargo tests, this used to never load functions
// It will hang for reasons unrelated to this.
if cfg!(test) {
return None;
}
#[cfg(feature = "embed-data")]
{
let narrow = wcs2string(cmd);
let cmdstr = std::str::from_utf8(&narrow).ok()?;
let p = if self.env_var_name == "fish_function_path" {
"functions/".to_owned() + cmdstr + ".fish"
} else if self.env_var_name == "fish_complete_path" {
"completions/".to_owned() + cmdstr + ".fish"
} else {
return None;
};
if has_asset(&p) {
if let Some(loaded_file) = self.autoloaded_files.get(cmd) {
if *loaded_file == INVALID_FILE_ID {
// The file has been autoloaded and is unchanged.
return None;
}
}
self.current_autoloading.insert(cmd.to_owned());
self.autoloaded_files
.insert(cmd.to_owned(), INVALID_FILE_ID);
crate::FLOGF!(autoload, "Embedded: %ls", cmd);
return Some(AutoloadPath::Embedded(p));
Some(path)
}
AutoloadResult::Loaded | AutoloadResult::Pending | AutoloadResult::None => None,
}
possible_path.map(AutoloadPath::Path)
}
/// Helper to actually perform an autoload.
@@ -182,7 +152,7 @@ pub fn perform_autoload(path: &AutoloadPath, parser: &Parser) {
AutoloadPath::Embedded(name) => {
use crate::common::str2wcstring;
use std::sync::Arc;
crate::FLOGF!(autoload, "Loading embedded: %ls", name);
FLOGF!(autoload, "Loading embedded: %ls", name);
let emfile = Asset::get(name).expect("Embedded file not found");
let src = str2wcstring(&emfile.data);
let mut widename = L!("embedded:").to_owned();
@@ -209,7 +179,9 @@ pub fn autoload_in_progress(&self, cmd: &wstr) -> bool {
/// Return whether a command could potentially be autoloaded.
/// This does not actually mark the command as being autoloaded.
pub fn can_autoload(&mut self, cmd: &wstr) -> bool {
self.cache.check(cmd, true /* allow stale */).is_some()
self.cache
.check(self.env_var_name, cmd, true /* allow stale */)
.is_some()
}
/// Return whether autoloading has been attempted for a command.
@@ -259,13 +231,19 @@ fn resolve_command_impl(&mut self, cmd: &wstr, paths: &[WString]) -> AutoloadRes
}
// Do we have an entry to load?
let Some(file) = self.cache.check(cmd, false) else {
let Some(file) = self.cache.check(self.env_var_name, cmd, false) else {
return AutoloadResult::None;
};
let file_id = match &file {
AutoloadableFileInfo::FileInfo(file) => &file.file_id,
#[cfg(feature = "embed-data")]
AutoloadableFileInfo::EmbeddedPath(_) => &INVALID_FILE_ID,
};
// Is this file the same as what we previously autoloaded?
if let Some(loaded_file) = self.autoloaded_files.get(cmd) {
if *loaded_file == file.file_id {
if *loaded_file == *file_id {
// The file has been autoloaded and is unchanged.
return AutoloadResult::Loaded;
}
@@ -273,8 +251,13 @@ fn resolve_command_impl(&mut self, cmd: &wstr, paths: &[WString]) -> AutoloadRes
// We're going to (tell our caller to) autoload this command.
self.current_autoloading.insert(cmd.to_owned());
self.autoloaded_files.insert(cmd.to_owned(), file.file_id);
AutoloadResult::Path(file.path)
self.autoloaded_files
.insert(cmd.to_owned(), file_id.clone());
AutoloadResult::Path(match file {
AutoloadableFileInfo::FileInfo(path) => AutoloadPath::Path(path.path),
#[cfg(feature = "embed-data")]
AutoloadableFileInfo::EmbeddedPath(path) => AutoloadPath::Embedded(path),
})
}
}
@@ -283,19 +266,28 @@ fn resolve_command_impl(&mut self, cmd: &wstr, paths: &[WString]) -> AutoloadRes
/// Represents a file that we might want to autoload.
#[derive(Clone)]
struct AutoloadableFile {
struct FileInfo {
/// The path to the file.
path: WString,
/// The metadata for the file.
file_id: FileId,
}
#[derive(Clone)]
enum AutoloadableFileInfo {
/// An on-disk file.
FileInfo(FileInfo),
/// An embedded file.
#[cfg(feature = "embed-data")]
EmbeddedPath(String),
}
// A timestamp is a monotonic point in time.
type Timestamp = time::Instant;
type MissesLruCache = LruCache<WString, Timestamp>;
struct KnownFile {
file: AutoloadableFile,
file: AutoloadableFileInfo,
last_checked: Timestamp,
}
@@ -343,10 +335,32 @@ fn dirs(&self) -> &[WString] {
/// Check if a command `cmd` can be loaded.
/// If `allow_stale` is true, allow stale entries; otherwise discard them.
/// This returns an autoloadable file, or none() if there is no such file.
fn check(&mut self, cmd: &wstr, allow_stale: bool) -> Option<AutoloadableFile> {
fn check(
&mut self,
env_var_name: &wstr,
cmd: &wstr,
allow_stale: bool,
) -> Option<AutoloadableFileInfo> {
let asset_dir = cfg!(feature = "embed-data").then_some(()).and_then(|()| {
if env_var_name == "fish_function_path" {
Some(AssetDir::Functions)
} else if cfg!(feature = "embed-data") && env_var_name == "fish_complete_path" {
Some(AssetDir::Completions)
} else {
None
}
});
// Check hits.
if let Some(value) = self.known_files.get(cmd) {
if allow_stale || Self::is_fresh(value.last_checked, Self::current_timestamp()) {
#[cfg(feature = "embed-data")]
let embedded = matches!(value.file, AutoloadableFileInfo::EmbeddedPath(_));
#[cfg(not(feature = "embed-data"))]
let embedded = false;
if allow_stale
|| embedded
|| Self::is_fresh(value.last_checked, Self::current_timestamp())
{
// Re-use this cached hit.
return Some(value.file.clone());
}
@@ -365,7 +379,10 @@ fn check(&mut self, cmd: &wstr, allow_stale: bool) -> Option<AutoloadableFile> {
}
// We couldn't satisfy this request from the cache. Hit the disk.
let file = self.locate_file(cmd);
let file = self
.locate_file(cmd, asset_dir, false)
.or_else(|| self.locate_asset(cmd, asset_dir?))
.or_else(|| self.locate_file(cmd, asset_dir, true));
if let Some(file) = file.as_ref() {
let old_value = self.known_files.insert(
cmd.to_owned(),
@@ -408,7 +425,12 @@ fn is_fresh(then: Timestamp, now: Timestamp) -> bool {
/// Attempt to find an autoloadable file by searching our path list for a given command.
/// Return the file, or none() if none.
fn locate_file(&self, cmd: &wstr) -> Option<AutoloadableFile> {
fn locate_file(
&self,
cmd: &wstr,
asset_dir: Option<AssetDir>,
want_generated_completions: bool,
) -> Option<AutoloadableFileInfo> {
// If the command is empty or starts with NULL (i.e. is empty as a path)
// we'd try to source the *directory*, which exists.
// So instead ignore these here.
@@ -421,6 +443,12 @@ fn locate_file(&self, cmd: &wstr) -> Option<AutoloadableFile> {
// Re-use the storage for path.
let mut path;
for dir in self.dirs() {
if asset_dir == Some(AssetDir::Completions) {
// HACK: Ignore generated_completions until we tried the embedded assets
if dir.ends_with(L!("/generated_completions")) != want_generated_completions {
continue;
}
}
// Construct the path as dir/cmd.fish
path = dir.to_owned();
path.push('/');
@@ -430,11 +458,31 @@ fn locate_file(&self, cmd: &wstr) -> Option<AutoloadableFile> {
let file_id = file_id_for_path(&path);
if file_id != INVALID_FILE_ID {
// Found it.
return Some(AutoloadableFile { path, file_id });
return Some(AutoloadableFileInfo::FileInfo(FileInfo { path, file_id }));
}
}
None
}
#[cfg(not(feature = "embed-data"))]
fn locate_asset(&self, _cmd: &wstr, _asset_dir: AssetDir) -> Option<AutoloadableFileInfo> {
None
}
#[cfg(feature = "embed-data")]
fn locate_asset(&self, cmd: &wstr, asset_dir: AssetDir) -> Option<AutoloadableFileInfo> {
// HACK: In cargo tests, this used to never load functions
// It will hang for reasons unrelated to this.
if cfg!(test) {
return None;
}
let narrow = wcs2string(cmd);
let cmdstr = std::str::from_utf8(&narrow).ok()?;
let p = match asset_dir {
AssetDir::Functions => "functions/".to_owned() + cmdstr + ".fish",
AssetDir::Completions => "completions/".to_owned() + cmdstr + ".fish",
};
has_asset(&p).then_some(AutoloadableFileInfo::EmbeddedPath(p))
}
}
#[test]

View File

@@ -22,7 +22,7 @@
#![allow(clippy::uninlined_format_args)]
use fish::{
ast::Ast,
ast,
builtins::{
fish_indent, fish_key_reader,
shared::{
@@ -226,7 +226,7 @@ fn run_command_list(parser: &Parser, cmds: &[OsString]) -> Result<(), libc::c_in
let cmd_wcs = str2wcstring(cmd.as_bytes());
let mut errors = ParseErrorList::new();
let ast = Ast::parse(&cmd_wcs, ParseTreeFlags::empty(), Some(&mut errors));
let ast = ast::parse(&cmd_wcs, ParseTreeFlags::empty(), Some(&mut errors));
let errored = ast.errored() || {
parse_util_detect_errors_in_ast(&ast, &cmd_wcs, Some(&mut errors)).is_err()
};

View File

@@ -1,5 +1,5 @@
use super::prelude::*;
use crate::ast::{Ast, Leaf};
use crate::ast::{self, Kind, Leaf};
use crate::common::{unescape_string, UnescapeFlags, UnescapeStringStyle};
use crate::complete::Completion;
use crate::expand::{expand_string, ExpandFlags, ExpandResultCode};
@@ -44,7 +44,7 @@ enum AppendMode {
Append,
}
enum TokenMode {
enum TokenOutputMode {
Expanded,
Raw,
Unescaped,
@@ -108,7 +108,7 @@ fn strip_dollar_prefixes(insert_mode: AppendMode, prefix: &wstr, insert: &wstr)
}
insert.find(L!("$ "))?; // Early return.
let source = prefix.to_owned() + insert;
let ast = Ast::parse(
let ast = ast::parse(
&source,
ParseTreeFlags::ACCEPT_INCOMPLETE_TOKENS | ParseTreeFlags::LEAVE_UNTERMINATED,
None,
@@ -116,7 +116,7 @@ fn strip_dollar_prefixes(insert_mode: AppendMode, prefix: &wstr, insert: &wstr)
let mut stripped = WString::new();
let mut have = prefix.len();
for node in ast.walk() {
let Some(ds) = node.as_decorated_statement() else {
let Kind::DecoratedStatement(ds) = node.kind() else {
continue;
};
let Some(range) = ds.command.range() else {
@@ -151,7 +151,7 @@ fn write_part(
range: Range<usize>,
range_is_single_token: bool,
cut_at_cursor: bool,
token_mode: Option<TokenMode>,
token_mode: Option<TokenOutputMode>,
buffer: &wstr,
cursor_pos: usize,
streams: &mut IoStreams,
@@ -171,7 +171,7 @@ fn write_part(
let mut args = vec![];
let mut add_token = |token_text: &wstr| {
match token_mode {
TokenMode::Expanded => {
TokenOutputMode::Expanded => {
const COMMANDLINE_TOKENS_MAX_EXPANSION: usize = 512;
match expand_string(
@@ -199,10 +199,10 @@ fn write_part(
ExpandResultCode::ok => (),
};
}
TokenMode::Raw => {
TokenOutputMode::Raw => {
args.push(Completion::from_completion(token_text.to_owned()));
}
TokenMode::Unescaped => {
TokenOutputMode::Unescaped => {
let unescaped = unescape_string(
token_text,
UnescapeStringStyle::Script(UnescapeFlags::INCOMPLETE),
@@ -218,10 +218,16 @@ fn write_part(
add_token(buff);
} else {
let mut tok = Tokenizer::new(buff, TOK_ACCEPT_UNFINISHED);
let mut in_redirection = false;
while let Some(token) = tok.next() {
if cut_at_cursor && token.end() >= pos {
break;
}
let is_redirection_target = in_redirection;
in_redirection = token.type_ == TokenType::redirect;
if is_redirection_target && token.type_ == TokenType::string {
continue;
}
if token.type_ != TokenType::string {
continue;
}
@@ -319,9 +325,9 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
return Err(STATUS_INVALID_ARGS);
}
token_mode = Some(match c {
'x' => TokenMode::Expanded,
'\x02' => TokenMode::Raw,
'o' => TokenMode::Unescaped,
'x' => TokenOutputMode::Expanded,
'\x02' => TokenOutputMode::Raw,
'o' => TokenOutputMode::Unescaped,
_ => unreachable!(),
})
}
@@ -447,7 +453,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
streams.err.append(wgettext_fmt!(
BUILTIN_ERR_COMBO2,
cmd,
"--cut-at-cursor and --tokens can not be used when setting the commandline"
"--cut-at-cursor and token options can not be used when setting the commandline"
));
builtin_print_error_trailer(parser, streams.err, cmd);
return Err(STATUS_INVALID_ARGS);

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