Commit Graph

20402 Commits

Author SHA1 Message Date
ndrew222
827bc32561 added completion for uv and uvx 2025-04-16 00:36:42 +08:00
Peter Ammon
85ea9eefc6 Fight off some clipplies 2025-04-14 21:08:26 -07:00
David Adam
692b53ab85 remove stray file 2025-04-13 09:14:46 +08:00
Johannes Altmanninger
92510c0488 man.fish: fix spurious error on embed-data builds
Commands like "man grep" print an error because __fish_data_dir[1] is no
longer defined. Fix that.
2025-04-12 20:25:08 +02:00
Fabian Boehm
765b700a04 cmake: Warn on unknown build type
CMake has this entire zoo of weird build types including "MinSizeRel".
I've also seen it set to empty, in distro packages no less.

Since we can't really make them all known to cargo, let's warn.

We could also error, but I'm not convinced there isn't some distro
packager out there setting it to "StrawberriesAndKittens" for some
reason,
and they'd be very cross with us if that stopped working.

See #11376
2025-04-12 14:21:56 +02:00
Johannes Altmanninger
b569f0d62f Update docs for transient prompt
Closes #11153
2025-04-12 12:09:08 +02:00
Johannes Altmanninger
6e85e5f6a0 Fix sphinx warning in changelog 2025-04-12 12:07:54 +02:00
Johannes Altmanninger
4b2c707721 Simplify exec_prompt_cmd 2025-04-12 12:07:54 +02:00
kerty
b3e417fd05 Add documentation for transient prompt 2025-04-12 12:07:26 +02:00
kerty
231ab22ce4 Update docs for transient prompt
See #11153
2025-04-12 12:07:26 +02:00
kerty
ca1d7ef863 Fix residual lines after repaint with shrinking prompt
If you use `set t 10; function fish_prompt; seq $t; set t $(math $t - 1); end` and trigger a repaint, you will see 9 residual lines from the previous prompt.
2025-04-12 10:51:35 +02:00
kerty
7ed4dfbd2d Ease condition for the execution of the right prompt
Now, the right prompt will not be executed only if it is undefined `fish_right_prompt`.
This allows the use of `read -p 'echo left' -R 'echo right'`.

Also changes condition for use of `DEFAULT_PROMPT` for consistency.
2025-04-12 10:46:33 +02:00
kerty
cb31f3e092 Refactor Reader::exec_prompt
Also fixes repaint-mode being run interactively
2025-04-12 10:46:33 +02:00
Johannes Altmanninger
b81a55e5f0 Fix bad conflict resolution 2025-04-12 10:34:38 +02:00
Johannes Altmanninger
6fcb418ae3 Enable 24-bit RGB colors by default
I think `set_color ff0000` should default to outputting true-color sequences.
Unfortunately there is no good and widely-supported way to query for true-color
support.  `COLORTERM=truecolor` doesn't work in some cases such as ssh.

Since many terminals nowadays implement the RGB sequences, let's try using
them by default.

Note that Emacs's ansi-term implements truecolor now.

See also the discussion around
https://github.com/fish-shell/fish-shell/pull/11345#issuecomment-2794920900

Closes #11372
2025-04-11 22:20:45 +02:00
Johannes Altmanninger
e7270915ac Update color support on COLORTERM change 2025-04-11 22:20:45 +02:00
Johannes Altmanninger
e45401e403 Fix copy paste error for smso/ritm/rmul sequences
We have basically zero system tests for text coloring/formatting.  I have
something in the works that will enable this without forcing tests to parse
the output of "tmux capture-pane -pe".

Fixes #11373
Fixes 17b4b39c8b (Stop reading terminfo database, 2025-03-20).
2025-04-11 22:20:45 +02:00
Johannes Altmanninger
fee48f8508 Remove stale output buffering code
This is handled above.
2025-04-11 22:20:45 +02:00
Daniel Rainer
9618a38215 Make control flow more explicit, log errors 2025-04-11 17:52:27 +02:00
Daniel Rainer
5c0fddae70 Refactor history flushing
Use function names which explicitly state their flushing behavior.
When writing history items to a new file, flushing is only done at the end.
When appending items to an existing file, flushing is done for each item, in
order to keep the `first_unwritten_new_item_index` counter consistent with the
file system.
2025-04-11 17:52:27 +02:00
Daniel Rainer
5c8d822ee1 Flush history with sync
- Replace the write_loop call with Writer::write_all.
- Call sync_all on the file to ensure it gets written to storage.
2025-04-11 17:52:27 +02:00
Fabian Boehm
170b3593a0 CHANGELOG 2025-04-11 17:39:56 +02:00
Fabian Boehm
b815fff292 Set $__fish_data_dir to empty for embed-data builds
These builds do not use it, and setting it makes it possible to use
stale files.

So instead, we set it to empty. All uses I could find are either fine
with that (`set fish_function_path $__fish_data_dir/functions` - which
would also just be empty, which means it reads the embedded
functions),

or would break even if the variable was set but the directory was
empty (`source $__fish_data_dir/completions/git.fish`).
2025-04-11 17:29:22 +02:00
Fabian Boehm
329cd7d429 Make functions, completions and tests resilient to running on an embed-data fish
In case a completion needs a function from another script, run
`complete -C"foo "` to load it, so the full autoloading logic is used.

Otherwise these things break if the path is off. E.g. cargo's version
will fail if you override the cargo completion in
~/.config/fish/completions without also overriding the rustup
completions.

In other cases, fix for empty $__fish_data_dir, which will be coming in the next commit
2025-04-11 17:29:22 +02:00
Fabian Boehm
53b2f5511b Rename the "installable" feature to "embed-data"
This reflects better what it is - fish doesn't need to "install"
itself anymore, it just includes the data in the binary.

This also means we could include a separate "embed-man" feature that
can be turned off if you want the man pages to be shipped separately.

Also explain that in the README.
2025-04-11 17:29:22 +02:00
Fabian Boehm
1a96db1708 functions/*: Extract data when needed
Technically the fish_update_completions files could also be piped to
python, but they'd have to be one file.

So for now, if you start a single-file fish, you'll have to run
fish_update_completions manually.

That fits the idea of having a single file that you move somewhere
better, given that it otherwise would run a script in the background
that creates a bunch of files
2025-04-11 17:29:22 +02:00
Fabian Boehm
ee2a6a851d Document and complete status get-file/list-files 2025-04-11 17:29:22 +02:00
Fabian Boehm
b56b876a98 Add status list-files
This allows us to implement fish_config using embedded files
2025-04-11 17:29:22 +02:00
Fabian Boehm
ca3a7f8356 Add status get-file
This allows getting embedded files, so we can use them in functions
2025-04-11 17:29:22 +02:00
Fabian Boehm
c8719fbff5 Rebuild if share/ or doc_src/ changed
Because these are embedded in the fish binary,
we need to rebuild fish once they're changed.

This is only for release builds,
because rust-embed only really embeds in those
(debug builds read from the filesystem).
2025-04-11 17:29:22 +02:00
Fabian Boehm
2a1c5b18e8 Remove --install option
This is no longer useful, given that we read files from in the binary.

In the upcoming commits, this can be done with status list-files/get-file if you need it
2025-04-11 17:29:22 +02:00
Fabian Boehm
2a3a23f53d Teach autoloader to read embedded files
This will load the functions and completions from inside of the fish
binary.

That means its no longer necessary to *install* a self-installable
build for basic functionality.

The functions/completions will be loaded *last*, so they are still
overridable via a file on disk (with the exception of
generated_completions, which we only use as a fallback if no
completions exist).

It still needs to extract files that are to be used by other tools,
including the man pages, fish_config.py, the man page completion
generator.

The remaining issues:

- It no longer prompts to install, but if you tried `fish_config`
  after this it would fail to open the tool,
  and it would be easy to forget to update those files
  So: When and how should this remind you that these files need to be extracted?
  Do we want e.g. a builtin that checks the version file (`status installed`)?
  This could then be run by `fish_config` and `help` and tell you to run `fish --install`.
- `builtin --help` will fail - we could read these things from inside,
  but we'd need groff for that.
  Do we want to pre-process these and put them in the builtins themselves?
  Do we want to print these on demand in `__fish_print_help` to groff?
- What directories need to still be defined? Does $__fish_data_dir need to keep existing?

Technically this *could* be the main distribution method. Maybe we
could let distro packages skip the embedded documentation and external
files,
but keep the functions/completions in the binary.
2025-04-11 17:29:22 +02:00
Fabian Boehm
66d7c00ba3 Let parser eval string directly
This gets the reader out of asting the source and is needed for
autoloader to get it to read a source string directly

Also add an "eval_file_wstr" method as a convenience to run a wstr as if it is a *file*, with a block and stuff
2025-04-11 17:29:22 +02:00
Fabian Boehm
64659e48f8 HACK: Create man1 dir even if not installable 2025-04-11 17:29:22 +02:00
Johannes Altmanninger
17b4b39c8b Stop reading terminfo database
Our use of the terminfo database in /usr/share/terminfo/$TERM is both
1. a way for users to configure app behavior in their terminal (by
   setting TERM, copying around and modifying terminfo files)
2. a way for terminal emulator developers to advertise support for
   backwards-incompatible features that are not otherwise easily observable.

To 1: this is not ideal (it's very easy to break things). There's not many
things that realistically need configuration; let's use shell variables
instead.

To 2: in practice, feature-probing via terminfo is often wrong.  There's not
many backwards-incompatible features that need this; for the ones that do
we can still use terminfo capabilities but query the terminal via XTGETTCAP
directly, skipping the file (which may not exist on the same system as
the terminal).

---

Get rid of terminfo. If anyone finds a $TERM where we need different behavior,
we can hardcode that into fish.

* Allow to override this with `fish_features=no-ignore-terminfo fish`
  Not sure if we should document this, since it's supposed to be removed soon,
  and if someone needs this (which we don't expect), we'd like to know.
  * This is supported on a best-effort basis; it doesn't match the previous
    behavior exactly.  For simplicity of implementation, it will not change
    the fact that we now:
    * use parm_left_cursor (CSI Ps D) instead of  cursor_left (CSI D) if
      terminfo claims the former is supported
    * no longer support eat_newline_glitch, which seems no longer present
      on today's ConEmu and ConHost
* Tested as described in https://github.com/fish-shell/fish-shell/pull/11345#discussion_r2030121580
* add `man fish-terminal-compatibility` to state our assumptions.
  This could help terminal emulator developers.
* assume `parm_up_cursor` is supported if the terminal supports XTGETTCAP
* Extract all control sequences to src/terminal_command.rs.
* Remove the "\x1b(B" prefix from EXIT_ATTRIBUTE_MODE. I doubt it's really
  needed.
* assume it's generally okay to output 256 colors
  Things have improved since commit 3669805627 (Improve compatibility with
  0-16 color terminals., 2016-07-21).
  Apparently almost every actively developed terminal supports it, including
  Terminal.app and GNU screen.
  * That is, we default `fish_term256` to true and keep it only as a way to
    opt out of the the full 256 palette (e.g. switching to the 16-color
    palette).
    * `TERM=xterm-16color` has the same opt-out effect.
* `TERM` is generally ignored but add back basic compatiblity by turning
  off color for "ansi-m", "linux-m" and "xterm-mono"; these are probably
  not set accidentally.
* Since `TERM` is (mostly) ignored, we don't need the magic "xterm" in
  tests. Unset it instead.
* Note that our pexpect tests used a dumb terminal because:
  1. it makes fish do a full redraw of the commandline everytime, making it
     easier to write assertions.
  2. it disables all control sequences for colors, etc, which we usually
     don't want to test explicitly.
  I don't think TERM=dumb has any other use, so it would be better
  to print escape sequences unconditionally, and strip them in
  the test driver (leaving this for later, since it's a bit more involved).

Closes #11344
Closes #11345
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
ad6d7137b8 Simplify selection between "CSI A" and "CSI Ps A"
I think multi is always shorter unless we're only moving by one cell.

Also, we want to simplify this for a following commit where we no longer
check if it's supported.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
f2e28fa6c4 Drop unnecessary use of is_dumb()
"infocmp dumb" shows that this is redundant.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
ef7bd4f13a Filter all control sequences but colors and cursor movement in tests
There are more escape sequences that can affect terminal state; let's allow
only the ones that are known-safe.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
f1aba8e3cd Remove unused terminfo capabilities 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
854e13048b Stop supporting terminals without eat_newline_glitch
This reverts commit 58347d494a (update PROMPT_SP heuristic, 2016-12-23)

If we write the last column of a line:

	printf %0"$COLUMNS"d 0; sleep 3

most terminals will *not* move the cursor to the next line.

This behavior is indicated by the terminfo's xenl (AKA xen or
eat_newline_glitch) boolean capability.

We originally added checks for this capability because ConEmu and Windows
ConHost did not implement it, but they do now.

Also, as mentioned in
https://github.com/fish-shell/fish-shell/pull/11342#issuecomment-2769979520,
we're not aware of any present-day terminal that does not have this behavior,
but the value advertised by terminfo is sometimes wrong.

Let's get rid of this for now. A following commit will document that we
require this behavior.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
0ca08ce81d Buffer OSC 0 terminal title writing 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
15379ae409 Ignore values XTGETTCAP values for indn/cuu
I don't think we want to support terminals that implement XTGETTCAP but for
some reason don't use CSI Ps S for scroll forward; that would be a needless
complication. 
Let's make ctrl-l / scrollback-push fail hard if a terminal does this.
Confusingly kitty and foot use different response formats, but happily we
no longer care.

An upcoming commit will document that we require the CSI Ps S style.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
7d5fb623c6 Remove unused variable 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
c0ad15fbc5 Fix missing repaint when TERM changes
E.g.

	set TERM xterm-16color
	set TERM xterm-mono
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
926566bad5 Remove unused parameter 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
aa825c40da Fix RST syntax 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
423a5a20ba Remove dead code checking for uninitialized terminal
See 75f7cda6ab (Add xterm-256color fallback, 2024-01-28).
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
594daf8f64 Use internal RST link for linking to #building 2025-04-11 15:11:22 +02:00
Johannes Altmanninger
d3b4a33ba4 Remove intrusive Screen::scoped_buffer
scoped_buffer borrows the screen to be able to flush buffers on drop.  This is
a bit intrusive (see also 29ae571afa (Make scoped_push nicer, 2024-12-28)).

Not sure what's the best solution -- probably we should always pass the
outputter as parameter, removing the field.

For now let's at least contain the effects of this.
2025-04-11 15:11:22 +02:00
Johannes Altmanninger
ce01b16402 Fix typo 2025-04-11 15:11:22 +02:00