Commit Graph

1842 Commits

Author SHA1 Message Date
Fabian Homborg
18e332772d functions: Add "--no-details" flag and use it in funced
This inhibits the function path comment which is annoying in `funced`.

Fixes #7879.
2021-03-30 16:54:26 +02:00
lapingenieur
a68791fa89 [vi-mode] corrected normal/default mode pasting
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.
2021-03-28 13:28:40 -07:00
Fabian Homborg
1705bd1440 __fish_man_page: Try man before
This is really just `less` being precious and `man` being unspecified.

Fixes #7863.
2021-03-27 09:15:31 +01:00
Fabian Homborg
fb7c8c4064 __fish_prepend_sudo: First insert history and then *toggle*
Previously this would only ever insert sudo if it took a commandline
from history, not remove it.

So you would end up with

    sudo sudo apt install
2021-03-26 19:32:14 +01:00
Ilan Cosman
bcbfd70d41
Create empty directories and files on interactive startup (#7796)
Closes #7402
2021-03-23 21:01:00 +01:00
Jannik Vieten
0f3274d5eb
Fix completion errors for tshark when running as root (#7858) 2021-03-23 20:40:44 +01:00
Fabian Homborg
95dc821a44 Disable pacman command-not-found handler
Apparently it's too slow on some systems

Fixes #7841.
2021-03-21 10:03:53 +01:00
exploide
5eadee61c5 improved SSH completions
- use __fish_complete_ssh also for sftp
- removed old options -1 and -2
- added several newer options
- cleaned up and sorted completion code
2021-03-20 21:17:53 +01:00
Johannes Altmanninger
f9e131aa93 Show an error when "builtin -h" fails to find a man page
Prior to this commit "builtin -h" would silently fail when no
documentation is installed. This happens when running fish without
installing it, or when the docs are not installed.

See #7824
2021-03-15 23:07:08 +01:00
lapingenieur
f95f12f5e7 changed 'rm' to 'command rm'
if rm is aliased to 'rm -i' then rm will ask to delete the cache file after funced edited the file which is anoying
2021-03-15 21:07:39 +01:00
Ilya Grigoriev
1a03c23b58 Improve error when help fails to find a browser
Previously, this message told the user to "set $BROWSER and try again". However,
when I first saw this error, I didn't know how I can set `BROWSER` in fish. Moreover,
I often see this error in situations when no browser will work. For instance, I might be
using fish over ssh, and I might either not know whether that system has a text-mode
browser installed or not want to use it.

A further improvement would be to report this message if a browser fails to start.
2021-03-11 18:32:24 +01:00
Fabian Homborg
dfebfcf376 __fish_apropos: Also add "--" separator
This actually *worked* in my tests which confuses me.

It really shouldn't, `apropos -foo` will complain about "-o" not being
a valid option.

It should be `apropos -- -foo`.

Now, of course there are awful apropos implementations, so let's see
if someone complains
2021-03-10 07:22:17 +01:00
Fabian Homborg
d2fc1c47ac __fish_describe_command: Add missing --
Fixes #7809.
2021-03-10 07:17:23 +01:00
exploide
274be5eeeb added descriptions to __fish_print_addresses
added --all flag to include 0.0.0.0 and ::
adapted use of this function in existing completions
fixes #7787
2021-03-08 17:47:29 +01:00
Kid
a85edbfbcd Fix typo in __fish_print_pipestatus 2021-03-07 12:51:57 +01:00
Ilya Grigoriev
f725cd402d Make help and fish_config work on Chrome OS
When `fish` is running in the Chrome OS Linux VM (Crostini),
both `help` and `fish_config` opened a "file not found"
page. That is because on Crostini, `BROWSER` is usually set to
`garcon-url-handler`, which opens URLs in the host OS Chrome
browser. That browser lacks access to the Linux file system.

This commit fixes these commands. `help` now opens the URL on
www.fishshell.com.  `fish_config` now opens the URL for the
server it starts. Previously, it opened a local file that
redirects to the same URL.

In the case of `help`, the situation could be improved further
by starting a web server to serve help. I don't know of another
way to access `/share/fish` from outside the VM without user
intervention, and I think that might be a part of the security
model for the Crostini VM.

It's hard to write a test for this. I checked that `help math`,
`python2 webconfig.py`, and `python3 webconfig.py` work on my
machine running in Crostini.
2021-03-07 09:42:41 +01:00
Fabian Homborg
10ef0d9daf Fix clipboard_paste nicer
Instead of hacking in arbitrary characters to avoid splitting, just
use `string collect`.

This reverts commit e450190d50.

Fixes #7782, but nicer.
2021-03-06 08:40:07 +01:00
Mahmoud Al-Qudsi
e450190d50 Fix regression causing error and prompt corruption on paste
Closes #7782

[ci skip]
2021-03-05 17:13:28 -06:00
Fabian Homborg
69c71052ef Remove __fish_repaint
This was a handler for various prompt variables that called a repaint.

Unfortunately, if you set one of those *inside* the prompt (a logical
place for it), this would lead to something like #7775.

So, because this isn't actually *useful* as far as I can see (how do
you set these variables in a way that you're not already inside a
prompt or about to draw a prompt? in a key binding?), we remove it,
like we removed the repaint from git's variable handlers.
2021-03-04 19:20:31 +01:00
Fabian Homborg
b1c5e003ef fish_command_not_found: Actually define default handler
Fixes #7777
2021-03-04 18:30:12 +01:00
Fabian Homborg
d85bdf120f fish_add_path: Handle moving multiple arguments correctly
This `set -e` had a cartesian product that caused it to remove the
indexes separately, so the later indexes were off - removing the first
and then the second ends up removing the first and then the
old-*third* which is now the second.

Just quote the expansion so it runs in one go.

Fixes #7776
2021-03-04 16:10:27 +01:00
Fabian Homborg
76457bdc4e fish_git_prompt: Remove repaint from variable handlers
Because we removed repaint coalescing, currently setting any of the
git prompt variables in fish_prompt leads to a repaint loop (that
presumably aborts once it reaches the recursion limit).

Since repainting on these variables isn't really useful (when you
`set` them interactively you already get a new prompt), just remove
it.

There's two cases this "breaks":

- When you set a variable *after* the call to fish_git_prompt
- When you set a variable via a binding

In both of these it's not too much to expect an explicit "commandline
-f repaint", especially since for bindings that's already needed in
most cases, and setting a variable after using it isn't normal.

Fixes #7775.
2021-03-04 15:58:20 +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
David Adam
39230978b3 docs: call the CHANGELOG "release notes" 2021-02-25 22:46:24 +08:00
Fabian Homborg
b8d28158a6 Do disown the completion updating without $last_pid
In this context, as it stands, $last_pid will give fish's pid (because
of pgroup shenanigans).

Since that doesn't really work, just `disown` without and let fish
figure out what the last process was.

Theoretically this has an issue if someone started a background
process *before* the python script *and* that exits before we run
disown.

That's a vanishingly small window and this is only run on first start,
so it seems acceptable.

Fixes #7739.
2021-02-24 20:30:01 +01:00
Jason
1f546ac1d0 abbr: improve error handling when --erase called with no args 2021-02-20 11:33:48 -08:00
Johannes Altmanninger
e16a1d7065 Add deprecated compatibility wrapper for __fish_commandline_is_singlequoted
It could be really annoying if Ctrl-V stopped working when switching between
fish versions, for example when using different machines.
2021-02-13 08:55:59 +01:00
Johannes Altmanninger
4c1173f2ae fish_clipboard_paste: trim indentation when pasting multiple lines
When pasting a multiline command with indented blocks, extra indentation
from spaces, or tabs, is generally undesirable, because fish already indents
pipes and blocks. Discard the indentation unless the cursor or the pasted
part is inside quotes.

Users who copied fish_clipboard_paste need to update it because
__fish_commandline_is_singlequoted had an API change and was renamed.
2021-02-13 08:55:59 +01:00
Johannes Altmanninger
330883b6fd Run fish_indent on share/**.fish
This is mostly to show that some of my following indent changes don't break
current behavior.
2021-02-08 07:31:33 +01:00
Fabian Homborg
2a9edfe26e help: Better handle builtins when docs aren't installed
__fish_print_commands just prints the commands we have man pages for,
and help uses that to figure out whether it should link
a command or a section. If the docs aren't installed it won't find
anything.

At least check the builtins, because we document them and it's easy.

This probably needs to be added at build time - glob
doc_src/cmds/*.rst.
2021-02-05 17:19:07 +01:00
Fabian Homborg
cf4f8ae929 Revert "Color "ip" output if available"
This reverts commit abb59a6ec9.

This is still buffered if piped to another function, like with the default `grep`.

See #5340, #5356.
2021-02-02 18:44:44 +01:00
Johannes Altmanninger
abb59a6ec9 Color "ip" output if available
This is supported since iproute2 v4.19.0

Closes #5340
2021-02-02 06:39:40 +01:00
Fabian Homborg
dd48fdc970 Remove hostname function
This was only a thing in cygwin, and only a workaround because
cygwin's hostname was broken in 2013 and our sample prompts called it,
which caused errors in fish_config.

Our sample prompts no longer call `hostname` at all (they use
`prompt_hostname`, which uses the variable), and it's possible
cygwin's hostname was fixed in the meantime.

Fixes #7669.
2021-01-31 08:36:00 +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
Wez Furlong
4b0152575e Enable OSC 7 when running in WezTerm
Over in https://github.com/wez/wezterm/issues/115#issuecomment-765869705 one of my users noted that fish had automatic OSC 7, but that it wasn't enabled under WezTerm.

You can detect WezTerm through the `$TERM_PROGRAM` environment.  In practical terms, all versions of wezterm in the wild support OSC 7 so a version check is not needed.

I'm not a fish user myself, but I did give the equivalent change to this a try on my Fedora 33 machine (it has an older version of fish).

I can see in this file that there's some stuff with `__fish_enable_focus` that you may also want to enable under wezterm; the escape sequence is supported as are panes, tabs and windows.
2021-01-23 18:10:32 +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
Fabian Homborg
bc6414aaa8
!fixup fish_git_prompt: Fix variable name
This missed one use of $user_variable
2021-01-18 12:37:30 +01:00
Fabian Homborg
dbfd3b5c39 fish_git_prompt: Remove a few unneeded variables 2021-01-17 21:04:16 +01:00
Johannes Altmanninger
f176503c0f Remove the explicit undo group in fish_clipboard_paste
It doesn't change the behavior, see
7669e8e497 (r45675920)
2021-01-15 20:23:59 +01:00
Fabian Homborg
e192066e98 Add $fish_handle_reflow to disable winch handler
Overriding event handlers is annoying.
2021-01-15 18:37:06 +01:00
Fabian Homborg
48082daad4 Turn off reflowing for Konsole >= 21.04 as well
See https://bugs.kde.org/show_bug.cgi?id=196998, https://invent.kde.org/utilities/konsole/-/merge_requests/321

Part of #7491.
2021-01-15 18:37:06 +01:00
Fabian Homborg
168677f8b3 Use disown with $last_pid
As mentioned in 5b706faa73, bare
`disown` has a problem: It disowns the last *existing* job.

Unfortunately, it's easy to see cases where that won't happen:

    sleep 5m &
    /bin/true & # will exit immediately
    disown # will most likely disown *sleep*, not true

So what we do is to pass $last_pid.

In help especially this is likely to occur because many graphical
browsers fork immediately to avoid blocking the terminal (we only
added the backgrounding and disown because some weren't).

Note that it's *possible* this doesn't occur if used in the same
function, but I don't want to rely on those semantics.

It might be worth doing this as the default - see #7210.
2021-01-09 13:44:48 +01:00
Mahmoud Al-Qudsi
aaaf74cd5b fixup! Add concept of edit groups
Correctly call begin/end-undo-group in fish_clipboard_paste
2021-01-06 16:45:24 -06:00
Mahmoud Al-Qudsi
7669e8e497 Add concept of edit groups
This allows for multiple edits to be undone/redone in one go, as if they
were one edit.

Useful when a function is editing the commandline buffer via scripted
changes or via a keybinding so the internal changes to the buffer can be
abstracted away.

(Having extreme difficulty getting pexpect to play nice with the concept
of undo/redo...)
2021-01-05 15:43:34 -06: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
8a585bb711 Also disable winch handling in alacritty
It also reflows.

We might want to think about doing something more extensible here, as
konsole is also about to add reflow, but for now the main problem
children here are VTE and alacritty.

Extends #7491.
2021-01-01 20:22:57 +01:00
Johannes Altmanninger
d6dd532d6a Do support the new realpath -s in our wrapper function
See #7574
2020-12-26 08:56:34 +01:00
Johannes Altmanninger
4dae106911 Use complete --keep-order with __fish_complete_suffix to prioritize files with matching suffixes
Part of #7040
2020-12-23 19:14:10 +01:00
Johannes Altmanninger
bae75c96d9 __fish_complete_suffix: complete all files, but sort files with matching suffix first
See #7040 and others.
2020-12-23 19:14:10 +01:00
Fabian Homborg
04d7d89020 __fish_print_packages: Extract the rest
Of note: The rpm/yum thing seems to be coupled, so I put it into one
function that tries the yum helper and uses the rpm path otherwise.
Zypper is already its own thing, so this should only be used for yum
and probably dnf (does that still have the helper?)

Zypper can be dropped, as that already used a separate function in the file.

Apk can just be inlined - it's literally one line for installed and another for all packages.
2020-12-22 17:10:02 +01:00
Fabian Homborg
97838657b9 Extract creating $XDG_CACHE_HOME into its own function 2020-12-22 17:10:02 +01:00
Fabian Homborg
24012b1941 __fish_print_packages: Break apart
This function doesn't make any sense.

Most things that expect package names expect package names for *one
specific package manager*.

It only happens to work, most of the time, because most people only
have one package manager installed.
2020-12-22 17:10:02 +01:00
ridiculousfish
90f4c458e5 Rename insert_line_above to insert_line_over
This is for symmetry with insert_line_under. See #7442.
2020-12-19 14:31:33 -08:00
ridiculousfish
2d2efc8b2e Implement o and O bindings for vi mode
Credit to @joallard for the patch. Fixes #7442
2020-12-19 14:28:00 -08:00
Johannes Altmanninger
f1478137dc __fish_complete_path: guard against non-matching input 2020-12-12 08:22:45 +01:00
Fabian Homborg
0fdef958b6 __fish_complete_blockdevice: Default to /dev
This gives all the blockdevices for `mount `

Fixes #7543.
2020-12-11 23:09:16 +01:00
Fabian Homborg
2aaa51e02e Repaint also for fish_color_{host_remote,error}
These are used in our prompts as well.
2020-12-11 20:55:09 +01:00
Vadim Zyamalov
0200fc0fbc
Creating cache for xbps-query in __fish_print_packages.fish (#7534)
* Completions for xbps were not showed on cache file creation

* Completions for xbps were not showed on cache file creation, small typo
2020-12-08 20:59:56 +01:00
Fabian Homborg
672fdde1f0 __fish_print_packages: Better parse apt-cache's weird format
Fixes #7521.
2020-12-04 16:45:14 +01:00
Fabian Homborg
eb592092a6 fixup! Only disable WINCH handling in VTE
Apparently iTerm doesn't reflow?

See #7491
2020-11-30 20:50:02 +01:00
Fabian Homborg
df137695bb Disable WINCH handler in reflowing terminals
Fixes #7491.
2020-11-30 20:01:33 +01:00
Enrico Maria De Angelis
2a86099cfd
fish_vi_key_bindings: Implement "d;" and "d," (#7516) 2020-11-29 21:24:42 +01:00
Mahmoud Al-Qudsi
a3cb1e2dcd Fix setting terminal title after fg
The code to override the `(status current-command) was present`, but not
handled in either the default `fish_title` function or the fallback.

Closes #7444.
2020-11-28 00:56:10 -06:00
Fabian Homborg
2e55e34544 Reformat 2020-11-22 14:39:48 +01:00
Mahmoud Al-Qudsi
01f239188d [zfs] Limit snapshots to spelled-out dataset
Use the `-d` parameter to `zfs list` to limit snapshots to the dataset
named in the current token being completed. Thanks to @Debilski for the
tip.

Closes #7472
2020-11-20 15:28:19 -06:00
Érico Rolim
31870e774a share/functions: account for the possibility of mktemp failure. 2020-11-14 15:57:42 +01:00
Mahmoud Al-Qudsi
6bd4f52b0d [zfs] Optimize enumeration of snapshots
Only generate the list of snapshots when
a) the argument must be a snapshot and nothing else, or
b) the argument as typed contains a literal @, or
c) a snapshot is a valid completion and there is only one dataset
   matching the argument as entered.

Unfortunately, it seems the `zfs` command itself is extremely primitive
and doesn't support listing snapshots by dataset so when we need to
generate completions, we end up needing to enumerate all snapshots
(ever) across all datasets. I'd be very happy to be proven wrong, but I
think the only other way would be manually parse `zdb` output.

See #7472
2020-11-12 22:24:29 -06:00
Shawn LeMaster
e4b64448fa Don't assume $__fish_git_prompt_char_cleanstate is non-empty
This fixes the case where an empty "clean state" character
can cause a spurious space character at the end of the git prompt.
2020-11-10 18:55:15 +01:00
Ayooluwa Isaiah
ea1dffd53d Add support for copy and paste in WSL
- clip.exe is used to copy to the Windows clipboard
- There's no binary for pasting from the Windows clipboard so
  `Get-Clipboard` from powershell is used as a workaround. The
  superflous carriage return is stripped from the output.
2020-11-06 22:10:04 +01:00
Jan-Jaap Korpershoek
4b74fbf1b7
Make mysql completions work with log-in (#7397)
Complete databases using credentials specified on the commandline.
2020-10-30 18:34:23 +01:00
Fabian Homborg
4bfda47449 Bind ctrl-r to search history if the commandline isn't empty
This is super cheesy.

One of the most common feature requests we get is "control-r must
search", even tho just using history-search-backward via e.g. up-arrow
is perfectly capable. The only real difference is that ctrl-r search
in other shells allows editing the search term by default, while we
stop the history search and edit the new commandline in those cases.

So, since the major problem is muscle-memory on ctrl-r,
let's just use that!

This makes ctrl-r do nothing on empty commandlines, and do
history-search-backward otherwise, so the basic flow of "press ctrl-r
to start history search, enter your search term, press ctrl-r to cycle
through matches" just works (except the first ctrl-r is useless and it
doesn't show anything).

See #602.
2020-10-23 13:42:54 +02:00
Mahmoud Al-Qudsi
7990bd3046 [npm/yarn] Add support for namespaced packages
The regex previously in use did not allow for namespaced packages and
wouldn't match against things like @types/foo.
2020-10-21 22:26:52 -05:00
Johannes Altmanninger
f20e8e5860 alias: don't add --wraps for wrappers with the same name
These aliases seem to be common, see #7389 and others.  This prevents
recursion on that example, so `alias ssh "env TERM=screen ssh"` will just
have the same completions as ssh.

Checking the last token is a heuristic which hopefully works for most
cases. Users are encouraged to use functions instead of aliases.
2020-10-10 09:24:49 +02:00
Johannes Altmanninger
03e0ec82af alias: use original body instead of escaping back and forth 2020-10-10 09:24:49 +02:00
Johannes Altmanninger
1173e8bda4 Clarify that some complete calls just need a command with no user-defined completion 2020-10-10 09:24:49 +02:00
Fabian Homborg
fb57ca8791 __fish_apropos: Use macOS' stat explicitly
Overrides the GNU tools some people use.

Fixes #7390.
2020-10-09 18:58:35 +02:00
Fabian Homborg
468c6ff0f8 abbr: Erase all abbrs in one go
Simplifies returns, also allows erroring out without erasing anything
if an abbr name was bogus
2020-10-04 12:34:51 +02:00
Fabian Homborg
420fa68c54 abbr: Fix check for spaces in the name
This used a non-existent variable
2020-10-04 12:34:51 +02:00
Fabian Homborg
135c5a9746 abbr: Don't write an error if erasing nonexisting abbrs
Fixes #7376.
2020-10-04 12:34:38 +02:00
Fabian Homborg
2ab4c10c47 abbr: Allow erasing multiple
Fixes #7377.
2020-10-04 12:27:59 +02:00
ridiculousfish
a6686ca310 Run makewhatis in the background
In the new __fish_apropos, makewhatis is run explicitly to generate the
whatis database. However this can be a little slow. Run it in the
background, after the apropos call completes so as to avoid a weird
race.

This means that descriptions may not be available the first time the
user invokes it, but that's better than appearing to hang for a while.
2020-10-03 17:09:00 -07:00
Folke Lemaitre
a6a0d43c9c Better __fish_describe_command for Macos
override MANPATH used by apropos with local whatis database and update it once a day

get rid of xargs

Created __fish_apropos and fixed __fish_complete_man to use that as well

moved macos apropos comment
2020-10-03 16:18:44 -07:00
Johannes Altmanninger
a1fd9e1b85 Fix invalid flags for builtin type
This combination of flags doesn't work anymore, which makes sense.
2020-09-30 21:46:43 +02:00
Johannes Altmanninger
e9582c41b2 Remove __fish_complete_external_command
It's no longer used.
2020-09-25 19:33:01 +02: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
Fabian Homborg
ef9c924960 Make type a builtin
This is too important to not be one.

For one if it couldn't be loaded for any reason it would
break a lot of fish scripts.

Also this is faster by ~20x.

Fixes #7342
2020-09-21 20:58:34 +02:00
Fabian Homborg
a3e20a4d38 Don't use abbreviated long options
"function --argument" is not a thing, it's "--argument-names". This only
accidentally works because our getopt is awful and allows abbreviated
long options.

Similarly, one argparse test used "--d" instead of "-d" or "--def".
2020-09-19 11:47:41 +02:00
Johannes Altmanninger
6ec0b583f5 __fish_paginate: move the cursor to end of recalled commandline
When pressing \ep on an empty commandline, the cursor would stay at the
beginning of the commandline. Move it to the end of the previous command,
this feels a bit more natural.
2020-09-17 18:44:54 +02:00
Fabian Homborg
e86a31f6d4 Use the newly fixed test -t in isatty
Removes a weird dependency on the test command.
2020-09-16 21:02:59 +02:00
Fabian Homborg
1c43030d79 cd: Remove unneeded code
This now works in cd proper, so it's unneeded in the function.
2020-09-12 20:17:30 +02:00
Fabian Homborg
0072367512 fish_add_path: Don't resolve symlinks
The case for symlinked directories being duplicated a lot isn't there,
but there *is* a usecase for adding the symlink rather than the
target, and that's homebrew.

E.g. homebrew installs ruby into /usr/local/Cellar/ruby/2.7.1_2/bin,
and links to it from /usr/local/opt/ruby/bin. If we add the target, we
would miss updates.

Having path entries that point to the same location isn't a big
problem - it's a path lookup, so it takes a teensy bit longer. The
canonicalization is mainly so paths don't end up duplicated via weird
spelling and so relative paths can be used.
2020-09-12 19:28:01 +02:00
Fabian Homborg
691deac1e4 Print default error in the pacman cnf-handler
Pacman *only* prints the package if it exists, no error or anything.

Fixes #7327.
2020-09-11 20:58:02 +02:00
Fabian Homborg
34be1b458a Add fish_command_not_found handler for pacman
Since version 5 (IIRC), pacman has a file database.

This is useful for people who don't have pkgfile, but we still prefer
that because it's much faster - pacman takes a full *second* on my system.
2020-09-09 17:44:25 +02:00
Fabian Homborg
576ce5f9f5 Remove __fish_command_not_found_handler
This could lead to an infinite loop (well, stack overflow) because
fish_command_not_found would also be defined to call
__fish_command_not_found_handler.

Since this is for

- missing command errors
- when downgrading

we can just remove it.
2020-09-06 13:50:38 +02:00
Fabian Homborg
0131974378 Use OpenSUSE command-not-found via $PATH
We check the full $PATH, so it's not guaranteed that it is in /usr/bin.
2020-09-06 11:15:54 +02:00
Fabian Homborg
340de73172 Call "fish_command_not_found" if a command wasn't found
Previously, when a command wasn't found, fish would emit the
"fish_command_not_found" *event*.

This was annoying as it was hard to override (the code ended up
checking for a function called `__fish_command_not_found_handler`
anyway!), the setup was ugly,
and it's useless - there is no use case for multiple command-not-found handlers.

Instead, let's just call a function `fish_command_not_found` if it
exists, or print the default message otherwise.

The event is completely removed, but because a missing event is not an error
(MEISNAE in C++-speak) this isn't an issue.

Note that, for backwards-compatibility, we still keep the default
handler function around even tho the new one is hard-coded in C++.

Also, if we detect a previous handler, the new handler just calls it.

This way, the backwards-compatible way to install a custom handler is:

```fish
function __fish_command_not_found_handler --on-event fish_command_not_found
    # do a little dance, make a little love, get down tonight
end
```

and the new hotness is

```fish
function fish_command_not_found
    # do the thing
end
```

Fixes #7293.
2020-09-06 11:15:54 +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
89724f9366 prompts: guard against missing fish_is_root_user
Prevents error spew when running one of these prompt on fish 3.1.2.
2020-09-05 09:48:47 +02:00
Charles Gould
6fd68d553d Stop initializing fish_color_match, it is no longer used 2020-09-04 19:46:38 +02:00