Commit Graph

20 Commits

Author SHA1 Message Date
Kid
a85edbfbcd Fix typo in __fish_print_pipestatus 2021-03-07 12:51:57 +01:00
Fabian Homborg
0a3fec5e8b __fish_print_pipestatus: Reset modifiers again
Called as

__fish_print_pipestatus "[foo" "oof]" "|" (set_color green) (set_color --bold blue) 0 1 2

it would make the closing `oof]` bold green.

Fixes #7771.
2021-03-03 19:20:28 +01:00
Johannes Altmanninger
58df0bc051 __fish_print_pipestatus: remove fallback colors for missing arguments
The arguments were not optional because we use
"set -e argv[1 2 3 4 5]"
2021-01-24 14:28:14 +01:00
Fabian Homborg
3eff7b26bf __fish_print_pipestatus: Add missing quotes
If this was called without an argument you'd not have a valid `test`
invocation.

Gosh I hate test.
2021-01-22 21:55:35 +01:00
Ilan Cosman
18940ea086
Remove dunderscores from __fish_status_to_signal (#7597)
* Remove dunderscores from __fish_status_to_signal

* Document fish_status_to_signal

* CHANGELOG: Add fish_status_to_signal

* Add string join to fish_status_to_signal documentation example
2021-01-03 15:15:57 +01:00
Fabian Homborg
2e55e34544 Reformat 2020-11-22 14:39:48 +01:00
Fabian Homborg
293a3a628d Remove pipestatus_with_signal
This was a wrapper around status_to_signal, just because that only
handled a single argument.

Instead, just teach status_to_signal to handle multiple arguments and
be done.
2020-09-24 20:14:10 +02:00
Fabian Homborg
dde8318e50 print_pipestatus: Simplify
Just some minor stylistic nits
2020-09-24 20:08:16 +02:00
Johannes Altmanninger
55bc6a27c6 Make prompts forward compatible with fish 3.1.2 by passing locally exported variable
Commit 5d135d555 (prompts: fix pipestatus for jobs prefixed with "not")
introduced a backwards compatibility hack about adding an optional argument
to __fish_print_pipestatus. This hack would break downgrading to fish 3.1.2
if the user copied the new prompt to their config - they would get a backtrace
on every prompt which is arguably worse than the patch's minor improvement.

This does away with the error trace - old fish just won't show the fancy
new pipestatus on `not true`.

Implemented by passing the last $status as the poor man's kwarg, which works
since 3.1.0 (9b86d5dd1 Export all local exported variables in a new scope).

The prompts don't work with fish 3.0.0 or older; downgrading does not seem
too important in general but I think this patch is an okay simplification.
2020-09-05 09:58:55 +02:00
Johannes Altmanninger
917f759a1a prompt: don't consider SIGPIPE a failure
Reproduce by running git log and press "q".
This regressed in master in 5d135d5.

[ci skip]
2020-03-07 14:13:58 +01:00
Johannes Altmanninger
5d135d5556 prompts: fix pipestatus for jobs prefixed with "not"
6902459566 was an attempt to not print
$status twice in the prompt. As a result we print $pipestatus but
not $status, which /usually/ is the same as $pipestatus[-1] --- unless
the builtin "not" is used, which inverts the $status of a job (it does
not alter $pipestatus).

As a result, the default prompt prints unexpected status codes:

	~ > not false
	~ [1]> not true
	~ > not true | true
	~ > not false | false
	~ [1|1]>

This commit reintroduces printing of $status after $pipestatus, but only
if it is different from $pipestatus[-1].
Additionally, we only print anything at all if the $status is nonzero,
to avoid confusing output on `not false | false`

	~ > not false
	~ > not true
	~ [0] 1> not true | true
	~ [0|0] 1> not false | false
	~ >

I think this is closer to users' expectations for those cases; they should
not have to think about this implementation detail of the not-statement.
2020-02-06 01:43:17 +01:00
Johannes Altmanninger
cc7ae03070 prompt: don't consider SIGPIPE a failure
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
6902459566 prompt: don't print status of last process in pipe twice
If a command fails, print the pipestatus in red instead of yellow and
don't print the status of the last process again. See #6375.

Also use $fish_color_status for coloring status consistently.

Also use __fish_pipestatus_with_signal to print SIGPIPE instead
of a numeric code on e.g.: yes | less +q

[ci skip]
2019-12-11 01:19:12 +01:00
Johannes Altmanninger
6b2addd9f3 prompt: don't print pipestatus if only the last process failed
Example: ps | grep something

[ci skip]
2019-12-10 22:35:24 +01:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
zabereer
a634356bcc remove redundant comment from __fish_print_pipestatus.fish 2019-03-05 18:25:16 +00:00
zabereer
d71e39f756 Revert "use global variables for $pipestatus in prompts to allow users to customize the look"
This reverts commit d5c18350a7.
2019-03-05 18:19:57 +00:00
zabereer
d5c18350a7 use global variables for $pipestatus in prompts to allow users to customize the look 2019-03-01 19:55:28 +00:00
zabereer
e157ba131b add $pipestatus to informative.fish prompt 2019-02-28 06:37:56 +00:00
zabereer
ead26881f0 create __fish_print_pipestatus function to reduce code duplication in other prompts when adding $pipestatus 2019-02-28 06:19:28 +00:00