Commit Graph

2155 Commits

Author SHA1 Message Date
bitraid
86afc7832d Call fish_vi_cursor_handle also for interactive read
Not doing this results in the cursor not being initially set for `read`.
2024-01-27 20:13:47 +01:00
bitraid
a5dfa84f73 fish_vi_cursor: skip if stdin is not a tty
Instead of skipping for non-interactive shells, skip when stdin is not a tty.
This allows the cursor to be set for scripts that use the `read` command.
2024-01-27 20:13:47 +01:00
Johannes Altmanninger
33a9659cd1 Fix stale name of --tokens-expand option
Missed in 368017905 (builtin commandline: -x for expanded tokens, supplanting
-o, 2024-01-06).
2024-01-27 20:09:33 +01:00
Fabian Boehm
677e4ff698 anypython: Add more versions 2024-01-27 18:47:38 +01:00
Johannes Altmanninger
5f459446a8 functions/funced: harmonize interpretation of VISUAL/EDITOR
Like other tools, we split $EDITOR by spaces and remove backslashes in Alt+e
and Alt+o but not in funced. Let's' fix this inconsistency.
2024-01-27 09:38:51 +01:00
Johannes Altmanninger
29f35d6cdf completion: adopt commandline -x replacing deprecated -o
This gives us more accurate completions because completion scripts get
expanded paths
2024-01-27 09:28:06 +01:00
Johannes Altmanninger
798527d79a completions: fix double evaluation of tokenized commandline
Fix cases like

    eval my-cmd (commandline -o)
    complete -C "my-cmd $(commandline -o)"

In both cases, we spuriously evaluate tokens like "(inside-quoted-string)"
as command substitutions. Fix this by escaping the strings.  The momentarily
regresses the intended purpose of "eval" -- to expand variables -- but the
next commit will fix that.
2024-01-27 09:28:06 +01:00
Fabian Boehm
423829a634 Rename existing cache files
We're already moving them, we can remove the awkward dot that hides
them, and while we're doing that remove the useless $USER as well.

Most systems will have only one of these files - it's rare to run a
second package manager (especially for anything more than
bootstrapping a container).
2024-01-21 14:18:50 +01:00
Fabian Boehm
e5b2c3e4be Add helper to cache | source completions
We have a lot of completions that look like

```fish
pip completion --fish 2>/dev/null | source
```

That's *fine*, upstream gives us some support.

However, the scripts they provide change very rarely, usually not even
every release, and so running them again for every shell is extremely
wasteful.

In particular the python tools are very slow, `pip completion --fish`
takes about 180ms on my system with a hot cache, which is quite
noticeable.

So what we do is we run them once, store them in a file in our cache
directory, and then serve from that.

We store the mtime of the command we ran, and compare against that for
future runs. If the mtime differs - so if the command was up or
downgraded, we run it again.
2024-01-21 14:18:50 +01:00
Fabian Boehm
7e087d8eda __fish_make_cache_dir: Create fish subdir and optionally deeper
This will move all current cache uses to e.g. ~/.cache/fish/

That's better anyway because it makes it easier to remove.

Also it allows supplying a subdir so you can do `__fish_make_cache_dir
completions`
to get ~/.cache/fish/completions.
2024-01-21 14:18:50 +01:00
Johannes Altmanninger
5dfcfa336b edit_command_buffer: if aliasee is a recognized editor, pass cursor position too
If I alias "e" to "emacsclient" it will probably accept the same options.
Let's dereference the alias so we can detect support for passing the cursor
position in more cases.

This does not solve the problem for recursive cases (e.g. alias of another
alias). If we want to handle that we would need cycle detection.
2024-01-21 09:39:59 +01:00
ahaoboy
8009469f8f Add support for the Windows MSYS environment. 2024-01-12 17:55:49 +01:00
Johannes Altmanninger
57d7c46d22 completions: fix some completions to not look at other commands on the command line 2024-01-07 19:04:54 +01:00
Nethum Lamahewage
a36ff7d143 history: fix deleting last entry 2024-01-04 16:10:08 +01:00
Fabian Boehm
b895cf49ca umask: Correctly handle empty symbolic value
Simple return/echo confusion.

Fixes #10177
2023-12-31 19:39:23 +01:00
Fabian Boehm
4c1e25b141 fish_git_prompt: Add separator even if state is empty
This would leave off the separator if the repo was just bare or had
upstream difference, but no status (e.g. dirty) applied.

Fixes #10175
2023-12-30 19:38:22 +01:00
Fabian Boehm
b1a1a3b0a7 prompt_pwd: Fix missing --
Fixes #10169
2023-12-25 18:46:23 +01:00
Johannes Altmanninger
b83f3b0e98 __fish_anypager: prefer less over other pagers
This is our traditional behavior; "man" and "git" do the same.
2023-12-17 17:12:13 +01:00
Fabian Boehm
dbdef5d267 vi-bindings: Make "/" open pager and go to insert mode
Fixes #10141
2023-12-10 10:37:05 +01:00
Johannes Altmanninger
3842d03473 Reformat fish files 2023-12-06 09:33:05 +01:00
Fabian Boehm
ed489d0d52 Add __fish_anypager helper
This makes it easier to get *any pager* in the number of places we do.

Unfortunately:

1. It can't just execute the pager because that might block
2. We can't really set the necessary options for less here
   so they still need to be set outside.

This

Fixes #10074

by falling back to `cat` in that case. We could also decide to abort
instead of using a non-pager, but for history that's probably fine.
2023-11-20 17:16:35 +01:00
Nicholas Rodrigues Lordello
93b3a0c1f5 Additional checks for -F support 2023-11-07 17:45:45 +01:00
Nicholas Rodrigues Lordello
5cf36bf3f8 ls No Longer Sets LS_COLORS 2023-11-07 17:45:45 +01:00
Fabian Boehm
e494e15574 funcsave: Always use local $funcdir
This abused default scope
2023-10-19 22:36:58 +02:00
Fabian Boehm
c4ca1a68d3
Add a clear-screen bind function to clear the screen (#10044)
This can be bound like `bind \cl clear-screen`, and is, by default

In contrast to the current way it doesn't need the external `clear`
command that was always awkward.

Also it will clear the screen and first draw the old prompt to remove
flicker.
Then it will immediately trigger a repaint, so the prompt will be overwritten.
2023-10-08 11:41:30 +02:00
Mathijs Henquet
a809672412
Fix out of scope opt variable (#10020)
* Fix out of scope opt variable

* Update ls.fish
2023-10-07 18:00:17 +02:00
Fabian Boehm
098b7093da fish_config: Fix save with variable with multiple values
Your basic quoting problem, regressed in 3.6.0
2023-10-06 22:15:35 +02:00
Fabian Boehm
f8e38819a5 open: Don't run xdg-open in the background
This was introduced as a workaround to #7215 - xdg-open's generic path
wouldn't background graphical apps.

This has been fixed a month ago in xdg-open, so we can stop doing it.

The good news is this also allows terminal apps to be used again, so
it

Fixes #10045
2023-10-04 15:57:32 +02:00
Fabian Boehm
9fa70d3ace Remove two calls to builtin realpath
path was added in 3.4, it's old enough that we can use it now.
2023-09-29 16:47:00 +02:00
Fabian Boehm
2cf22596e7 Disable reflow handling for WezTerm too
Seems to work fine
2023-09-22 17:13:28 +02:00
Fabian Boehm
b03327f5d2 __fish_complete_command: Fix --foo= logic
This was already supposed to handle `--foo=bar<TAB>` cases, except it
printed the `--foo=` again, causing fish to take that as part of the
token.

See #9538 for a similar thing with __fish_complete_directories.

Fixes #10011
2023-09-10 18:16:41 +02:00
Fabian Boehm
dcebffb9e7 funced: Note --wait
See #9999
2023-09-05 09:19:21 +02:00
Fabian Boehm
81cd035950 print_apt_packages: Go back to apt-cache for non-installed packages
Unfortunately, /var/lib/dpkg/status on recent-ish Debian versions at
least only contains the *installed* packages, rendering this solution
broken.

What we do instead is:

1. Remove a useless newline from each package, so our limit would now
let more full package data sets through
2. Increase the limit by 5x

This yields a completion that runs in ~800ms instead of ~700ms on a
raspberry pi, but gives ~10x the candidates, compared to the old
apt-cache version.

This partially reverts 96deaae7d8
2023-08-22 22:17:22 +02:00
Axlefublr
fd68aca6ea
fix __fish_list_current_token not recognizing ~ as $HOME (#9954)
* fix __fish_list_current_token not recognizing ~ as $HOME

* right. it was supposed to be $HOME. lol.
2023-08-16 22:05:59 +02:00
Gregory Anders
69ef51f417 Enable PWD reporting for iTerm2 2023-08-14 18:09:12 +02:00
Gabriel Górski
21ddfabb8d
Simplify and fix __fish_is_zfs_feature_enabled (#9939)
* Simplify and fix `__fish_is_zfs_feature_enabled`

Previously `__fish_is_zfs_feature_enabled` was doing
`<whitespace>$queried_feature<whitespace>` pattern matching which
was skipping the state part expected in the follow-up checking code.

Passing the dataset/snapshot in a `target` argument is pointless. As
none of the existing code attempts to do this plus it is also a
private function (`__` prefix), rename of the argument and removal
of extra text replacement should not be considered a breaking change.

* Changed the `&& \` into `|| return`

* Run `fish_indent`
2023-08-09 17:28:01 +02:00
Fabian Boehm
ed881bcdd8 Make default theme use named colors only
This gives us the biggest chance that these are *visible* in the
terminal, which allows people to choose something nicer.

It changes two colors - the autosuggestion and the pager
description (i.e. the completion descriptions in the pager).

In a bunch of terminals I've tested these are pretty similar - for the
most part brblack for the suggestions is a bit brighter than 555, and
yellow for the descriptions is less blue
than the original.

We could also make the descriptions brblack, but that's for later.

Technically we are a bit naughty in having a few foreground and
background pairs that might not be visible,
but there's nothing we can do if someone makes white invisible on brblack.

Fixes #9913
Fixes #3443
2023-07-25 16:42:24 +02:00
Fabian Boehm
2b0e3ba3b8 __fish_print_hostnames: Fix regex
This used `]` when it should have been `}`, which made the regex nonsensical

Broken since 94c12d84e2 in 2016
2023-07-11 20:50:56 +02:00
Fabian Boehm
1a11cee559 functions/cd: Optimize check for too many args
This ran two `test`s a `count` and one `echo`, which is a bit wasteful.

So instead, for the common case where you pass one argument, this will
run one `set -q`.

This can save off ~160 microseconds for each ordinary `cd`, which
speeds it up by a factor of ~2 (so 1000 runs of cd might take 260ms
instead of 550ms).

Ideally the cd function would just be incorporated into the builtin,
but that's a bigger change.
2023-07-11 18:01:29 +02:00
Johannes Altmanninger
052823c120 history pager: delete selected history entry with Shift-Delete
After accidentally running a command that includes a pasted password, I want
to delete command from history. Today we need to recall or type (part of)
that command and type "history delete".  Let's maybe add a shortcut to do
this from the history pager.

The current shortcut is Shift+Delete. I don't think that's very discoverable,
maybe we should use Delete instead (but only if the cursor is at the end of
the commandline, otherwise delete a char).

Closes #9454
2023-07-04 18:42:11 +02:00
Fabian Boehm
c385027eca
docs: Add "Writing your own prompt" doc (#9841)
* docs: Add "Writing your own prompt" doc

* Remove a space from the "output"

* some teensy adjustments

* Address feedback

* envvar one more PWD

* More html warning
2023-06-20 19:43:09 +02:00
Fabian Boehm
38ac21ba5e alias: Escape the function name when replacing
Fixes #8720
2023-06-17 07:46:07 +02:00
Fabian Boehm
65769bf8c8 history: Allow deleting ranges
This allows giving a range like "5..7".

It works in combination with more (including overlapping) ranges or
single indices.

Fixes #9736
2023-06-10 15:35:40 +02:00
Fabian Boehm
516b8da302 Allow disabling focus reporting 2023-06-10 07:25:20 +02:00
Amy Grace
4c9fa511e8 Force use of macOS's builtin manpath
Prevent a useless warning msg if Homebrew's `man-db` is installed and configured
2023-06-06 13:12:30 -05:00
Fabian Boehm
946ecf235c Restyle fishscript and python 2023-06-01 18:20:19 +02:00
may
d19a08cd8c
update npm completions (#9800)
* update npm install completions

* update npm uninstall

* init npm dep rewrite

+ init npm

* npm uninstall complete global packages

* add npm pack completions

* add npm publish completions

* add npm init completions

* add missing commands, remove outdated, add missing aliases

* add npm audit completions

* implement requested changes

* rename __yarn_ to __npm_

* add missing commands / aliases

* slightly less verbose options, reword dry-run description (meh)

* more commands and options

* add and update completions for several commands

* access, adduser, bugs, ci, config, cache
* dedupe, deprecate, dist-tag, diff, docs, doctor
* edit, exec, explain, explore, find-dupes, fund
* hooks, help-search, install, ls, publish, search
* version, view

* more commands, fixes

* fish_indent

* remove most aliases from command suggestions

* add most other commands

* npm help, --help

* minor fixes

* remove npm builtin completion, new install option, fish_indent

* add completions for npm set, npm get
2023-05-30 11:22:18 +02:00
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