Commit Graph

2108 Commits

Author SHA1 Message Date
Fabian Boehm
aac30367bf completions/systemctl: Add some missing commands
Fixes #9804
2023-05-21 10:02:26 +02:00
Mahmoud Al-Qudsi
4f5cef446a apt.fish: Fix compatibility with newer versions of Debian/Ubuntu
Why drop support for `awk -e`? Linux sees so much needless churn!
2023-05-03 21:27:46 -05:00
Fabian Boehm
d2165ca7e9 Use path basename 2023-04-26 19:38:10 +02:00
BrewingWeasel
d9c1fb5d51 fix E not moving cursor at end of word in VI mode 2023-04-01 10:04:28 -07:00
Fabian Boehm
43e8bb4532 fish_vi_cursor: Don't call __fish_cursor_konsole anymore
This hasn't been used for years.
2023-03-31 20:07:54 +02:00
Fabian Boehm
e45bddcbb1 __fish_cursor_xterm: Ignore unknown cursor settings
This prevents leaking the escape sequence by printing nonsense, and it
also allows disabling cursor setting by just setting the variable to
e.g. empty.

And if we ever added any shapes, it would allow them to be used on new
fish and ignored on old

Fixes #9698
2023-03-31 20:07:54 +02:00
Fabian Boehm
c39780fefb __fish_complete_directories: Remove --foo= from token
Otherwise this would complete

`git --exec-path=foo`, by running `complete -C"'' --exec-path=foo"`,

which would print "--exec-path=foo", and so it would end as

`git --exec-path=--exec-path=foo` because the "replaces token" bit was
lost.

I'm not sure how to solve it cleanly - maybe an additional option to
`complete`?

Anyway, for now this
Fixes #9538.
2023-03-27 22:57:34 +02:00
NextAlone
45b6622986
completion/ssh-copy-id: add completion (#9675)
Add completions for ssh-copy-id.

Refactored __ssh_history_completions into its own file for autoloading across completions.
2023-03-22 12:24:18 -05:00
Quinten Roets
f5506803d7
fish_vi_cursor: add new variable for external cursor mode (#9565)
* add new variable for external cursor mode

* fix backwards compatibility

* add documentation

* document change in changelog
2023-03-14 10:50:20 +01:00
lengyijun
aa65856ee0 Fixes #8924 via __fish_complete_suffix overhaul
Before:
* hand write arg parse
* only accepts one suffix

After:
* use `arg_parse` to parse args
* accepts multi suffixes

Closes #9611.
2023-03-12 22:07:44 -05:00
Agatha Lovelace
e32e6daced support prepending please instead of sudo/doas 2023-03-05 12:49:27 +01:00
Johannes Altmanninger
326e62515b functions/history.fish: also save when called with --exact
After deleting a history item with

    history delete --exact --case-sensitive the-item

it is still reachable by history search until the shell is restarted.

Let's fix this by saving history after each deletion.  The non-exact variants
of "history delete" already do this.  I think this was just an oversight
owed to the fact that hardly anyone uses "--exact" (else we would surely
have changed it to not require an explicit "--case-sensitive").
2023-03-04 22:24:22 +01:00
mhmdanas
0f39de2eee xbps: actually show all packages in __fish_print_xbps_packages's output.
`xbps-query` actually parses `-Rsl` as `-Rs l`, which means that packages
without the letter "l" in their names or descriptions are not included in
`__fish_print_xbps_packages`'s output.
2023-03-03 18:07:45 +01:00
Fabian Boehm
af49b4d0f8 Disable bracketed paste for read
It's not of much use (read will only read a single line anyway) and
breaks things

Fixes #8285
2023-03-02 16:56:32 +01:00
Fabian Boehm
5aaa1e69bc fish_git_prompt: Allow counting stash without full informative
Fixes #9572
2023-02-15 19:28:18 +01:00
rymrg
43b1be0579
Improve fossil prompt execution time (#9528)
* Improve prompt execution time

* Change status to changes

* Remove grep/awk/sort

* Remove calls to grep/awk/sort
* Don't overwrite user defined colors

* Make look more consistent with git
2023-02-15 18:52:05 +01:00
Fabian Boehm
4a8ebc0744 __fish_complete_path: Also use an empty command
This removes a weird `ls` call (that just decorates directories), and
makes it behave like normal path completion.

(really, this should be a proper option to complete)

Fixes #9285
2023-02-14 17:09:58 +01:00
Fabian Boehm
200095998a __fish_complete_directories: Use an empty command as the dummy
Fixes #9574
2023-02-14 17:09:58 +01:00
matt wartell
904839dcce fix 3 instances of old command substitution $() 2023-02-12 16:49:40 +01:00
Fabian Boehm
85504ca694 completions/zfs: Check for zpool
This is an additional tool, and this function is executed on source
time so we'd spew errors.

(also remove an ineffective line - it's probably *nicer* with the
read, but that's not what's currently effectively doing anything)
2023-02-10 20:55:37 +01:00
Fabian Boehm
7d7b72f995 Use path basename instead of basename
This is faster and guaranteed to be available
2023-02-10 20:51:22 +01:00
Fabian Boehm
8ff78eddf0 man: Reroute ".",":","[" to the proper names
Fixes #9552
2023-02-07 19:23:26 +01:00
Mahmoud Al-Qudsi
96deaae7d8 completions/apt: Read from the dpkg cache directly
I have no idea why `apt-cache --no-generate show` is so slow since it basically
dumps the contents of the cache file located at `/var/lib/dpkg/status`. We are
technically bypassing any waits on the cache lock file so this may produce
incorrect results if the cache is being regenerated in the moment, but that's a
small price to pay and the results are likely confined to simply not generating
comprehensive results.

With this change, we no longer need to truncate results to the first n matches
and we no longer only print packages beginning with the commandline argument
enabling fish's partial completions logic to offer less-perfect suggestions when
no better options are available.

Even though we are generating more usable completions, we still trounce the old
performance by leaps and bounds:

```
Benchmark #1: fish -c "complete -C\"apt install ac\""
  Time (mean ± σ):      2.165 s ±  0.033 s    [User: 267.0 ms, System: 1932.2 ms]
  Range (min … max):    2.136 s …  2.256 s    10 runs

Benchmark #2: build/fish -c "complete -C\"apt install ac\""
  Time (mean ± σ):     111.1 ms ±   1.8 ms    [User: 38.9 ms, System: 72.9 ms]
  Range (min … max):   108.2 ms … 114.9 ms    26 runs

Summary
  'build/fish -c "complete -C\"apt install ac\""' ran
   19.49 ± 0.44 times faster than 'fish -c "complete -C\"apt install ac\""'
```
2023-02-05 16:30:34 -06:00
nat-418
cf67709931
feat: add support for fossil-scm in prompt (#9500)
* feat: add support for fossil-scm in prompt

* fix: change directory testing and string matching
2023-01-29 16:54:39 +01:00
Fabian Boehm
177ce0d40e __fish_make_completion_signals: Check for "kill" 2023-01-29 14:44:59 +01:00
Johannes Altmanninger
29a3344226 Make bracketed paste add only one undo entry
Bracketed paste adds one undo entry unless the pasted text contains a '
or \.  This is because the "paste" bind-mode has bindings for those keys,
so they effectively start a new undo entry.

Let's fix this by adding an explicit undo group (our first use of this
feature!).
2023-01-24 20:32:13 +01:00
Fabian Boehm
01d681067c Bind ctrl-g to cancel as well
Classic emacs thing and the chord is so far unused.

Fixes #9484
2023-01-21 13:35:22 +01:00
Fabian Boehm
f9f29f0737 completions/portage: Fix errors with unreadable files
This could occur if a non-readable location was mentioned in one of
the portage config files.

Fixes #9495
2023-01-19 17:13:13 +01:00
Fabian Boehm
fd8291a96f __fish_print_help: Respect $MANPAGER
Fixes #9488
2023-01-18 17:05:39 +01:00
Fabian Boehm
afd242b14d fish_config: Skip backing up prompt
This would print an ugly but benign error
2023-01-08 12:44:02 +01:00
Fabian Boehm
d2f5daf8e8 bindings: If handler doesn't exist, set immediately
Fixes #9443
2023-01-02 21:44:02 +01:00
ridiculousfish
5e0f9521a5 fish_git_prompt: only do macOS workarounds for /usr/bin/git
On macOS, fish_git_prompt was failing to correctly handle the case where
another git was installed, e.g. /usr/local/bin/git from Homebrew.
Disable the workarounds in that case.
2023-01-02 12:26:56 -08:00
Jannik Vieten
2357c9f577
completions wireshark: removed wrong interface completion for -I option (#9440)
Wireshark completions for -I were wrong, since it doesn't take the network interface directly. It must still be specified with -i.
2023-01-02 17:45:25 +01:00
Aaron Gyes
550857ef65 Remove obsolete lynx bug mitigation
a lynx-internal hash of div.contents collided with em>a which caused
built-in styling to render much of entire pages as emphasized links.

Since switching from doxygen, we haven't had a <div class="contents">
so this workaround is no longer needed.
2023-01-01 19:41:41 -08:00
Johannes Altmanninger
a0840637fa fish_git_prompt: silence xcrun error when XCode is not installed
Our macOS workarounds involve running "xcrun" to check if Git is installed.
On a freshly upgraded Ventura system that does not have XCode or
CommandLineTools installed, "xcrun" will print this error:

    xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

on every prompt. Let's silence this error.
2023-01-01 14:37:40 +01:00
Fabian Boehm
c844b974b3 fish_git_prompt: Silence disown
The `git` can already have finished here, leading to "disown: There
are no suitable jobs". This has caused a failure on Github Actions.

So we do $last_pid and silence all output, like we do in other spots
2022-12-28 14:21:24 +01:00
ridiculousfish
6742d11a0e __fish_anypython: do not automatically run python3 on macOS
macOS ships with a stub `/usr/bin/python3` which by default opens a
dialog to install the command line tools. As we run `python3` initially
at launch, this causes the dialog to appear on first run of fish, if the
command line tools are not installed.

Fix this by detecting the case of `/usr/bin/python3` on Darwin without
the command line tools installed, and do not offer that as a viable
python.
2022-12-27 11:48:58 -08:00
ridiculousfish
a77bc70def fish_git_prompt: be careful about invoking git on macOS
git on macOS has two hazards:

1. It comes "preinstalled" as a stub which pops a dialog to install
   command line developer tools.

2. It may populate the xcrun cache when run for the first time, which
   may take several seconds.

We fix these as follows, both fixes limited to Darwin:

1. If git is `/usr/bin/git` and `xcode-select --print-path` fails,
   then do not run git automatically.

2. Second, if there is no file at `xcrun --show-cache-path`, we take it
   as an indication that the cache is not yet populated. In this case we
   run `git` in the background to populate the cache.

Credit to @floam for the idea.

Fixes #9343. Fixes #6625.
2022-12-27 11:48:58 -08:00
Johannes Altmanninger
9c0680070d Bind Shift+Return CSI u sequence to Return
I often hit Shift-Return accidentally, which makes my terminal echo a
weird escape sequence. Traditionally, terminals interpret Shift-Return
as Return, so let's follow that behavior.  Analoguous to commit 1dc526884
(Bind Shift+Space CSI u sequence to Space, 2022-04-24).
2022-12-17 11:12:40 +01:00
Fabian Boehm
478c8fb35e Remove "^" expand-abbr binding
This is no longer a special token, so it shouldn't expand abbreviations.
2022-12-16 17:06:03 +01:00
ridiculousfish
1402bae7f4 Re-implement abbreviations as a built-in
Prior to this change, abbreviations were stored as fish variables, often
universal. However we intend to add additional features to abbreviations
which would be very awkward to shoe-horn into variables.

Re-implement abbreviations using a builtin, managing them internally.

Existing abbreviations stored in universal variables are still imported,
for compatibility. However new abbreviations will need to be added to a
function. A follow-up commit will add it.

Now that abbr is a built-in, remove the abbr function; but leave the
abbr.fish file so that stale files from past installs do not override
the abbr builtin.
2022-12-10 15:29:03 -08:00
Sergei Shilovsky
022f42c3cd Update $fish_cursor_selection_mode in vi/default bindings
Introduced with 3.6.0 `fish_cursor_selection_mode` variable breaks
existing vi bindings (for example, input sequence `abc<Esc>0vd` doesn't
delete the `a` character as would be expected).

This patch fixes it by switching `fish_cursor_selection_mode` to
`inclusive` and back.
2022-11-01 19:04:55 +01:00
Aaron Gyes
3286c3cb6b funced: skip indent step if fish_indent not installed
Just in case.
2022-10-30 22:27:34 -07:00
Aaron Gyes
5447c130fc remove fish_key_reader finder/wrapper thing.
This was just added since "it works for fish_indent, might
as well". It's of limited utility, remove it.
2022-10-30 22:17:48 -07:00
Aaron Gyes
4906c680c6 remove fish_indent wrapper
When this was introduced, we used fish_indent --ansi to format
the output of `builtin functions` for color output in `type`, etc.

We don't anymore.

Today it's not a potential showstopper if one launches a fish
session with a five year-old fish_indent in $PATH. We need not
go to lengths to try to make sure we run whatever is in the
build dir adjacent to the `fish` binary.
2022-10-30 22:07:15 -07:00
Aaron Gyes
c887e5dbde Fix apropos completions
The 'str' variable was apparently mistakenly removed by 49c5f96470.

Re-add it, and regex-escape it as well.

Allow completing on apropos <TAB> instaed of requiring an initial char.

Use __fish_apropos instead of apropos.

New regex to hopefully work on more platforms.

Explicitly use ^ instead of adding it at __fish_apropos
2022-10-28 10:01:35 -07:00
Aaron Gyes
054d0ac0ea git completions: undo mistaken set -f usage
and fix issue in __fish_git_needs_command
2022-10-28 01:14:45 -07:00
Johannes Altmanninger
90b2c95bbc fish_clipboard_copy: bypass tmux, write OSC 52 to the underlying terminal
For security reasons, some terminals require explicit permission from the
user to interpret OSC 52. One of them is [tmux] but that one usually runs
inside another terminal. This means we can usually write directly to the
underlying terminal, bypassing tmux and the need for user configuration.

This only works if the underlying terminal is writable to the fish user,
which may not be the case if we switched user. For this reason, keep writing
to stdout as well, which should work fine if tmux is configured correctly.

[tmux]: https://github.com/tmux/tmux/wiki/Clipboard
2022-10-24 22:45:45 +02:00
Johannes Altmanninger
4de2891507 fish_clipboard_copy: make it work inside SSH/containers via OSC 52
When running inside SSH, Control-X runs a clipboard utility on the remote
system.  For pbcopy (and probably clip.exe too) this means that we write to the
remote system's clipboard. This is usually not what the user wants (although
it is consistent with  fish_clipboard_paste).  When X11 forwarding is used,
xclip/xsel copy to the SSH client's clipboard, which is what most users want.

When we don't have X11 forwarding, we need a different solution. Fortunately,
modern terminal emulators implement the OSC 52 escape sequence for setting
the clipboard of the terminal's system. Use it in fish_clipboard_copy.

Tested in SSH and Docker containers on foot, iTerm2, kitty, tmux and xterm
(this one requires "XTerm.vt100.allowWindowOps: true").

Should also work in GNU screen and Windows Terminal. On terminals that don't
support OSC 52 (like Gnome Terminal or Konsole), it seems to do nothing.

Since there does not seem to be a way to feature-probe OSC 52, let's just
always do both (pbcopy and friends as well as OSC 52).  In future, we should
probably stop calling pbpaste and clip.exe, at least on remote systems.

I think there is also an escape sequence to request pasting the system
clipboard but that's less important and less popular, possibly due to
security concerns.
2022-10-24 22:45:45 +02:00
Mahmoud Al-Qudsi
db0a297b8a Add new line between each trap -p output function
This makes the output a little easier on the eyes.
Tests appear to not need any changes to pass. I always forget whether or not
littlecheck cares about whitespace.
2022-10-24 15:36:02 -05:00