Commit Graph

8643 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
144af5116a Allow functions -e completions to complete hidden __fish functions
...but only if the user has started their function name argument with an
underscore.
2018-06-27 14:42:42 -05:00
Mahmoud Al-Qudsi
092307d4c0 Include whatis description for kernel modules in kldload completions
Using `__fish_whatis` based on a heuristic to make sure completions are
timely available.
2018-06-27 14:38:51 -05:00
Mahmoud Al-Qudsi
121c70cf39 Add completions for FreeBSD's kldunload
Lists currently loaded kernel modules as valid completions, and obtains
a description via the newly minted `__fish_whatis` if available.
2018-06-27 14:14:40 -05:00
Mahmoud Al-Qudsi
948b9d2ab8 Add __fish_whatis helper function/wrapper for whatis
Executes `whatis` safely, returns at most one line, and strips the name
of the command from the start of line, returning a value fit for use as
the description parameter for a completion argument value.
2018-06-27 14:14:40 -05:00
Dale Eidd
8e49229d8f Fix & improve ssh_config Include directive for hostname printing
Fixes
- Use the actual path when skipping unusable paths to fix all Include
  directives being skipped when there is no ~/.ssh directory
- Prevent "No matches for wildcard" message

Improvements
- Skip paths that are directories since we only want files
- Remove `cd` as it is not needed
2018-06-27 14:07:11 +02:00
Mahmoud Al-Qudsi
49bfc4f000 fixup! Fix __fish_complete_suffix behavior for paths with literal . 2018-06-25 20:59:24 -05:00
Mahmoud Al-Qudsi
72d80c3d91 Fix __fish_complete_suffix behavior for paths with literal .
__fish_complete_suffix assumed that the only literal . in a path
would be the . before an extension, and stripped accordingly. This
behavior has been there for a long time, but broke many things
including completion of relative paths and completion of paths with
a literal . in a directory name.

__fish_complete_suffix does not just complete extensions (or at the
very least, it no longer does just that) but rather any suffix, so
isolating the path name without the extension was unnecessary in all
cases.
2018-06-25 13:54:10 -05:00
Fabian Homborg
cbdd347ec6 Changelog range expansion change, expand docs 2018-06-25 17:57:06 +02:00
Fabian Homborg
81a987c39c Fix range expansion with negative ends
If just one of the range ends is negative, this now forces direction away from it.

I.e. if the beginning is negative, we go in reverse.
If the end is negative, we go forwards.

This fixes cases like

    $var[2..-1]

if $var only has one element.
2018-06-25 17:52:56 +02:00
ridiculousfish
5692adbdf6 Teach fish_wcwidth about variation selectors
System wcwidth() misreports variation selectors as width 1. Special
case these to width -1 (unprintable).

See #2652
2018-06-23 16:40:25 -07:00
Sam Yu
9470f8a05b Fix cut completion (#5069) 2018-06-23 15:30:31 -07:00
ridiculousfish
e812b609f9 Update set man page to clarify scoping rules
"When an exported variable goes out of scope, it is unexported."

As requested in #5064
2018-06-23 15:18:38 -07:00
ridiculousfish
44bae29039 Add a debug_escape function
This function for debugging makes it easier to understand what special
characters are present in a string.
2018-06-23 13:15:32 -07:00
zhustec
f025607c11 Competion: add missing list-timers for systemctl.fish 2018-06-21 20:10:14 +02:00
Mahmoud Al-Qudsi
fa00183e5f Fix and optimize kldload completions
I'm not sure what was wrong with the old syntax, but I needed to switch
the outer quotes to ' and the inner quotes to " in order for the
completions to work when they weren't explicitly sourced.

Additionally, realized that the overload for __fish_complete_suffix can
be used to get the filtered list of kernel modules from /boot/kernel in
the initial run.
2018-06-19 00:10:40 -05:00
Mahmoud Al-Qudsi
4d909b1c19 Add partial completions for curl, supporting @file syntax
Allows the most painful of curl's arguments to be completed by fish by
restoring file-based completions for paths prefixed with `@` (which are
typically used after parameters like --data).
2018-06-18 23:56:22 -05:00
Mahmoud Al-Qudsi
6e36b20e42 Optimize __fish_complete_suffix and fix duplicate listings
With a blank $suff (i.e. complete all files), __fish_complete_suffix
returned directories twice, once with the trailing `/` and once without.
This fixes that, and additionally speeds up the code by no longer
shelling out to `sort -u` as we no longer rely on brace expansion to
enumerate directories and files simultaneously.

In general, this behavior would occur when a directory exists that
matches the suffix search pattern (so a dir named 'foo.bar' with a
search pattern '.bar' would return 'foo.bar' twice).

Runtime has dropped from ~22ms to ~8ms on my machine, while also
returning more correct results.
2018-06-18 23:55:18 -05:00
Mahmoud Al-Qudsi
5061f1666b Add completions for FreeBSD's kldload 2018-06-18 21:01:05 -05:00
Mahmoud Al-Qudsi
1ab9fe663f [cmake] Add flags for different build types and set default value
Default to RelWithDebInfo (-O2 -g) if no custom CMAKE_BUILD_TYPE is
defined. Also add flags for use with CMAKE_BUILD_TYPEs Debug, Release,
and RelWithDebInfo.
2018-06-18 00:34:31 -05:00
Mahmoud Al-Qudsi
cda18be6b4 fixup! Replace \e with \x1B, as the former is a gcc extension 2018-06-18 00:34:31 -05:00
Mahmoud Al-Qudsi
27cd74e16c Fix warning about extra ';' being ignored
It is both present at the end of the #define and explicitly included
after the define is called in the main code, leading to an expansion of
`;;`.
2018-06-18 00:05:31 -05:00
Mahmoud Al-Qudsi
dcced5f1bc Replace \e with \x1B, as the former is a gcc extension
While supported by gcc and clang, \e is a gcc-specific extension and not
formally defined in the C or C++ standards.

See [0] for a list of valid escapes.

[0]: https://stackoverflow.com/a/10220539/17027
2018-06-18 00:01:47 -05:00
Mahmoud Al-Qudsi
d16d463e0d Silence EACCES errors upon setpgid after posix_spawn()
We've tried numerous approaches to mitigate the race condition between
`posix_spawn` and the `setpgid` call, but unfortunately due to the flags
we pass to `posix_spawn`, it (rarely? never?) results in `vfork()` being
used, which means it is never executed atomically. Since it is executed
out-of-band, we must manually call `setpgid` in case `posix_spawn`
hasn't gotten around to doing that yet, but in the event that it has, an
EACCES error can be returned.

Closes #4884. Closes #4715. See also #4778.
2018-06-17 22:32:52 -05:00
Mahmoud Al-Qudsi
072974ec5c Fix service completions on non-FreeBSD platforms
I never realized script-local variables set after the function
definition do not keep their value when the function is executed later
in the file.
2018-06-17 22:03:04 -05:00
Mahmoud Al-Qudsi
31745d29ab Refactor service completions to drop eval usage under FreeBSD 2018-06-17 21:49:39 -05:00
Mahmoud Al-Qudsi
8f166cbb2a Prevent fish from crashing if non-essential terminfo strings not found
On systems where the terminfo for TERM does not contain a string for
attributes such as enter_underline_mode, etc. fish was crashing with a
fatal error message and a note to email the developers.

These are non-essential text attribute changes and should not trigger
such a failure.
2018-06-17 20:59:34 -05:00
Mahmoud Al-Qudsi
a6d64c1086 Handle odd return codes for waccess(..) in src/path.cpp under Solaris 2018-06-17 19:58:20 -05:00
ridiculousfish
2443ea92c3 Eliminate a common subexpression 2018-06-16 11:43:52 -07:00
ridiculousfish
e6737d5775 Use a std::move in expand_cmdsubst
Save an unnecessary allocation.
2018-06-16 11:40:59 -07:00
Fabian Homborg
fa665bd3c8 [completions/git] Remove unnecessary helper function 2018-06-15 15:40:04 +02:00
Fabian Homborg
7b86062720 [completions/git] Allow relative paths for files
This is _ugly_ because it is implemented for both status --porcelain
formats, but it is both fast and accurate.
2018-06-15 15:40:04 +02:00
Mahmoud Al-Qudsi
f25a1d720a Add brief note on setting feature flags to CHANGELOG.md 2018-06-14 17:34:52 -05:00
Sam Yu
76749468aa Fix sudo completion
* fix command under sudo get sudo's option completions
* rewrite completion of command under sudo with argparse
2018-06-14 23:05:06 +02:00
Fabian Homborg
64ff2f7895 Read conf.d snippets as last part of share/config.fish
This allows snippets to use everything that is defined in config.fish,
which is our _base_ initialization.

Among other things, it enables snippets to use $PATH as it will appear
in the user's config.fish, or even to change $PATH.

Also, this is how it was in 2.7.1 and before (with the small change
that abbrs were upgraded after).
2018-06-14 22:55:52 +02:00
Gustaf Johansson
1270bb265f completions: [go] Lookup pkgs from GOPATH
As defined in the `go help packages`:
  Many commands apply to a set of packages:
    go action [packages]
  Usually, [packages] is a list of import paths.

This patch introduces automatic lookup of said packages from GOPATH
using `go list`, and provides them as options go subcmds.
2018-06-13 15:33:29 +02:00
Mahmoud Al-Qudsi
35a7e1ef0e Add intelligent service-specific completions under FreeBSD 2018-06-12 19:24:18 -05:00
Mahmoud Al-Qudsi
eca4273f77 fixup! Add OS check to pkg completions 2018-06-07 13:42:53 -05:00
Mahmoud Al-Qudsi
e8b6705067 Add OS check to pkg completions 2018-06-07 12:22:47 -05:00
Mahmoud Al-Qudsi
c133cb2f1a Log addition of serve completions 2018-06-05 13:35:37 -05:00
Twinkle
3b1806a904 Add completions for serve
See: https://github.com/zeit/serve
2018-06-05 16:36:22 +02:00
Sabine Maennel
b347b44d9e added 2 sections to the tutorial
Added 2 sections to the tutorial:
- getting started
- switching to fish

This fixes issue #475
2018-06-04 20:39:08 -07:00
Mahmoud Al-Qudsi
086d088e1b Fix scp completions to support bidirectional transfer
Also hardcode standard /bin/ls to avoid issues with `ls` aliases on the
target, and inherit the (improved) list of remotes from `ssh`.
2018-06-04 07:32:21 -05:00
Mahmoud Al-Qudsi
c8c3265cb8 Fix completions for service
I'm not sure what was up with the old completions,
`$__fish_service_commands` is not set anywhere and completions for the
command (not the service) were not being generated on my machine.
2018-06-04 07:32:21 -05:00
Mahmoud Al-Qudsi
fd14e459cf Add completions for xsv 2018-06-04 07:32:21 -05:00
Mahmoud Al-Qudsi
f6a1bc1489 Fix unzip completions for non Info-ZIP versions
macOS and (AFAICT) most Linux distributions ship with the Info-ZIP
version of unzip, which has the `unzip -h` flag; but other
implementations of unzip do not necessarily have it (i.e. FreeBSD).

`unzip` under FreeBSD does not support `unzip -h`. Under both Linux and
FreeBSD, `unzip -v` presents the list of options, though. Using this
instead of `unzip -h` to detect the Debian-patched version of the
Info-ZIP unzip program.
2018-06-03 14:57:11 -05:00
Fabian Homborg
8de5af5f9e Fix off-by-one in complete_cmd_desc
The substring constructor (string(str, pos)) includes pos, so we need
to add one. Also be careful not to go over the length again.
2018-06-03 19:17:02 +02:00
kewl fft
ebc5e18956 add xclip support for clipboard copy and paste functions 2018-06-03 00:39:07 +02:00
Mahmoud Al-Qudsi
56198818b0 Work around compiler warning regarding C++17 name mangling
[9/13] Building CXX object CMakeFiles/fishlib.dir/src/builtin_string.cpp.o
../src/builtin_string.cpp:1221:12: warning: mangled name of 'string_transform' will change in C++17 due to non-throwing exception specification in function signature [-Wc++17-compat-mangling]
static int string_transform(parser_t &parser, io_streams_t &streams, int argc, wchar_t **argv, decltype(std::towlower) func) {
           ^
1 warning generated.
2018-06-01 22:53:33 -05:00
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