Commit graph

1666 commits

Author SHA1 Message Date
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