Commit Graph

8795 Commits

Author SHA1 Message Date
Fabian Homborg
39905d4135 Skip fish_vi_cursor when not interactive
This prints an escape sequence, so it can break scp or similar when
someone has an unqualified

    fish_vi_key_bindings

in config.fish and happens to run a terminal that can set the cursor.
2018-06-01 20:26:54 +02:00
Fabian Homborg
72e9d41dcc [complete] Fix crash with __fish_describe_command
Our completion machinery calls our `__fish_describe_command` function
to describe commands via apropos. Only it trusts the output a bit too
much, so it crashes when any line from that is shorter than the
original string.

Fix this by skipping any string that is shorter than the original,
since it can't be a match anyway.

Also stop doing wcslen so often - std::strings are nice!

Fixes #5014.
2018-06-01 20:16:23 +02:00
Fabian Homborg
44d68f99ea [completions/gcc] Improve wording
These completions are apparently based on an auto-generated version,
so there's a whole bunch of rewording to be done here.

Also for some reason some of the options are mentioned more than once?
2018-06-01 20:16:23 +02:00
Mahmoud Al-Qudsi
f741968d6d Drop hard dependency on bash from git_version_gen.sh again
I can't seem to find a reason why the shell interpreter needs to be bash
and not just sh here. Needed to replace `BASH_SOURCE[0]` with the legacy
`$0` supported by sh, but otherwise it seems to still work.

Many non-Linux platforms do not ship with bash out-of-the-box (and as a
shell, I don't think we need to encourage the further proliferation of
bash ;-), this lets fish build on a clean install of FreeBSD, which does
not have bash.
2018-06-01 12:48:03 -05:00
Mahmoud Al-Qudsi
e26d5418af Revert "Blow away existing $fish_data_dir on (re)install"
This reverts commit e35983438e.
Reopens #4314. Closes #5007.

# Conflicts:
#	share/config.fish
2018-05-31 22:41:49 -05:00
David Adam
8a6fe77f71 docs: remove unneeded dashes 2018-05-31 13:07:02 +08:00
David Adam
84f5d2082a Mark arguments as optional in read docs synopsis 2018-05-31 13:07:02 +08:00
Fabian Homborg
fa8248f170 [completions/git] Don't run __fish_git_refs twice for "log"
That's already included in `__fish_git_ranges`, so we don't need to do
it again.

Mentioned in #4117.
2018-05-30 18:10:52 +02:00
Fabian Homborg
0f4126c115 Silence winch handler
Fixes #4876.
2018-05-29 18:40:29 +02:00
Fabian Homborg
93d40f9143 [input] Only timeout if the last character was escape
There really is no need to

- Timeout just because the _first_ character was a control character

- Timeout because of any control character other than escape

The reason to timeout because the '\e' sequence can appear by itself (signifying
pressing the escape key) and still make
sense - e.g. vi-mode has it bound to a rather important function!

But a \c can't appear by itself, so we can just block.

This allows binding sequences like \cx\ce and inputting them at a
leisurely pace rather than the frantic escape_timeout one.

It should also improve sequences that _include_ escape somewhere else.

E.g. something like a\eb ("a, then alt+b") should now time out for the "\eb" part,
allowing users to bind a\e ("a, then escape") to something else. Why you'd want to do
that, I have no idea. But it's more consistent, and that's nice!
2018-05-29 18:40:29 +02:00
David Adam
725062d360 fish.spec: switch to cmake builds 2018-05-29 13:46:14 +08:00
Gustaf Johansson
23eb63eb2f completions: [git] Added git help completions
This patch adds completions for the help subcommand of git.
2018-05-28 12:15:19 +02:00
Fabian Homborg
88e6930b57 [string] Be explicit about nextstr() type 2018-05-28 12:10:40 +02:00
Fabian Homborg
ca897807eb Add some tests for string and NUL 2018-05-28 12:10:40 +02:00
Fabian Homborg
49c736f407 [string] Move split/repeat to wcstring 2018-05-28 12:10:40 +02:00
Fabian Homborg
e468c767b5 [String] Partially switch match/replace to string
For regex-mode, this should be enough to read NUL-delimited strings to act on, but not
quite patterns and replacements.

Glob-mode requires more work - it uses wcscmp internally, which is unsuitable.
2018-05-28 12:10:40 +02:00
Fabian Homborg
1e2fa80d3e Switch (un)escape to wcstring
Also the various styles have one function each with barely any
difference - mostly passing the corresponding STYLE argument.

Pack them into one function for escape and one for unescape to save
about 100 lines.
2018-05-28 12:10:40 +02:00
Fabian Homborg
0cfe722a93 Switch lower/upper to wcstring
Also, these are different only in that one uses "towlower", the other
"towupper". So just make one function that both call.
2018-05-28 12:10:40 +02:00
Fabian Homborg
191ca21092 Switch trim to wcstring 2018-05-28 12:10:40 +02:00
Fabian Homborg
4cc0c3bfa7 Switch string sub to wcstring 2018-05-28 12:10:40 +02:00
Fabian Homborg
583d771b10 Fix escape_string_var for UTF-16
We're now actually handling wchar_t here, so comparing the 0x80 bit
would break for UTF-16, causing ASCII false-positives.

Also simplifies a bit, since we no longer need a second variable.
2018-05-28 12:10:40 +02:00
Fabian Homborg
b2b4ab4bab constref more things
Thanks @ridiculousfish!
2018-05-28 12:10:40 +02:00
Fabian Homborg
4dc1c6ca39 [string] Allow url/var escaping to handle NULs
Fixes #4605.
2018-05-28 12:10:40 +02:00
Fabian Homborg
485fdbde41 [string] Allow length to handle NULs
printf 'a\0b' | string length

used to print "1". Now it prints "3".

Note that this switches to using C++'s std::string::length, which
might give differing results.
2018-05-28 12:10:40 +02:00
Fabian Homborg
bcd23ff971 [string] Allow join to handle NULs 2018-05-28 12:10:40 +02:00
Fabian Homborg
aedb8dc327 [string] Allow string escape to handle NULs
TODO: This currently only works for the "script" escaping style.

Work towards #4605.
2018-05-28 12:10:40 +02:00
Fabian Homborg
a229f703ae Allow escape_string_url from escape_string with wcstring
This was an oversight.
2018-05-28 12:10:39 +02:00
Fabian Homborg
338b40bb43 Trust the passed size in escape_string_script
This allows it to handle NULs.
2018-05-28 12:10:39 +02:00
ridiculousfish
ba69f8f71d Remove an unused variable 2018-05-27 15:46:30 -07:00
ridiculousfish
5492a16719 Clean up some env.cpp export code
Adopt some modern practices.
2018-05-27 15:45:30 -07:00
Swayam Raina
eb0539af60 Don't update CMD_DURATION if no command is requested
Fixes issue #4926
2018-05-27 11:37:36 -07:00
Luca Weiss
c1af560753 pacman: Recognize *.pkg.tar as valid package extension (#5005)
* pacman: Recognize *.pkg.tar as valid package extension
2018-05-26 15:41:46 -07:00
Mahmoud Al-Qudsi
b7db397f61 Fix zfs completions under FreeBSD
Under FreeBSD, as annoying as it is, switches must directly follow the
command or subcommand in question, and cannot come after actual payload
argument. Calling `zpool get all -H` instead of `zpool get -H all`
caused error messages to be spewed to the console under FreeBSD when
simply completing `zfs <TAB>`, this should fix that. The change should
also be compatible with other operating systems (namely Linux) that
don't have this requirement, as they (generally) allow arguments to come
before _or_ after the primary non-switch argument (though I do not have
access to a zfs-enabled Linux machine to test this).
2018-05-26 12:20:04 -05:00
Mahmoud Al-Qudsi
46bd0e66b6 fixup! Clean up completions a little bit
Reverts some changes that broke sudo completions, and adds comments
clarifying the purpose behind sudo completions.

Closes #5004.
2018-05-22 17:44:52 -05:00
Mahmoud Al-Qudsi
6401906288 Fix missing -- in string match in __fish_complete_suffix
Caused completion to fail when current token begins with -
2018-05-22 09:59:16 -05:00
ridiculousfish
1b3154e50e Add fish_feature_flags.cpp to Xcode project
Fixes #4998
2018-05-21 21:53:01 -07:00
Mahmoud Al-Qudsi
7d33372d20 Fix __fish_complete_suffix behavior per __fish_complete_directories test 2018-05-20 14:35:52 -05:00
Mahmoud Al-Qudsi
0a337a9d8e Clean up completions a little bit 2018-05-20 14:07:56 -05:00
Mahmoud Al-Qudsi
fd4b3f2c26 Fix __fish_complete_directories test failure
The `sort -u` was applied only conditionally in __fish_complete_suffix,
now applied universally at the final step.
2018-05-20 13:50:28 -05:00
Mahmoud Al-Qudsi
4be4932786 Fix unzip completions directory completion 2018-05-20 12:33:41 -05:00
Mahmoud Al-Qudsi
beac145e75 Support expansions in directory completions as well
Also fixes some issues with duplicate results in __fish_complete_suffix.
2018-05-20 12:30:07 -05:00
Mahmoud Al-Qudsi
5bd121bd6d Fix unzip completions for non-Linux platforms 2018-05-20 12:04:22 -05:00
Alexander Skwar
9401d3a6d5 Fix fish-shell issue #4996: open -a works now on non-english installs 2018-05-20 21:14:10 +08:00
Alexander Skwar
e6aacd6167 Fix fish-shell issue #4993 - support pathname completion for open -a command. 2018-05-20 21:14:10 +08:00
Mahmoud Al-Qudsi
9ddba0116f Add completions for unzip 2018-05-20 01:22:16 -05:00
Mahmoud Al-Qudsi
ec14507723 Add function to retrieve first token
This should probably be updated to use argparse at some point?
2018-05-20 01:21:03 -05:00
Mahmoud Al-Qudsi
332e17e8e8 Support [*{}~$] in completions with __fish_complete_suffix
Previously, trying to complete a token with any of these
expansion-related characters would cause the completion to return no
results, as it would emit expanded values which weren't matched by the
autocompleter.
2018-05-20 00:38:17 -05:00
Mahmoud Al-Qudsi
4974ecfc32 Block pseudo/meta arguments from ./configure completions
Also finishes faster.
2018-05-17 23:36:56 -05:00
Mahmoud Al-Qudsi
4b78c92652 Optimize structure/layout of __fish_print_packages
Move XDG_CACHE_HOME logic below package providers that don't use the
cache.
2018-05-17 22:21:19 -05:00
Mahmoud Al-Qudsi
1c4940c04c Make sudo completions _much_ smarter
Now dynamically generating completions for the target of the `sudo`
command, where possible.
2018-05-17 20:19:31 -05:00