Commit Graph

1842 Commits

Author SHA1 Message Date
V
fc13dd362c
Colourise diff(1) output, if supported (#7308) 2020-09-04 18:43:09 +02:00
Fabian Homborg
bfb5b28d0f Let command, jobs and type take --query instead of --quiet
Now command, jobs, type, abbr, builtin, functions and set take `-q` to
query for existence, but the long option is inconsistent.

The first three use `--quiet`, the latter use `--query`. Add `--query`
to the first three, but keep `--quiet` around.

Fixes #7276.
2020-09-04 16:55:09 +02:00
Fabian Homborg
6a21a2ce16 Prompts: Don't color space before pipestatus
These passed " [" to __fish_print_pipestatus as the left brace.

If the color contained a background, that would also color the space
in, leading to a weird unbalanced space before and none after.

Instead, prepend the whitespace when printing later.

[ci skip]
2020-08-27 18:41:38 +02:00
Fabian Homborg
f88c3389da fish_prompt: Don't do work outside of the function
That just makes it annoying to use `funced`.

Also sync the classic_vcs prompt again.
2020-08-27 17:07:23 +02:00
chref
81d87d1c7f
fix Subversion prompt (#7278)
* fix Subversion prompt

- after switching to "string match", some SVN status symbols need
  proper escaping
- the __fish_svn_prompt_flag_names list was missing
  "versioned_obstructed" and was therefore not in line with
  the symbols from __fish_svn_prompt_chars
- when checking for individual SVN status symbols, use
  "string match -e" to handle the case where multiple different
  symbols appear in one status column
- use "sort -u" before merging all symbols from a column into
  one line

Fixes #6715

* use regex for SVN status matching

Using regex matching will prevent different match behaviour
depending on qmark-noglob feature.
Also, counting the resulting matches is unnecessary.

* use list instead of string for SVN status

Make $column_status a list be not removing newlines from SVN status
output. This makes checking for the individual status types within
a column easier because it doesn't require regex matching.

* added quotes for string length test (-n)
2020-08-26 18:31:23 +02:00
Fabian Homborg
72a44460c6 Move fish_greeting to a function
This adds a "fish_greeting" function that prints the variable of the
same name.

In doing so, it makes $fish_greeting default to a global
variable (this is of little cost because of the `_` builtin)

This means that:

- We have fewer universal variables by default
- If we change the default greeting people will actually get
- it (unless they have a leftover universal, of course)
- If the user changes their language the variable changes with it
2020-08-21 20:46:23 +02:00
Johannes Altmanninger
eb59d4eb14 Run fish_indent on share/**.fish 2020-08-17 17:40:28 +02:00
Johannes Altmanninger
9c327b19a6 Fix extra or missing newlines at end of file in our fish scripts
New fish_indent does that too, so this will make any future reformatting
diffs smaller.

Done using either of:

	perl -pi -e 'undef $/; s/\n*$/\n/' share/**.fish
	kak -n -f '<a-/>\n*<ret>d' share/**.fish
2020-08-09 23:53:46 +02:00
Johannes Altmanninger
93cb0e2abb __fish_complete_suffix: enable fuzzy completion, simplify
fish's internal completion logic is much smarter than the globbing in this
function, so let's just reuse "complete -C", and filter directories and
files with the given suffix.

Thanks to @Kratacoa for reporting on Gitter.

Using "complete -C" works well no prefix is given. Since in this repository
only the openocd completions pass a prefix, I left the prefix-case as is.
It could probably be improved and simplified as well.  The prefix argument was
introduced to avoid cd's side effects inside a completion. Using cd is tempting
though because it would allow to use the same logic as without a prefix.
2020-08-08 22:59:41 +02:00
Johannes Altmanninger
0dd334ee46 __fish_complete_suffix: replace prefix only at start 2020-08-08 22:56:54 +02:00
Fabian Homborg
203061292f Remove unused "__fish_prompt_cwd" variable
The repaint handler erased a variable that was just a dumb cache when `set_color` wasn't a builtin.

It was removed in 3f11d90744 in 2014.
2020-08-07 21:06:16 +02:00
Fabian Homborg
677e699a7a Stop repainting after paste
"repaint" here is a bit of a misnomer. It *doesn't* re-highlight, that
just happens on its own.

It re-runs the prompt, which can take quite a while (depending on the
configuration), and which is also useless in this context as this
isn't something the prompt will be reacting to (theoretically it
could, but I doubt the utility of displaying "PASTE" for a few milliseconds).
2020-08-07 21:06:16 +02:00
Fabian Homborg
be9d17b08a help: Add the other pages 2020-08-07 21:06:16 +02:00
Johannes Altmanninger
d7ccc475cf Cleanup __fish_complete_subcommand
The external-commands-only completion was briefly added in 3.1.0 and removed
in 3.1.1 (see #6798), which means we can remove some dead code.

Maybe we should just remove __fish_complete_external_command - it could break
users, but then again, we don't really have a way to stop people from starting
to use this deprecated function. The underscores ought to communicate that
this is function is private to fish but that is not enforced.
2020-08-06 21:24:26 +02:00
Soumya
916ffe8273 Only bold status in default prompt when set by last command
Uses regular text when the status is carried over, e.g. after a background job.
2020-08-05 12:23:49 -07:00
Allen Sobot
54823c9243
Implement XBPS completions (#7239) 2020-08-05 20:01:19 +02:00
Johannes Altmanninger
ac1f63781d __fish_complete_suffix: don't fail when a part of the suffix is present
Resolves #7233
2020-08-01 17:04:03 +02:00
Olivier FAURE
e7f0b5801d Add forward-single-char input command
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves https://github.com/fish-shell/fish-shell/issues/4984
2020-08-01 12:09:31 +02:00
ridiculousfish
1c2323e76f Use dashes instead of underscores pervasively in tutorial anchors
This fixes some broken help completions.
2020-07-31 12:10:16 -07:00
Gokul Soumya
b259fe17f9 vi-keybingings: Add missing abbr triggers for command terminators
Abbr expansion on command terminators were added
back in ec74c739 in response to #6970, but vi mode
was not updated.
2020-07-30 01:04:03 +02:00
Fabian Homborg
84b25855b0 alias: Escape the first word again
See https://stackoverflow.com/questions/63115744/alias-with-spaces-and-arguments-in-fish-3

This was broken in 115892ccd2
2020-07-27 17:19:44 +02:00
Fabian Homborg
5b706faa73 open: Workaround an xdg-open bug
If it can't recognize the DE, xdg-open uses a "generic" way of opening
things where it doesn't spawn off a DE-provided utility like kde-open.

This sounds great, but it fails to fork and therefore blocks the
terminal.

So we start it in the background and disown it.

Fixes #7215.
2020-07-21 16:59:05 +02:00
Fabian Homborg
42486a4cb3 Don't do CWD OSC in tests
Should fix #7193.
2020-07-13 20:55:39 +02:00
Mahmoud Al-Qudsi
f1a59e83c5 Move __fish_set_lscolors to ls.fish
It's not used anywhere else.

[ci skip]
2020-07-12 14:18:42 -05:00
Gokul Soumya
ec0c3f349d Return early if token is empty in whatis_current_token 2020-07-12 00:15:24 +02:00
Gokul Soumya
5f782cef7d Show builtin description with whatis_current_token 2020-07-12 00:13:51 +02:00
Gokul Soumya
e665f9b523 Precedence for functions over commands in whatis_current_token 2020-07-12 00:11:37 +02:00
Gokul Soumya
d0ce5fe943 Show function description if available with whatis_current_token
By default __fish_whatis_current_token is bound to ALt-W
2020-07-12 00:11:37 +02:00
Johannes Altmanninger
1f8c9a5d42 __fish_print_help: handle [ and : 2020-07-12 00:11:37 +02:00
Fabian Homborg
a40c82dcc4 Check if create_manpage_completions was installed
Fixes #7183.
2020-07-09 18:35:41 +02:00
Shun Sakai
d24a14744c
Update apk-tools completions (#7171)
* Update apk-tools completions

Add completions of options of it's subcommands.
The completions of deprecated options is unimplemented.

* Fix installed package listing for apk-tools

An error occurs when the local cache does not exist, so fixed this.
2020-07-05 18:22:36 -05:00
Fabian Homborg
eb35975c0f Make cancel-commandline actual bind function
This was always awkward as fish script, and had problems with
interrupting the autoloading.

Note that we still leave the old function intact to facilitate easier
upgrading for now.

Fixes #7145.
2020-07-01 20:56:56 +02:00
Mahmoud Al-Qudsi
de47a096e8 Add udevadm completions
[ci skip]
2020-07-01 09:27:20 -05:00
Johannes Altmanninger
8b961a0ca8 Bind undo to Control-Z in addition to Control-/
See #7152
2020-07-01 00:40:32 +02:00
Mahmoud Al-Qudsi
614c494859 Speed up default ^C action considerably
No more shelling out to external commands, no more loops, and no
conditionals past the initial check.
2020-06-29 19:41:33 -05:00
exploide
a966ace4a9 __fish_print_hostnames: match IPv6 addresses + cleanup 2020-06-28 20:11:39 -05:00
Daniel Bengtsson
e2f03fa8a7 Add a function to check if the user is root.
Add a helper function to check if the user is root. This function can be
useful for the prompts for example. Modify the prompts made root checked
to use the function instead. Add also the support of Administrator like
a root user.

Fixes: #7031
2020-06-26 21:25:13 +02:00
Fabian Homborg
149a0b98af Another formatting run
I really kinda hate how insistent clang-format is to have line
breaks *IFF THE LINE IS TOO LONG*.

Like... lemme just add a break if it looks better, will you?

But it is the style at this time, so we shall tie an onion to our
belt.
2020-06-24 20:43:56 +02:00
Malobre
94f4473d3b
Fix #7113, correct a few regexes. (#7130)
* Fix #7113 (cannot call help using msys2), correct a few regexes.

* Use regex instead of glob-style matching

* Match `\.exe$` instead of `cmd\.exe$` for WSL

* Match `\.exe(\s+|$)` instead of `\.exe$` and `cmd\.exe$`

* Fix a few regexes

This allows cygstart to be manually set as a browser, with or without arguments
2020-06-24 18:36:37 +02:00
Gokul Soumya
2fd78fd5c2
Uncomment most recent comment if commandline is empty when using toggle comment binding (#7137)
* functions/__fish_toggle_comment_commandline: Uncomment most recent comment if commandline is empty

* Refactor variable setting in functions/__fish_toggle_comment_commandline.fish

* Update changelog regarding toggle comment binding
2020-06-24 18:35:36 +02:00
Fabian Homborg
63f7f1925e git prompt: Simplify "staged" logic
This had this weird "pass along the sha, then check" logic to it which
is entirely unnecessary.

This function just says when something is staged, nothing more. Why
that is you can figure out for yourself.

This makes it easier to call this function, and it no longer prints an
empty line if nothing is staged.
2020-06-20 21:47:19 +02:00
Fabian Homborg
197d615cc8 git prompt: Minor cleanup 2020-06-20 19:01:27 +02:00
Fabian Homborg
4186d840db git prompt: Simplify some helper functions 2020-06-20 19:01:27 +02:00
Fabian Homborg
73c0fa03b8 git prompt: Also repaint correctly if use_informative_chars is set 2020-06-20 19:01:27 +02:00
Fabian Homborg
894ec3dfd4 fish_git_prompt: Always allow for displaying stashstate
This wasn't added to the prompt status order, so it was computed and
then not used for the informative prompt.

We still check later if we should compute it, so this is harmless if
showstashstate is unset.

Fixes #7136.
2020-06-20 09:33:04 +02:00
Fabian Homborg
4660be372a Only disable title in emacs "term"
There's more than one emacs terminal (for some reason), and term is
the most broken one and can't even handle a title.

Fixes #7122.
2020-06-17 16:48:13 +02:00
Shun Sakai
ffaf969e6e Add completions for apk-tools
Completion of options for each subcommand is not implemented.
2020-06-14 19:23:49 +02:00
Lennard Hofmann
1b90be57f2 Add foot to update_cwd_osc
See https://codeberg.org/dnkl/foot
2020-06-09 12:49:33 -07:00
Fabian Homborg
a4a4a2e1b6 __fish_print_packages: Fix apt
On my system this printed just "Description:" without any additional
characters, so this awkward `sed` didn't match and produced *all
packages on one line*.

Tbh this should probably be rewritten, but first we'd have to find a
way to get proper output here.
2020-06-08 18:32:52 +02:00
Fabian Homborg
e646285bcb
Let __fish_prepend_sudo use the last commandline if there is no current one (#7079)
* docs/faq: Mention prepend_sudo

[ci skip]

* __fish_prepend_sudo: Use $history[1] if commandline is empty

Currently, if you press alt+s with an empty commandline, it inserts
"sudo", which seems fairly useless.

Now, it inserts "sudo " followed by the last history entry, which
makes it a replacement for `sudo !!`.

* docs
2020-06-04 18:25:02 +02:00
Fabian Homborg
0064279905 Don't show greetings in read in scripts
This reverts commit 1b0ec21773.

"Interactive" has multiple meanings here, one of them being "the whole shell" is interactive, which `status is-interactive` tests, and one "this interaction is interactive", which happens when `read`ing in a script.

Fixes #7080.
2020-06-04 17:00:09 +02:00
Fabian Homborg
1f434cfde8 fish_config: Don't mention python 2
See #6537.

[ci skip]
2020-05-30 12:10:24 +02:00
Jason Nader
b4ca4245c6 gpg completions: add export SSH command 2020-05-30 10:10:07 +02:00
Fabian Homborg
4785440f65
Add an "_" builtin to call into gettext (#7036)
* Add an "_" builtin to call into gettext

We already have gettext in C++ (if available), so it seems weird to
fork off a command to start it from script.

This is only for fish's own translations. There's no way to call into
other catalogs, it just translates all arguments separately.

This is faster by a factor of ~1000, which allows us to call
translations much more, especially from scripts.

E.g. making fish_greeting global by default would hurt cost-wise,
given that my fish starts up in 8ms and just calling the current `_`
function takes 2ms, and that would have two calls.

Incidentally, this also makes us rely on a weirdly defined function
less, so it:
Fixes #6804.

* docs: Add `_` docs

Let's see if that filename works out.

* Reword _ docs
2020-05-29 20:53:44 +02:00
Fabian Homborg
9354dd6971 Add fish_add_path, a simple way to add to $PATH
This is a function you can either execute once, interactively, or
stick in config.fish, and it will do the right thing.

Some options are included to choose some slightly different behavior,
like setting $PATH directly instead of $fish_user_paths, or moving
already existing components to the front/back instead of ignoring
them, or appending new components instead of prepending them.

The defaults were chosen because they are the most safe, and
especially because they allow it to be idempotent - running it again
and again and again won't change anything, it won't even run the
actual `set` because it skips that if all components are already in.

Fixes #6960.
2020-05-29 20:51:05 +02:00
Fabian Homborg
ba116f1d3b fish_git_prompt: Count untracked files from the repository root
We already do this for the non-informative (non-counting) version.

Fixes #6086.
2020-05-28 20:49:48 +02:00
Jason
4e5220a4e1 gpg completions: add new option 2020-05-28 17:43:49 +02:00
Jason
bb7eb33b22 Fix typo 2020-05-28 17:41:01 +02:00
Jason
dc4ca005f8 gpg completions: complete key id for --edit-key
More useful than just user id since can have multiple keys per user.
2020-05-28 17:40:24 +02:00
Donovan
bc2eb383d4
Funcsave with --directory option (#7041)
* funcsave: add option --directory

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix synopsis

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix completion

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix error message

Signed-off-by: Donovan Jean <commit@dkrm.dev>

* funcsave: fix parameter expansion

Signed-off-by: Donovan Jean <commit@dkrm.dev>
2020-05-27 20:13:44 +02:00
Mahmoud Al-Qudsi
2d52335fed Don't fire fish_prompt when read is used
Apart from being semantically incorrect, this was causing `fish_prompt`
to fire twice after commands that used `read` (e.g. `cdh`).

Closes #7039.
2020-05-26 15:24:31 -05:00
Johannes Altmanninger
e885a65754 fish_greeting: highlight "help" in in green, like it used to be
This was changed in b9d2e4d with no obvious motivation, and the
translation strings still have the old version.
2020-05-25 23:50:30 +02:00
Jason
7b9119cc9a fish_vcs_prompt: allow argv passthrough
fish_git_prompt encloses its output in brackets, however this can be changed by supplying a format string to it, i.e. `fish_git_prompt %s`.
However when using `fish_vcs_prompt` there's no way to pass on the arg to fish_git_prompt, so you need to manually remove it.
fish_hg_prompt doesn't have the same format string support as fish_git_prompt, but I suppose it could be added later if needed.
2020-05-24 20:18:06 +02:00
Fabian Homborg
18a4ae3fd1 fish_greeting: Add second line unconditionally
For some reason we checked __fish_initialized *after confirming* that
$fish_greeting was empty?

See #7016.
2020-05-23 18:54:43 +02:00
Fabian Homborg
a40a35cc52 Put all the ls logic into the function
Doing it when sourcing isn't necessary or all that great.

Just make it an actual normal function file.
2020-05-23 14:30:00 +02:00
Fabian Homborg
928e80ad6a Extract setting $LS_COLORS to its own function
Makes it easier to override ls while keeping $LS_COLORS.
2020-05-23 14:30:00 +02:00
Johannes Altmanninger
a9b60d2493 Call fish_prompt after background job finishes
We don't need to call it if a job was stopped, because in that case
read_i() will fire fish_prompt already, because the newly stopped job
was probably a foreground job.

Fixes #1018
2020-05-22 21:24:59 +02:00
Johannes Altmanninger
6746060c14 Run fish_indent on all fish files in share/ 2020-05-19 21:15:39 +02:00
Shun Sakai
cc039e29ce Add completions for Docutils 2020-05-19 21:02:55 +02:00
Soumya
518170b299 Also call fish_job_summary for foreground sigint
The default implementation will not print any output in that case, but this provides users with additional flexibility when it comes to customising the shell's behaviour.
2020-05-19 20:39:10 +02:00
Soumya
324fa64114 Add fish_job_summary, called whenever a job ends, stops, or is signalled
This allows users to customise the behaviour of the shell by redefining the function. This is similar to how fish_title or fish_greeting behave, where the default implementation can be easily overridden.

The function receives as arguments the job id, command line, signal name and signal description.
2020-05-19 20:39:10 +02:00
Enrico Borba
f10de5f653
__fish_prepend_sudo: Toggle "sudo" on multiple presses (#7012)
At the moment calling __fish_prepend_sudo multiple times does not toggle
sudo, and also unnecessarily uses the `-c` flag to `commandline` to see if
the first token on the commandline is "sudo".

This change removes the `-c` switch and also toggles "sudo" on multiple
calls to __fish_prepend_sudo, while maintaining the cursor position and
while maintaining any spaces between "sudo" and the next token on the
commandline.
2020-05-17 11:15:15 +02:00
Johannes Altmanninger
f9447dc72f help.fish: fix help for the separate completion page 2020-05-16 11:58:12 +02:00
Johannes Altmanninger
8e18f683a7 help.fish: fix not using anchors for some help topics
The completions for help know many more help topics, it makes no sense
to whitelist them here.

Fix anchor links for tutorial sections.

Remove some dead code: the "man" branch was unreachable because of the
earlier (__fish_print_commands) case.
2020-05-16 10:34:32 +02:00
Johannes Altmanninger
ec2371fb79 Some more precautionary uses of set --local 2020-05-15 21:35:48 +02:00
Johannes Altmanninger
49c5f96470 Use set -l to force use of a local variable
Bare set overwrites a global/universal variable if it exists.
2020-05-15 08:25:07 +02:00
Johannes Altmanninger
fe6c76d058 Read into local variables in some completions
Otherwise these might modify global or universal vars.
2020-05-15 07:14:54 +02:00
Uy Ha
76bbcb9804 Add check to let Windows Terminal pass 2020-05-14 18:02:50 -07:00
exploide
1ccec532f0 __fish_print_hostnames: skip ssh host definitions containing wildcards 2020-05-14 22:34:47 +02:00
LawAbidingCactus
f71737e58a Add $fish_force_vi_cursor variable to allow cursor setting on unsupported terminals 2020-05-14 22:25:20 +02:00
Johannes Altmanninger
a8e9f560e4 fish_clipboard_copy: also copy newlines from mult-line commands 2020-05-14 21:07:37 +02:00
Fabian Homborg
ea0a0991a1 anypython: Try supported numbered python3 versions
In case someone doesn't even have a `python3` symlink.
2020-05-10 22:49:25 +02:00
Jason Nader
bb65f81e64 edit_command_buffer: Add line:col support for micro 2020-05-08 20:00:07 +02:00
Eamon Caton
b665604475 Add newline to history clear message for consistency 2020-05-08 22:36:57 +08:00
Fabian Homborg
3c6c8d5424 fish_vi_cursor: Add alacritty to the whitelist 2020-05-07 18:04:39 +02:00
David Adam
ec74c739c8 bindings: expand abbreviations with all end-of-command characters
Closes #6970.
2020-05-07 09:13:33 +08:00
Fabian Homborg
3e29b0d916 fish_vi_cursor: Allow new Konsole
It removed $KONSOLE_PROFILE_NAME and added $KONSOLE_VERSION.

Let's assume if $KONSOLE_PROFILE_NAME is set we use the old sequences,
if not we use the new ones.
2020-05-02 17:42:42 +02:00
David Adam
f36c82ce86 Reenable command descriptions on macOS 10.15.4+
Further work on #6270, as recommended in 611a6589ea.

[ci skip]
2020-05-01 21:28:43 +08:00
ridiculousfish
a1494c9c22 Revert "__fish_describe_command: print only exact match and exit"
This reverts commit 535845861a.

That commit introduced a bug where tab-completing commands no longer
prints their descriptions, unless there is an exact match.
2020-04-30 11:09:46 -07:00
hyperfekt
31cb615671 __fish_config_interactive: use __fish_anypython 2020-04-29 14:17:16 +08:00
George Christou
2bc4228d42 edit_command_buffer: Add line:col support for Sublime Text 2020-04-28 08:48:31 +02:00
LawAbidingCactus
ad677d388c fix pushd 2020-04-26 14:39:15 +02:00
Fabian Homborg
c7c10c8b10 __fish_ps: Use builtin realpath
We might want to find a better home for that builtin.
2020-04-21 21:11:26 +02:00
Fabian Homborg
18b2a65fdc Remove unused --inherit-variable 2020-04-21 21:11:26 +02:00
Fabian Homborg
6ebbe5a450 fish_clipboard_copy: Stop adding newlines
When this switched over from directly piping commandline to storing
its output and using printf, I inadvertently always added a trailing
newline. That's probably annoying.

Note that this will now always *remove* a trailing newline (because
the command substitution does). That will barely make a
difference (because trailing newlines are quite unusual in the
commandline) and will probably feel better than keeping it - we could
even make a point of removing trailing whitespace in general.

Fixes #6927
2020-04-21 07:26:27 +02:00
Jason Nader
f66285d7a1 dogfood string split -f 2020-04-20 22:39:48 +02:00
Johannes Altmanninger
9c6e81a838 Support busybox ps in process completions
Fixes #6918
2020-04-19 05:51:25 +02:00
Alan Somers
3d0581d195 fish_hg_prompt should return 1 when not in a mercurial directory 2020-04-19 04:24:28 +02:00
Joel Kuhn
a3dfa21737 Change vi-mode tilde to toggle character case
This updates the behavior of tilde to match the behavior found in vim.
In vim, tilde toggles the case of the character under the cursor and
advances one character. In visual mode, the case of each selected
character is toggled, the cursor position moves to the beginning of
the selection, and the mode is changed to normal. In fish, tilde
capitalizes the current letter and advances one word. There is no
current tilde command for visual mode in fish.

This patch adds the readline commands `togglecase-letter` and
`togglecase-selection` to match the behavior of vim more closely. The
only difference is that in visual mode, the cursor is not modified.
Modifying the cursor in visual mode would require either moving it in
`togglecase-selection`, which seems outside its scope or adding
something like a `move-to-selection-start` readline command.
2020-04-18 14:59:37 +02:00
Jouke Witteveen
93b86bbe63 systemctl completions: Use --plain where appropriate
The --plain flag drops the '●'-glyph and generally makes the output more
suitable for automated processing.
2020-04-18 11:11:27 +02:00
Jason Nader
85a8deabe9 Run fish_indent on all files 2020-04-18 10:53:11 +02:00
Johannes Altmanninger
be36c96028 alias.fish: unbreak listing aliases without backslashes
The description for an alias which already has escape sequences will
use backslash escapes for quoting; usually `string escape` can simply
quote it.  Use a regex that accepts either escaping style.
2020-04-18 09:35:33 +02:00
Johannes Altmanninger
9eb2b69a51 alias.fish: list aliases that are escaped, not quoted
Fixes #6910
2020-04-17 23:16:43 +02:00
jeanprey
052d8d3a10 Activate untracked status in hg prompt
Correction of a typo that prevented the display of untracked status on the detailed prompt.
2020-04-16 19:18:22 +02:00
Benjamin Kellermann
de9f4cb252 add completion for netcat
- implement the most common netcat variants on Linux
  - nc.openbsd
  - nc.traditional
  - nc/netcat tries to guess which netcat is currently used
2020-04-13 23:45:40 +02:00
Jason Nader
d278ff4e45 Use the new string split --fields feature 2020-04-12 14:01:21 -07:00
Charles Gould
8029f15f1f git prompt: better check for git stashes
When you run "git gc":

 - .git/refs/stash is deleted
 - .git/logs/refs/stash is kept intact
2020-04-10 00:22:16 +02:00
exploide
8025e80fdb new function __fish_preview_current_file to open file at the cursor in pager
bound to Alt+O by shared key bindings
created with help from @krobelus
fixes #6838
2020-04-07 22:30:05 +02:00
Thom Chiovoloni
39e0fd14eb Allow man completions on catalina if apropos is overridden
It's pretty easy to fix catalina's apropos with a small tweak, so it
would be nice if man completions worked if this is done.
2020-04-06 19:13:12 +02:00
Fabian Homborg
ff68bdceba Allow file completions for more builtins
- contains
- count (for `count *`)
- echo
- printf
- random (for `random choice`)

Fixes #6520
2020-04-06 18:59:10 +02:00
Fabian Homborg
6a721fab63 Let . and : be completed with files
For `.` it's *correct* and for `:` it literally accepts everything
2020-04-06 18:56:10 +02:00
Ron Gebauer
77fb54fa99 In Fish MD5 on BSD now use given String and not -s
Signed-off-by: Ron Gebauer <ron.gebauer@raytion.com>
2020-04-05 17:25:02 -07:00
Jason Nader
eaf313f755 Dogfooding to show off use case 2020-04-04 15:30:09 +02:00
Fabian Homborg
1b0ec21773 __fish_config_interactive: Remove a "is-interactive" check
This looks like a copy-paste error. If we're in
__fish_config_interactive, we're *interactive*.
2020-03-28 09:50:37 +01:00
Johannes Altmanninger
aa304cbd3d Restore directory completions for subcommands
Fixes #6798

This re-adds some false positives: functions, builtins and abbreviations
are suggested after commands like sudo but I don't think anyone had
complained about that.
2020-03-24 20:18:07 +01:00
Johannes Altmanninger
d0bedf3bbd help.fish: only use cmd.exe on WSL
Fixes #6797
2020-03-23 21:02:15 +01:00
Jason Nader
979d3a18aa help function: special case string xxx 2020-03-22 09:33:07 +01:00
Fabian Homborg
8ddd512fba Refine when we expand abbreviations
- ctrl-space will insert a space without expanding abbrs
- ")" or alt-enter will expand abbrs

Fixes #6658
2020-03-21 13:55:15 +01:00
Jon Cinque
23a21eb318 Add vi 'y' bindings and some i / a support
Many people have mentioned wanting support for changing / yanking /
deleting between "" and '', meaning the commands `ci' ci" yi' yi" di' di"`,
so this adds that support in a generic, and thus potentially confusing way.
The concept is that we check for the character backwards and forwards
before making the selection.  Unfortunately, this will also work for *any*
character that isn't `w` or `W`, so `cia` could change everything between
two `a` characters.
Looking through the [bind documentation](https://fishshell.com/docs/current/cmds/bind.html)
and input handler at `src/input.cpp`,
this is the best possible solution I could come up with until
`forward-jump` and `backward-jump` can accept input in the call to `bind`,
and not just from stdin, meaning we can write a binding as:
```
bind di\" backward-jump-till \" and repeat-jump-reverse ...`
```
If that were done, then other commands such as `di)` to go between `()` would
be possible.
There are also some added `y` bindings not part of #6648.
Let me know if you need anything else.
2020-03-21 13:52:12 +01:00
Mahmoud Al-Qudsi
1d7643751b Revert "Make funcsave update the function <-> file mapping"
This reverts commit 7f402cdae7.

There are fundamental issues with `funced` and `funcsave` that prevent
this from working. A file and a function are not interchangeable.
2020-03-20 10:18:52 -05:00
Mahmoud Al-Qudsi
7f402cdae7 Make funcsave update the function <-> file mapping
This makes `funced` after `funcsave` behave as expected rather than a
potential source of data loss.

Closes #6113.
2020-03-20 10:03:05 -05:00
Fabian Homborg
1e2e511570 fish_default_key_bindings: Remove outdated stderr silencing
We *always* silence `bind` here, so we don't need to specifically
silence for these keys.
2020-03-15 21:01:11 +01:00
Fabian Homborg
aa629c5aca Reformat fish scripts with escaped newline changes to fish_indent 2020-03-15 21:01:11 +01:00
Fabian Homborg
463b9b99c6 Move ctrl-left/right forward-word to shared bindings
These also work in vim.

Fixes #6755.
2020-03-15 13:24:45 +01:00
Jason Nader
266ce7c940 Improve Arch Linux package completions
Add completions for `downgrade` tool
Add new `--installed` option for printing Arch packages
Change Arch Linux package related completions to use `--installed`

add newline
2020-03-15 13:19:25 +01:00
Johannes Altmanninger
651f3cf863 Fix VSCode not blocking in edit_command_buffer 2020-03-14 14:15:10 +01:00
Fabian Homborg
db7dfddc3b completions/systemctl: Remove annoying marker
The output of

systemctl list-units

seems to include a marker of '●' or '*' for some units, even if the
output is not going to a terminal and "--no-legend" and "--no-pager"
are given. This appears
to be a recent development, and there does not appear to be a flag to
disable it.

So we simply filter it out in the completions to once again hopefully
offer the actual units.

Fixes #6740
2020-03-12 18:37:32 +01:00
Fabian Homborg
5ab1e2dc0f help: Always use xdg-open if available
Even if $DISPLAY is unset, xdg-open can be useful, and on systems that
have xdg-open, "open" is most likely some god awful outdated thing
called "openvt" elsewhere.

Fixes #6739

[ci skip]
2020-03-12 17:27:37 +01:00
Johannes Altmanninger
c5e4419097 Add "--" safeguards at string length [ci skip] 2020-03-10 21:01:00 +01:00
Johannes Altmanninger
208b0f9dd5 Interactive config: remove useless argument and correct redirection 2020-03-10 20:56:45 +01:00
Johannes Altmanninger
685b668958 Complete IDs for unix users and groups that start with _ 2020-03-10 20:56:45 +01:00
Fabian Homborg
9367d4ff71 Reindent functions to remove useless quotes
This does not include checks/function.fish because that currently
includes a "; end" in a message that indent would remove, breaking the test.
2020-03-09 19:46:43 +01:00
exploide
f39cba1d9f added functions to complete user and group IDs 2020-03-08 17:24:14 +01:00
ridiculousfish
29c2bce704 Use self-insert-notfirst on spaces during paste
This changes a5a643f854 to use the new self-insert-notfirst binding.
It also adds a test.
2020-03-07 13:31:55 -08:00
Jason Nader
926c1f1016 Privatise completion-only funtions 2020-03-07 13:26:27 -08:00
Johannes Altmanninger
87728c4d0d Pass cursor position to edit_command_buffer for some editors
Fixes #6138

Naturally this does not work for many other editors/aliases,
but it's still nice that we can make it work for some common
editors without requiring any configuration.

Of course this approach is not terribly flexible; but it's
alwyas possible to just wrap edit_command_buffer and set an
EDITOR that knows about the cursor position. It doesn't
feel important enough to add a configuration option.
2020-03-07 21:24:14 +01: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
da7b762f4a Make default hg prompt leaner
The default hg prompt is slow on large repositories (hg status takes
2-3 seconds on mozilla-central) which is unacceptable as a default.

Mimick our git prompt: by default, only show the current branch.
If the new variable $fish_prompt_hg_show_informative_status is set,
then use the old behavior.

[ci skip]
2020-03-07 13:02:58 +01:00
Jason Nader
b4626468ec completion helper functions: do not use gettext
remove package
2020-03-06 22:23:50 +01:00
Jason Nader
97d5f68cdf completions: update ftp 2020-03-04 10:26:54 -08:00
Fabian Homborg
4f47636838 fish_print_hostnames: Fix multiple host aliases
Fixes #6698.

[ci skip]
2020-03-03 18:30:06 +01:00
Jason Nader
86b7c1034c Prevent prompt from spewing errors if cwd has disappeared 2020-03-03 18:06:20 +01:00
Jason Nader
9c8fff08c1 fish_npm_helper: fix typo in comments 2020-03-02 21:36:11 +08:00
Fabian Homborg
0f34459fce Disable svn prompt by default
This is apparently quite slow on large svn repos (like 40 seconds
slow), and we don't have a good thing to display other than the full
file information.

So we'll have to disable it for now.

Fixes #6681.

[ci skip]
2020-03-01 17:04:02 +01:00
Jason Nader
45b1ca25a5 Speed up python startup time 2020-02-28 11:23:58 +01:00
Jan Verbeek
d02736c0ce
Improve psql completions and add some related commands (#6620) 2020-02-28 11:16:41 +01:00
Simon Rainer
e1a08e3f58 Add additional vi bindings
Adds dh, dl, c0, cf, ct, cF, cT, ch, cl, and y0 bindings.
2020-02-24 00:05:14 -08:00
Mahmoud Al-Qudsi
535845861a __fish_describe_command: print only exact match and exit
Mimic the behavior of Linux's `apropos -e` and ~BSD's `apropos -f` with
the awk script by disallowing trailing characters in the name of the
manpage as compared to the original input string. Apart from being
faster (by aborting earlier and stopping `apropos` by breaking the pipe
after the first match), it's also more correct.
2020-02-17 20:22:39 -06:00
Mahmoud Al-Qudsi
3c7019b335 __fish_describe_command: check for apropos only at startup 2020-02-17 20:13:39 -06:00
Mahmoud Al-Qudsi
5510443f48 __fish_describe_command: Remove regex escape hack 2020-02-17 20:13:30 -06:00
Fabian Homborg
65883e0e40 Restyle
Mostly line breaks, one instance of tabs!

For some reason clang-format insists on two spaces before a same-line comment?

(I continue to be unimpressed with super-strict line length limits,
but I continue to believe in automatic styling, so it is what it is)

[ci skip]
2020-02-17 14:14:05 +01:00
Jason Nader
a619f69b15 Rename functions to match others 2020-02-17 09:55:05 +01:00
Johannes Altmanninger
8a033b9f3d Add undo
Add the input function undo which is bound to `\c_` (control + / on
some terminals). Redoing the most recent chain of undos is supported,
redo is bound to `\e/` for now.

Closes #1367.
This approach should not have the issues discussed in #5897.

Every single modification to the commandline can be undone individually,
except for adjacent single-character inserts, which are coalesced,
so they can be reverted with a single undo. Coalescing is not done for
space characters, so each word can be undone separately.

When moving between history search entries, only the current history
search entry is reachable via the undo history. This allows to go back
to the original search string with a single undo, or by pressing the
escape key.
Similarly, when moving between pager entries, only the most recent
selection in the pager can be undone.
2020-02-07 17:15:17 +01:00
Geoff Nixon
f7edfba5d7 Avoid apropos on macOS 10.15 with man completion
Same issue occurs here, as in #6270 (and fixed in 611a658 for `__fish_describe_command.fish`). Same reason. I've just copied the same workaround and changed the function name to match.
2020-02-07 20:52:39 +08: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
50e08dc3a0 add completions for wireshark/tshark/dumpcap 2020-01-30 16:45:02 +01:00
Johannes Sasongko
8e8a3846fb __fish_prepend_sudo: Don't move the relative position of the cursor
At the moment the "prepend sudo" functionality always sets the cursor to
the end of the line. This changes it to restore the relative position of
the cursor.
2020-01-29 09:21:23 +01:00
Jason
bcf2e2cdbd Remove unused variable 2020-01-26 12:28:01 +01:00
Jason Nader
5bfb6fef76 Stringify __fish_pwd.fish 2020-01-24 19:05:08 +01:00
Fabian Homborg
d61c188c3c Fix xdg mimetype completion
This hung when no file existed, and failed to properly find the
directories if they didn't end in a "/".

Fixes #6525

[good for 3.1.0]
2020-01-22 16:33:56 +01:00
Jason Nader
6fb545cf9b Stringify gpg completions 2020-01-21 17:57:57 +01:00
Jason Nader
103a26ffb1 Fix function output on FreeBSD/Cygwin systems 2020-01-21 16:55:37 +01:00
Fabian Homborg
1480865d52 Stringify make_completion_signals 2020-01-20 17:51:59 +01:00
Fabian Homborg
acefa61e8b Hardcode signal names/numbers on cygwin
Work around weirdness in Cygwin's kill implementation.

Fixes #6469.
2020-01-20 17:51:59 +01:00
Fabian Homborg
69b464bc37 Run fish_indent on all our fish scripts
It's now good enough to do so.

We don't allow grid-alignment:

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z              -a '(something)'
```

becomes

```fish
complete -c foo -s b -l barnanana -a '(something)'
complete -c foo -s z -a '(something)'
```

It's just more trouble than it is worth.

The one part I'd change:

We align and/or'd parts of an if-condition with the in-block code:

```fish
if true
   and false
    dosomething
end
```

becomes

```fish
if true
    and false
    dosomething
end
```

but it's not used terribly much and if we ever fix it we can just
reindent.
2020-01-13 20:34:22 +01:00
Fabian Homborg
611a6589ea Disable command descriptions on macOS 10.15.X
We just do a cheesy version check and hope it works out.

If this is fixed in 10.15.4, we have to reenable it. If it still isn't
fixed in 10.16, we need to adjust it.

Fixes #6270
2020-01-05 18:35:59 +01:00
Fabian Homborg
4a47e212f8 Color the default prompt host if running via SSH
This is part of our (well, my) quest to spice up the default prompt.

In this case we color the host if $SSH_TTY is set, which is easy to
detect and helps draw attention to the host.

See #6398.
See #6375.
2019-12-30 14:03:36 +01:00
Johannes Altmanninger
0afc5258cf Unify detection of fish version upgrade with $__fish_initialized
This variable holds an integer that resembles the fish version up to
that initializations were performed. It should be incremented whenever
some new initialization is required after upgrading fish.  This should
not change the behavior for existing fish installations, except for a
minor message on installations that upgrade from fish<2.3.0.

[ci skip]
2019-12-30 14:00:22 +01:00
Fabian Homborg
b0e3cc4b5c __fish_complete_suffix: Remove eval
This use of eval is unsafe, not really all that useful and can spew
errors that can't be suppressed. So let's remove it, and in future add
a thing that can do expansions in a safe manner

Fixes #6456.
2019-12-28 17:10:23 +01:00
Johannes Altmanninger
feb87bbda8 __fish_man_page: ignore prefixing variable assignments 2019-12-19 23:44:58 +01:00
Fabian Homborg
22b2dbd97d functions/history: X is incompatible with SDMV, not C
"-C" is short for "--case-sensitive", which is entirely okay with "--delete".

The one that isn't okay is "-X", which is short for "--Clear".

Seen on gitter.im
2019-12-19 20:59:17 +01:00
Mahmoud Al-Qudsi
364929e46e Disown first-run python completions generation
Closes #6269.
2019-12-18 14:12:49 -06:00
Jason
48bf3a4907 Delete __fish_sgrep.fish 2019-12-18 13:17:54 -06:00
Mahmoud Al-Qudsi
6dc8a1d3a7 Partially address #6340 (escape files starting with -)
This prefixes files beginning with `-` with a `./` when generating
completions *in fish code*. Standard completions for directory listings
generated by the C++ directory traversal code are not afected by this
patch.

Most fish completions defer to `__fish_complete_suffix` to generate the
file/directory completions, these *will* be corrected.
2019-12-18 13:13:23 -06:00
Dan Martinez
4e52feb51a Have type deal with both flavors of fileless function (#6421)
* Deal with *both* types of dynamic function

* Use a guard (`--`) when `-` is an argument
2019-12-12 20:42:11 +01:00
Dan Martinez
9a3886dc2b Make type -p and type -P behave as documented (#6412)
* Make `type -p` and `type -P` behave as documented

* Recognize `-` as an additional sign of no path

Functions created via `source` (like by `alias`) cause `functions --details` to return `-`
rather than `stdin` when invoked upon them.
2019-12-12 17:09:52 +01:00
Dan Martinez
16dc606001 Add the --short flag to type (#6403)
* Add the `--succinct` flag to `type`

* Use `echo` rather than `printf`

* Change `succinct` to `short`; print path if known

* Clean up the printing logic ever so slightly
2019-12-11 22:24:29 +01:00
Johannes Altmanninger
cc7ae03070 prompt: don't consider SIGPIPE a failure
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
94b5720343 prompt: remove fallback for $fish_color_host
This was mostly dead, since $fish_color_host is set to normal in
__fish_config_interactive. The assignment was only used if the user
explicitly unsets fish_color_host (which they shouldn't, really).
Anyway it's weird to use cyan, use normal instead.
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
2f1a5e65d8 prompt: don't set default colors twice
The colors are set in __fish_config_interactive before the prompt is
painted for the first time.

Also initialize the $fish_color_status for the (pipe) status, bump the
version for that.
[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
Akatsuki
efb72f1f91 Revert "Move __fish_systemd_machines into machinectl completion script"
This reverts commit 9c15b5b7a4.
2019-12-09 21:07:21 +01:00
Fabian Homborg
b2332e9f3e Switch default prompt to Classic+VCS
This has more info, in particular vcs and status.

The old default is still available as the "classic" prompt.

Fixes #6375.
2019-12-07 19:25:41 +01:00
Peter Collingbourne
6dc4ac60ae Use $PWD to retrieve the current directory in __fish_move_last.
(command pwd) uses the system's implementation of pwd. At least the GNU
coreutils implementation defaults to -P, which resulted in symlinks being
expanded when switching between directories with nextd/prevd.
2019-12-07 12:20:31 +01:00
Jason
7999cd4f25 Remove fish_fallback_prompt function 2019-12-07 12:16:48 +01:00
Fabian Homborg
9d14594f7c
Merge pull request #6390 from ammgws/debian
Move __fish_print_debian_services into invoke-rc.d completion script
2019-12-07 12:16:29 +01:00
Jason
c4400c31f7 Remove deprecated function 2019-12-07 12:16:15 +01:00
Jason
3129b3c5ef
Move __fish_print_debian_services into invoke-rc.d completion script 2019-12-05 05:26:26 +09:00
Fabian Homborg
9efb7fd5f6 __fish_cancel_commandline: Always repaint
Fixes #6394.
2019-12-04 21:21:34 +01:00
Jason
a361cde1df Move __fish_complete_svn_diff into the completion script 2019-12-04 20:53:58 +01:00
Jason
965b142acd Move __fish_print_zfs_* into zfs completion script 2019-12-04 20:53:01 +01:00
Jason
69dccce937 Move __fish_print_function_prototypes into valgrind completion script 2019-12-04 20:51:55 +01:00
Jason
013001c283 Move __fish_print_lsblk_columns into lsblk completion script 2019-12-04 20:51:37 +01:00
Jason
5107de395d Move __fish_print_xdg_desktop_file_ids into xdg-mime completion script 2019-12-04 20:51:21 +01:00
Jason
9c15b5b7a4 Move __fish_systemd_machines into machinectl completion script 2019-12-04 20:51:09 +01:00
Jason
b658b421ad Move __fish_ports_dirs into ports completion script 2019-12-04 20:50:55 +01:00
Jason
40832f897c Move __fish_portage_print_repository_names into emaint completion script 2019-12-04 20:50:28 +01:00
Jason
69255d5641 Move __fish_parse_configure into configure completion script 2019-12-04 20:50:19 +01:00
Jason
b3f8a93e02 Move __fish_print_abook_emails into mutt completion script 2019-12-04 20:50:01 +01:00