Commit Graph

1387 Commits

Author SHA1 Message Date
Fabian Homborg
fc51c156cb __fish_config_interactive: Use variable-as-command
This removes a use of eval, and some duplication.
2018-10-21 15:31:49 +02:00
Fabian Homborg
09f77a355f __fish_config_interactive: Remove unused $configdir 2018-10-21 15:31:12 +02:00
Fabian Homborg
3b2be9009e funcsave: Use mkdir -p
It's in POSIX, and simplifies stuff.
2018-10-21 15:24:38 +02:00
Mahmoud Al-Qudsi
c02bf2548f Close the completions pager (if it's open) on ctrl+c
If you're using the old binding that only clears the commandline and
doesn't preserve its contents and start a new line, you can use

```fish
bind \cc "commandline -f cancel; commandline ''"
```

instead.

Closes #4298.
2018-10-15 13:34:34 -05:00
Fabian Homborg
d22446f651 Let funced handle empty $EDITOR
For some weird reason we only used $editor if it wasn't empty, but
then failed to fail if it was.

This will now print an error and use fish, just like if the $EDITOR
value is invalid in any other way.

Fixes #5257.
2018-10-15 10:14:59 +02:00
ridiculousfish
3e4bdf51d4 Teach hg prompt to use pwd -P
The hg prompt walks up the directory hierarchy to decide if we are in a
repo subdirectory. Because hg is an external command, it resolves symlinks.
Switch to using pwd -P so hg and fish will have the same view of the hg repo.

Based on comment:
https://github.com/fish-shell/fish-shell/pull/5190#issuecomment-421912360
2018-10-06 17:03:18 -07:00
Fabian Homborg
444f9f8715 Add separation of "preset" bindings
This allows for marking certain bindings as part of a preset, which allows us to

- only erase those when switching presets
- go back to the preset binding when erasing a user binding
- only show user customization if requested
- make bare bind statements in config.fish work (!!!11elf!!!)

Fixes #5191.
Fixes #3699.
2018-09-30 16:54:56 +02:00
Mahmoud Al-Qudsi
f15dd314e0 Revert "Add hash function for compatibility with sh/bash"
This reverts commit dbd228cc75.
2018-09-27 17:21:12 -05:00
Mahmoud Al-Qudsi
dbd228cc75 Add hash function for compatibility with sh/bash 2018-09-26 12:43:40 -05:00
David Adam
f823611c2e Move abbr_old to __fish_abbr_old
This is an internal function that should not be used except by the migration process.
2018-09-21 09:25:16 +08:00
Curtis Jiang
06e5194092 add OpenWrt and opkg support
Signed-off-by: Curtis Jiang <jqqqqqqqqqq@qq.com>
2018-09-04 01:47:30 -07:00
Chris
1d68b52cbc Add till/repeat/reverse jump bindings
- Add support for:
  - Jumping to the character before a target.
  - Repeating the previous jump (same direction, same precision).
  - Repeating the previous jump in the reverse order.
- Enhance vi bindings.
2018-08-18 14:42:29 -07:00
Mahmoud Al-Qudsi
e8a35bfaa8 Prevent errors in __fish_describe_command when apropos isn't installed
__fish_describe_command now bails early if `type -q apropos` returns a
non-zero exit code.
2018-08-16 13:20:04 -05:00
Riccardo Azzolini
c79db8ecf7 cdh: Only replace home directory with ~ at the start of paths 2018-08-13 18:24:42 +02:00
Mahmoud Al-Qudsi
46b65a550f Reverse order of files and directories in __fish_complete_suffix output
Ordering of directories above files was introduced in a recent change to
the same script. By default it does not matter as completions are sorted
by fish internally, but this allows the use of `-k` to sort files before
directories (or piped to `sort -r` for vice-versa).
2018-07-30 14:31:47 -05:00
Mahmoud Al-Qudsi
392cdd4338 Show a meaningful description of packages in __fish_print_packages
Use `apt-cache show` instead of `apt-cache packagenames` to efficiently
print package names and a brief description instead of the placeholder
(localized) "Package" text that was previously printed. This applies to
both available and installed packages (for inistall and remove operations,
respectively).

TODO: update `__fish_print_packages` for non-debian platforms to do the
same.
2018-07-28 17:44:17 -05:00
Mahmoud Al-Qudsi
1ca58984bf [debian] Exclude packages with dpkg state 'deinstall' from installed list
When listing packages already installed (e.g. for use with `apt remove
...`), do not consider packages return by `dpkg --get-selections` with
state 'deinstall'.

Previously the `string replace` pattern was matching both 'install' and
'deinstall' packages.
2018-07-28 17:44:17 -05:00
raichoo
06cd4dc66f vi key bindings: fix "*y 2018-07-23 16:22:12 +02:00
James Lee
e26bdff487 Improve eopkg completions by using the --installed flag (#5089)
Utilized the `--install` flag added in commit #8c09d6e.

Limit `eopkg remove/autoremove/check ...` completions to installed packages.
Limit `eopkg install/upgrade/info ...` completions to available packages.
2018-07-09 23:21:44 -07:00
ridiculousfish
6a6ffe68cb Make __fish_describe_command stop barfing on /
Prior to this fix, __fish_describe_command would error if the
input contained any special characters, because it would be interpolated
into a regex. Hack in a guard to do nothing if the input contains
anything other than [a-zA-Z0-9_ ]
2018-07-09 23:13:53 -07:00
Mahmoud Al-Qudsi
8c09d6e063 Limit apt remove ... completions to installed packages only
Added a new flag `--installed` via `argparse` to `__fish_print_packages`
which indicates that only installed packages should be listed.

TODO: Other non-debian/apt platforms should take advantage of this flag/
behavior as well.
2018-07-02 11:43:18 -05:00
David Adam
a6031c42bf __fish_config_interactive: make default colours the same as web_config's default 2018-06-29 21:49:35 +08: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
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
kewl fft
ebc5e18956 add xclip support for clipboard copy and paste functions 2018-06-03 00:39:07 +02: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
0f4126c115 Silence winch handler
Fixes #4876.
2018-05-29 18:40:29 +02: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
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
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
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
Fabian Homborg
560985cdee Remove test invocations with implicit -n tests
This is something we would like to remove - #2037.
2018-05-17 13:24:26 +02:00
Mahmoud Al-Qudsi
5f1168002e Complete current commandline token with __fish_complete_directories if
Akin to __fish_complete_suffix, __fish_complete_directories now attempts
to complete the current commandline token if no token is explicitly
passed in as an argument.
2018-05-12 14:06:03 -05:00
Fabian Homborg
feb6e9c90b Make DEFAULT_PROMPT and DEFAULT_TITLE work without functions
The prompt is a fallback that is overridden via a function file
anyway.

Do that with the title as well, so we can use just builtins.

This removes error messages when $fish_function_path is borked.
2018-05-12 13:53:45 +02:00
Fabian Homborg
ef66b99721 Remove some dead code
This was a remnant from us checking `string length`. Now that we check
if the variable is set, this code does nothing.
2018-05-12 13:48:32 +02:00
Fabian Homborg
a4f55d95d4 Detect GNU make via "--version"
Turns out that `make -pn` actually takes a while - about 300ms on
fish's makefile.

That's quite a bit of time just to throw away the output and use the
exit code.

So we just check for "GNU" in the version string.

It would be nice to just _do_ the completion and fall back on the
BSD-style if it doesn't work, but that is tricky to do with the pipe
to `awk` - the awk expression actually does not fail if `make` does
not print output.

And I don't know enough about awk to change that.
2018-05-11 16:16:14 +02:00
Fabian Homborg
88b688c544 [hg prompt] Use hg status -q
For some reason, `hg status -q` prints the exact same output as `hg
status`, but about 20% faster.
2018-05-08 22:52:16 +02:00
Mahmoud Al-Qudsi
6dc74d3b6c New helper functions __fish_is_first_arg and __fish_prev_arg_in
For usage in completion scripts.

Unlike `__fish_is_first_token` (which is probably not correctly named),
`__fish_is_first_arg` returns true regardless of whether existing tokens start with `-`
or not, to be used when an arg cannot be used with any other argument.

`__fish_prev_arg_in` is similar to `__fish_seen_...` but it explicitly
tests the preceding token only, for arguments that take only a single
parameter.
2018-05-06 18:55:12 -05:00
Fabian Homborg
f533189a28 [default bindings] Bind \e\b as well
As it turns out, for some terminals backspace is \b but only when
preceded by \e.

All this makes about as much sense as the english language.

Fixes #4955.
2018-05-04 12:28:20 +02:00
Fabian Homborg
b5d6c1102e [git prompt] Only set chars/colors when necessary
Either on start or when something has changed.

This saves about 8ms on every call except the first.
2018-05-04 12:28:20 +02:00
Fabian Homborg
2a616698b3 Just define : compatibility function directly
There really is no need for that indirection.
2018-05-03 12:42:09 +02:00
Fabian Homborg
e02e485cc6 command-not-found: Split os-release' stuff on space
ID_LIKE is defined as a space-separated list and ID can't have spaces.

Fixes it for "openSUSE Tumblewee".
2018-05-01 19:28:37 +02:00
Mahmoud Al-Qudsi
4962244161 Fix __fish_complete_suffix for arguments starting with './'
The previous completion generation was broken for several reasons:
* ./foo would break detection of suffix due to the leading . being
  interpreted an extension marker,
* ./foo would be completed as foo, which would be excluded from
  matching inrcomplete.cpp
2018-04-29 11:20:07 -05:00
Andrew Lobos
f479e4a830 Remove caret redirection from tar completion 2018-04-28 18:13:24 +02:00
Fabian Homborg
e598cb235a Fix case matching literal ?
Fixes #4896.
2018-04-25 23:37:39 +02:00
Fabian Homborg
2fd15e7c6c Silence xsel errors
Fixes #4923.

[ci skip]
2018-04-25 23:11:40 +02:00
Wilke Schwiedop
02ae926c8e remove sed (and awk) from gentoo-portage completions 2018-04-25 15:45:12 +02:00
Wilke Schwiedop
70c80c9d0e fix and remove sed from __fish_print_xrandr_modes.fish 2018-04-25 15:45:12 +02:00
Wilke Schwiedop
374772e539 remove sed from __fish_print_xrandr_outputs.fish 2018-04-25 15:45:12 +02:00
Wilke Schwiedop
83637e2178 remove sed from __fish_complete_groups.fish 2018-04-25 15:45:12 +02:00
Wilke Schwiedop
4d864aea1c remove sed from __fish_print_addresses.fish 2018-04-25 15:45:12 +02:00
Mahmoud Al-Qudsi
7db0958804 Add __fish_can_complete_switches & __fish_should_complete_switches
To be used by completions to directly determine whether it is either
possible or preferable to complete a switch (instead of a subcommand),
(presuming that switches must come before subcommands).

* __fish_can_complete_switches: we are in a position where a switch may
be placed.
* __fish_should_complete_switches: we're in a position to accept a
switch and the current token starts with `-` so we have no choice but
to do so.
2018-04-19 18:09:10 -05:00
Sam Yu
408cdba1be Update tar completion
* Fix gzip archive files completion
* Let tar auto detect file type
2018-04-19 14:27:23 +02:00
Mahmoud Al-Qudsi
9d9afd8264 Speed up ./configure completion by not running ./configure --help
Instead, attempt to extract the message that _would_ be displayed on
execution of `./configure --help` by relying on some markers present in
autoconf-generated configure files.

As measured with 'hyperfine' on a laptop running in reduced frequency
power savings mode, `fish -c "__fish_parse_configure ./configure"`
runtime dropped from ~1.25s to ~0.8ms, which is inline with the
previously observed ~350ms execution time for `./configure --help`.
fish's own startup time is approximately 75ms before parsing begins.

Still very slow, but much better.
2018-04-18 15:40:52 -05:00
Mahmoud Al-Qudsi
6c5e5d35a9 Add real completions for ./configure
This relies on the new `read --line/-L` support as an entire parser for
the output of `./configure --help`  was written in fishscript. Also
doesn't work without 72f32e6d8a7905b064680ec4b578c41dea62bf84.

The completion script is slow... a function of both the autotools
configure script itself being written in a shell script combined with a
fishscript output parser.

fish's own `./configure --help` takes around 350ms to execute, while
`__fish_parse_configure ./configure` (which runs that behind the scenes)
takes around 660ms to run, all-in-all - a not insignificant overhead.

Output can be cached (based off of ./configure hash or mtime) in the
future if this is a big deal.
2018-04-17 21:35:51 -05:00
Wilke Schwiedop
8ae9b716a0 fix 'grep ... | sed' 2018-04-09 01:09:49 +02:00
Thom Chiovoloni
25169a44ed Add alias -s/--save, which saves the alias.
Also updates the `alias` documentation to mention the `-h`/`--help` option,
which was previously undocumented.
2018-04-09 01:08:56 +02:00
George Christou
c6e7b7ef00 prompt: Show untracked Git files relative to root directory (#4874)
* prompt/git: Match untracked files relative to root directory

* prompt/git: Move untracked file logic to a separate function
2018-04-09 01:05:03 +02:00
Mahmoud Al-Qudsi
366933413b Fix string match argument parsing in __fish_seen_argument 2018-04-03 21:13:11 -05:00
Mahmoud Al-Qudsi
c492d03f51 Overhaul completions for set and add new completions for set -e
Now the description includes the variable scope, `set [-e] -[Ugl]`
completions only provide variables matching that scope, and completions
that shouldn't be modified are hidden from the user. Completions that
are often modified but rarely unset (`fish_*` variables) are omitted
from `set -e` completions.

A new helper function `__fish_seen_argument` has been added that makes
it easy to only provied completions for a specific flag.
2018-04-03 14:42:26 -05:00
Mahmoud Al-Qudsi
99ecaec175 Use system web browser under WSL
Launch `cmd.exe /c "start URL"` under WSL for both `fish_config` and
`help`. This works around #4299 but does not address the underlying
issue (#1132).
2018-04-02 18:36:14 -05:00
David Adam
5c56765d12 hg prompt: fix infinite loop due to incorrect scoping
4b079e16e5 fixed some unintended behaviour
which the hg prompt was apparently relying upon, producing an infinite
loop whenever called.
2018-04-02 21:24:52 +08:00
ridiculousfish
ca13e816ce Make fish more resilient to empty key bindings
If fish_key_bindings gets set to empty, fish will become unusable.
In this case reset it to fish_default_key_bindings.
2018-04-01 16:11:12 -07:00
Peter Ammon
7659554dea Remove use of caret redirection from share/*
This removes the use of caret redirections from share/completions
and share/functions, in preparation for dropping support in fish.
2018-04-01 13:42:38 -07:00
Mahmoud Al-Qudsi
6d80ab8d74 Rename $pid (née %self) to $fish_pid 2018-03-24 11:54:27 -05:00
Daniel Beckwith
7583d57b63 Add Makefile --file detection to completion 2018-03-23 22:45:40 -07:00
Wilke Schwiedop
44e2c28255 revisit gentoo-related completions (#4758)
* revisit gentoo-related completions

- add completion for emaint
- improve completion for emerge
  still incomplete, but an impovement regardless
- improve completion for equery
- add gentoo/portage-related auxiliary functions

* fix spelling

* remove trailing '.'

* remove old '_' invocation and capitalize descriptions

* add number-completion

* remove trailing '.'

* shorter descriptions

* replace sed with fish-builtin and drop deduplication

* batch change capitalization (lower case)

* indent equery descriptions

* batch change capitalization (upper case)
2018-03-23 19:42:30 +01:00
Mahmoud Al-Qudsi
007ae0b15e Add colon.fish for : compatibility with sh and bash
no-op function for compatibility with sh, bash, and others.
Often used to insert a comment into a chain of commands without having
it eat up the remainder of the line, handy in Makefiles.
2018-03-14 17:41:09 -05:00
Mahmoud Al-Qudsi
c51abd04ff Clean up $__fish_*dir variable names
Closes #4429
2018-03-12 08:34:20 -05:00
Mahmoud Al-Qudsi
b42b562d06 Revert prompt_hostname to short hostname only
Hat-tip: @zx8. Closes #4804.
2018-03-12 08:24:42 -05:00
Mahmoud Al-Qudsi
18a9aa58cd Add binding for MSFT/WSL paste escape sequence 2018-03-10 10:57:32 -06:00
Mahmoud Al-Qudsi
b3ec069401 Add missing $argv injection in fish_default_key_bindings.fish
These have to be present in all the default rules so that any errors can
be silenced at startup (and so additional arguments can be passed in).
2018-03-10 10:54:29 -06:00
Mahmoud Al-Qudsi
410f6fbd44 Switch prompt_hostname over to $hostname 2018-03-09 15:05:43 -06:00
Mahmoud Al-Qudsi
2a266c4d48 Update fish's only usage of read -s to use read --shell instead 2018-03-09 11:55:12 -06:00
Mahmoud Al-Qudsi
a6f79dcca8 Implement -s for fish_vi_key_bindings
In similar vein to how fish_default_key_bindings works, parameters
passed to the function are automatically passed to bind upstream.
Additionally, -s is automatically added if no parameters had been
specified to prevent startup error messages. See 46d1334.

Closes #4494
2018-03-09 09:29:25 -06:00
Mahmoud Al-Qudsi
b236ab6e5d Update %self references with $pid instead 2018-03-09 03:56:19 -06:00
Cesar Andreu
3792fb086a Fix man autocomplete when a section is set 2018-03-06 20:50:20 +01:00
Fabian Homborg
93209ab053 Fix termux path
This is "/data/data/com.termux/files/usr/etc", not just ".../files/etc".
2018-03-06 17:55:25 +01:00
Fabian Homborg
e7f8e58be9 Add more ssh known_hosts paths
Fixes #4759.
2018-03-06 15:27:34 +01:00
Mahmoud Al-Qudsi
225f748f79 Add __fish_parent_directories helper function for completions
Can be used to retrieve a list of parent paths, useful for searching
ancestors recursively via their absolute paths. Paths are returned from
deepest to shallowest, starting from the path passed in. Paths are not
validated for performance reasons. (Usually the input to
__fish_parent_directories would be (pwd) or (dir $file).)
2018-03-05 08:25:25 -06:00
George Christou
6f1ae79a13 alias: Fix string args being parsed as options 2018-02-28 11:17:00 +01:00
ridiculousfish
973533e374 Teach alias about wrap argument injection
Update the alias function to pass arguments to 'wraps'. For example
alias gco='git checkout' now works like it ought to.
2018-02-27 14:12:44 -08:00
Kevin Konrad
8536a6825f add completion for MacPorts 2018-02-24 23:32:25 +08:00
Fabian Homborg
f7adaeb97b Use the new fish_exit event 2018-02-19 20:21:02 +01:00
ridiculousfish
c4a12f90c1 Bind pager-toggle-search to control-s by default. 2018-01-30 09:58:08 -08:00
Benoit Hamon
c92bb703dc add few bindings for vi mode 2018-01-26 18:32:03 +01:00
Ivan Trubach
6066e243e0 Fixed suspend --force conditions 2018-01-19 11:23:55 +01:00
Thom Chiovoloni
7b88187310 Add ability to autosave functions at the end of funced 2018-01-18 18:03:52 +01:00
Thom Chiovoloni
42fa841573 Fix #4480 by using a temporary file with a redirect to the correct location. 2018-01-16 18:38:20 +01:00
Thom Chiovoloni
7dae40a240 Revert "Work around OS X issue with dropped #fragment in launched URLs"
This reverts commit 80b658e247.
2018-01-16 18:38:20 +01:00
Fabian Homborg
66f181499b Strip quotes in __fish_complete_suffix
Fixes #4481.
2018-01-01 13:18:40 +01:00
Fabian Homborg
4096a7fda9 Revert "Fix "Unknown argument -s" error in fish_vi_key_bindings"
Unfortunately this made tests on travis fail - for some reason I still need to figure out.

This reverts commit 5acbd32c2e.
2017-12-22 00:44:18 +01:00
Yurizal Susanto
94ff789c4b Add eopkg completion support (#4600)
* Add eopkg support

Add support for eopkg in __fish_print_packages function, and
add new completion eopkg.fish in share/completions

* Sorry for the empty file

* Sorry for the empty file again

* Use builtin function for checking subcommand and options

* Fix description

* Use string function to replace grep and cut

* Add completion for search command
2017-12-21 16:43:21 +01:00
David Guyot
dcf9ce6fc5 Added completions/translations for zfs and zpool 2017-12-21 16:39:06 +01:00
Fabian Homborg
5acbd32c2e Fix "Unknown argument -s" error in fish_vi_key_bindings
This was caused by it prepending "-s" to argv always,
and later checking $argv[1].

As it turns out, that is kinda superfluous, so we can just add "-s" to
the `bind` calls.

Also adjust the tests so the vi-bindings are enabled via the function,
which would have caught this.

Fixes #4494.
2017-12-21 16:17:21 +01:00
Fabian Homborg
4ca9953114 Skip unusable paths in __fish_print_hostnames
See
https://github.com/fish-shell/fish-shell/issues/4511#issuecomment-343022740.

This would try to `cd` to ~/.ssh even if it didn't exist. That's
clearly bogus.
2017-12-13 13:18:25 +01:00
Aaron Bieber
bfd2885279 add package parsing for OpenBSD 2017-12-12 19:18:53 +01:00
Aaron Bieber
440df37b41 parse *BSD interface names 2017-12-12 19:18:53 +01:00
Aaron Bieber
277cd30520 add ffs to known filesystems 2017-12-12 19:18:47 +01:00
Mahmoud Al-Qudsi
ae700c8707
Merge pull request #4581 from mqudsi/help_section_workaround
Work around OS X issue with dropped #fragment in launched URLs
2017-12-07 18:59:16 -06:00
ArkBriar
5faa425df1 fix #4521 (#4575) 2017-12-04 22:51:20 -08:00
Aaron Gyes
fa57565c42 Fix fish_opt --help showing nextd manpage. 2017-11-14 01:56:58 -08:00
WEBER Logan
11cebe9483 feat(share:git-prompt): be able to truncate the branch name with a defined max length 2017-11-13 10:57:42 +01:00
Judson
37e0fbb5e4 Paginating last command
Often, I want to paginate the command I just ran.

Easy enough to <up><alt-p>, but this patch saves a keystroke.
2017-11-01 07:35:26 +08:00
Fabian Homborg
720f4ad742 Also allow "sles" as OS-ID for command-not-found-handler
"Suse Linux Enterprise Server".

Fixes #4447.
2017-10-19 19:09:29 +02:00
Mahmoud Al-Qudsi
80b658e247 Work around OS X issue with dropped #fragment in launched URLs
The previous hack used to work around an OS X issue/bug where launching
a URL with a #fragment appended would drop the fragment by using
`osascript` does not seem to work any more. Append the section name as a
query string (in addition to, not instead of #section) and then use some
basic javascript appended to the user doc HTML template to parse that
and jump to the correct section (if the section was dropped).

Closes #4480
2017-10-18 12:11:20 -05:00
Fabian Homborg
d18b0be518 Revert "Fix cd completions if a directory exists in $CDPATH and $PWD"
That's not what happens - I had set CDPATH to start with ".".

See #4484.

This reverts commit 1af38d69a8.
2017-10-16 19:33:38 +02:00
Aaron Gyes
fb8ae04f80 Rename $FISH_VERSION back to the original $version.
Order is restored in the universe. Fixes #4414
2017-10-14 08:33:02 -07:00
Fabian Homborg
1af38d69a8 Fix cd completions if a directory exists in $CDPATH and $PWD
E.g. if "foo" is in CDPATH, and both "foo/bar" and "./bar" exist, `cd
bar` will go to ./bar.

The completions described "bar" as going to "foo/bar" ("CDPATH foo").

This fixes it by checking for ./bar's existence.

See #4475.
2017-10-13 18:32:36 +02:00
madblobfish
649e244092 fish_update_completions: error when python not found (#4454) 2017-10-12 06:00:50 -07:00
Mahmoud Al-Qudsi
46d1334f95 Silence bind errors in default key bindings
This silences binding errors due to keys not found in the current
termcap config in the default fish bindings.

Closes #4188, #4431, and obviates the original fix for #1155

It was necessary to re-implement builtin_bind as a class in order to
avoid passing around the options array from function to function and
as adding an opts parameter to `get_terminfo_sequence` would require
otps to be passed to all other builtin_bind_ functions so they could, in
turn, pass it to `get_terminfo_sequence`.
2017-10-03 11:20:17 +02:00
Aaron Gyes
1ef310c3a8 Fix export returning 1 on success
Fixes #4435
2017-10-01 01:11:17 -07:00
Fabian Homborg
281d468285 Rewrite systemctl completion with argparse
This

- Offers more candidates

- Is more reactive (it'll always incorporate "--state=" and "--type="

- Is faster (about 800ms to about 120ms)

- Needs fewer function files

All __fish_systemctl_* functions except __fish_systemctl_services have
been removed.
2017-09-29 20:07:18 +02:00
Mahmoud Al-Qudsi
338311af1e Install custom LSS script to /usr/local/share/fish on make install
Decided to move doc_src/fish.lss to share/lynx.lss, which just makes
more sense all around. Accordingly, now using {$__fish_datadir} instead
of {$__fish_help_dir} in help.fish.

Makefile now installs the custom lss on make install
2017-09-26 14:31:11 -05:00
Mahmoud Al-Qudsi
8b858f2fcc Use a custom Lynx style sheet (LSS file) to work around Lynx bug
Lynx uses a very naïve method of applying styles to HTML elements by
hashing the element type and the class name to generate a map of
hash:style. After the hash is calculated, Lynx does not go back and
check whether or not the actual string values match the LSS properties.

See the following links on the Links mailing list:
 * http://lists.gnu.org/archive/html/lynx-dev/2015-12/msg00037.html
 * http://lists.gnu.org/archive/html/lynx-dev/2015-12/msg00039.html

This patch copies the default Lynx stylesheet but removes highlighting
and other styles that would result in unreadable text (due to not enough
contrast with the background color), and if the `help` builtin detects
that the best web browser to use is Lynx, it instructs it to use this
modified stylesheet.
2017-09-26 13:44:19 -05:00
Mahmoud Al-Qudsi
2b425ad221 Don't use xdg-open if running in terminal mode (i.e. no Xorg)
If the $DISPLAY environment variable is not set, xdg-open should not be
used to load the web browser. Just because it is installed does not mean
that the user exclusively runs in an X session.

Needed for Lynx detection to work around #4170
2017-09-26 13:42:40 -05:00
Mahmoud Al-Qudsi
3b3bcc998e Speed up __fish_print_hostnames for faster completions
Thanks to @ThomasAH, as per #4378. Tested on many platforms (OS X,
FreeBSD, Linux, and Solaris). Works with IPv4 and IPv6 as well as
host names and loopback addresses.
2017-09-26 09:21:16 -05:00
Mahmoud Al-Qudsi
6513db35c1 Support colored ls output on Solaris 11
Closes #1223
2017-09-26 08:55:28 -05:00
oddwheel
a05bcc6a63 Suppress git prompt CRLF warnings noise
Drawing prompt in repo with text=auto attribute and mixed line endings in files was spawning crlf conversion warnings to terminal from unsilenced stderr of git diff
2017-09-22 18:57:36 +02:00
Aaron Gyes
25d83ed0d7 seq fallback speedup
Using `string match` instead of `grep -E` resulted in a 2x-3x speedup according
to $CMD_DURATION.
2017-09-22 00:30:26 -07:00
Kurtis Rader
67946b5509 Drop deprecated history search --with-time flag (#4403)
This flag was only documented for a few weeks before being renamed
`--show-time` and has been deprecated for a long time. Fish 3.0 is a good
opportunity to remove it.
2017-09-15 19:28:44 -07:00
Kurtis Rader
ee1d310651 Implement history search --reverse (#4375)
* Implement `history search --reverse`

It should be possible to have `history search` output ordered oldest to
newest like nearly every other shell including bash, ksh, zsh, and csh.
We can't make this the default because too many people expect the
current behavior. This simply makes it possible for people to define
their own abbreviations or functions that provide behavior they are
likely used to if they are transitioning to fish from another shell.

This also fixes a bug in the `history` function with respect to how it
handles the `-n` / `--max` flag.

Fixes #4354

* Fix comment for format_history_record()
2017-09-14 15:44:17 -07:00
David Adam
725febb669 Revert "convert popd and pushd to use argparse"
This reverts commit 05aae4764b.

Closes #4398.
2017-09-14 12:36:37 +08:00
ridiculousfish
a5fd0b317e Revert "Switch to bare vars in our math invocations"
This reverts commit bd18736ee5.

Bare variables should only be used in commands that must
manipulate the variable stack, such as `set`.
2017-09-09 23:35:47 -07:00
Fabian Homborg
b00daebec2 __fish_print_hostnames: Use string replace -f
Saves one `string match` invocation.

Also removes a useless-use-of-cat.

(cherry picked from commit 4437e8d8d6)
2017-09-07 16:30:17 +02:00
daniel-surename
ed475ab24b fix: git status in __fish_git_prompt_informative_status (#4365)
Added and staged files weren't shown in the prompt,
had a missing $ to denote variables
2017-08-29 23:50:27 -07:00
Kurtis Rader
bd18736ee5 Switch to bare vars in our math invocations
Using bare vars is more efficient because it makes the builtin `math`
expression cache more useful. That's because if you prefix each var with
a dollar-sign then the fish parser expands it before `math` is run.
Something like `math x + 1` can be cached since the expression is the
same each time it is run. But if you do `math $x + 1` and x==1 then you're
effectively executing `math 1 + 1`. And if x==2 the next time then you're
running `math 2 + 1`. Which makes the expression cache much less effective.
2017-08-24 12:38:10 -07:00
Kurtis Rader
d10decabda Make builtin math the default implementation
Remove our `math` function that wraps `bc`. Our math builtin is now good
enough that it can be the default implementation.

Another step in resolving #3157.
2017-08-23 17:32:49 -07:00
Kurtis Rader
6e02ec83d1 Fix typo in xdg-mime completion functions 2017-08-17 10:54:05 -07:00
MoritzKn
5eb0b34da1 Update xdg-mime helper
This will respect the `/usr/local/share/applications/` directory when
fetching mime infos.

Update xdg-mime helper to comply with the xdg spec.

This also makes sure __fish_print_xdg_applications_directories only prints
directories that exist.

Relevant specs:
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
https://specifications.freedesktop.org/desktop-entry-spec/latest/ape.html
2017-08-17 10:50:06 -07:00
sentriz
72173a93a7 Accept return as a valid answer to 'Edit the file again?'
Also, check for affirmative answer so a random string isn't taken as a
"yes" response.
2017-08-14 18:18:41 -07:00
Fabian Homborg
4e2b11f2e0 help: Fix error if no argument is given 2017-08-14 18:18:10 -07:00
Sam Yu
d87c0424d8 Speedup git prompt
Fix __fish_git_prompt too slow under repo with lots of untracked
files when __fish_git_prompt_showuntrackedfiles enabled.
2017-08-06 13:24:33 -07:00
Kurtis Rader
8b79f4e5c9 use the new set -a and set -p in our scripts 2017-08-04 18:02:24 -07:00
Kurtis Rader
d4fb75e9f3 fix bug in abbr function
I introduced a bug in the `abbr` function with commit 17dff8c by
referencing the undefined `$cmd` variable. This fixes that.
2017-08-03 23:52:07 -07:00
Kurtis Rader
17dff8c569 rewrite abbr function
Rewrite the `abbr` function to store each abbreviation in a separate
variable. This greatly improves the efficiency. For the common case
it is 5x faster. For pathological cases it is upwards of 100x faster.
Most people should be able to unconditionally define abbreviations in
their config.fish without a noticable slow down.

Fixes #4048
2017-08-03 14:35:06 -07:00
Kurtis Rader
1a55e9ba60 Merge branch 'master' into major 2017-07-29 21:58:15 -07:00
Kurtis Rader
4e026588f4 modify prev commit to use builtin cd
Using the `cd` function can have undesirable side effects like mucking
with the directory history. So force the use of the builtin cd.
2017-07-27 14:36:32 -07:00
Kurtis Rader
defdc92b57 fix ssh config Include file handling
Fixes #4253
2017-07-27 14:36:32 -07:00
Kurtis Rader
92f39f7b89 fix bug introduced by commit 86af63cd3 2017-07-25 14:03:40 -07:00
Kurtis Rader
35a7db50a2 fix bug introduced by commit 86af63cd3 2017-07-25 14:02:50 -07:00
Kurtis Rader
8e87d595b7 remove some uses of $IFS
This is a step towards resolving issue #4156. It replaces uses of `$IFS`
with other solutions.
2017-07-24 20:45:43 -07:00
Kurtis Rader
d068f846e8 simplify history function
The fix for #4232 allows us to simplify the `history` function slightly.
2017-07-21 16:26:15 -07:00
Kurtis Rader
d376cb316f simplify history function
The fix for #4232 allows us to simplify the `history` function slightly.
2017-07-21 16:25:03 -07:00
Fabian Homborg
e0f0164b16 Quote $USER when used with switch or test
Common in prompts, this would fail if $USER is empty.

See #4229.
2017-07-20 19:45:32 +02:00
Kurtis Rader
0dc92fbb2d a make style-all cleanup 2017-07-18 22:40:25 -07:00
Kurtis Rader
69ecda5082 update math to use the new argparse validation 2017-07-18 15:03:08 -07:00
Kurtis Rader
4e1303823b add ability for argparse to validate args
Fixes #4211
2017-07-18 14:42:50 -07:00
Kurtis Rader
403d9691cb fix handling of ssh aliases
Fixes #4213
2017-07-17 21:13:21 -07:00
Kurtis Rader
8f22def8f7 return to psub --file being the default
The recent change to switch `psub` to use `argparse` caused it to use
a fifo by default because it inadvertently fixed a long standing bug in
the fish script. This changes the behavior back to `psub --file` being
the default behavior and introduces a `--fifo` flag. It also updates the
documentation to make it clearer when and why `--fifo` mode should not
be used.

Fixes #4222
2017-07-17 14:33:51 -07:00
Kurtis Rader
3e226f0a5e implement a new implicit int option spec
While updating the `history` function to use `argparse` I realized it is
useful to define an option that can be used in three ways. First by
using the short flag; e.g., `-n NNN`. Second by using the long flag;
e.g., `--max NNN`. Third, as an implicit int flag; e.g., `-NNN`. This
use case is now supported by a spec of the form `n#max`.
2017-07-16 18:27:41 -07:00
Kurtis Rader
c22df3b823 update history to use argparse 2017-07-16 15:13:39 -07:00
Kurtis Rader
f2c8e73891 add more alias unit tests
A recent regression to the `alias` command points out the need for more
unit tests of its behavior. I also decided to use it as an opportunity
to normalize the output of just `alias` to list aliases.
2017-07-15 17:36:36 -07:00
Kurtis Rader
98449fec51 fix math regression
The previous change to use `argparse` for parity with every other
builtin and function introduced a regression. Invocations that start
with a negative number can fail because the negative value looks like an
invalid flag.
2017-07-14 16:03:31 -07:00
Kurtis Rader
ff4d275f22 remove left over debug statement 2017-07-14 08:18:41 -07:00
Kurtis Rader
49a0841533 update type to use argparse 2017-07-13 15:19:02 -07:00
Kurtis Rader
51bbecc419 update realpath to use argparse 2017-07-13 14:33:11 -07:00
Kurtis Rader
3e6c57d5d3 update psub to use argparse 2017-07-13 14:12:51 -07:00
Kurtis Rader
30940916bd update prompt_pwd to use argparse 2017-07-13 14:12:51 -07:00
Kurtis Rader
51a52a7286 update open to use argparse 2017-07-13 14:12:51 -07:00
Kurtis Rader
e8243af20b update math to use argparse 2017-07-13 14:12:47 -07:00
Kurtis Rader
140e6204be update help to use argparse 2017-07-13 13:49:15 -07:00
Kurtis Rader
86af63cd39 update funcsave to use argparse 2017-07-13 13:35:26 -07:00
Kurtis Rader
6ecd0bcb32 update funced to use argparse 2017-07-13 13:29:35 -07:00
Kurtis Rader
df65ed8696 update dirs to use argparse 2017-07-13 11:53:29 -07:00
Kurtis Rader
30baf8d101 convert dirh to use argparse 2017-07-13 11:50:57 -07:00
Kurtis Rader
f156bea1b7 convert alias to use argparse 2017-07-13 11:47:41 -07:00
Kurtis Rader
05aae4764b convert popd and pushd to use argparse 2017-07-13 11:31:08 -07:00
Kurtis Rader
5ac8c42fad convert nextd to use argparse
Also fix a bug I introduce in `prevd` when I converted it to use `argparse`.
2017-07-13 11:30:48 -07:00
Kurtis Rader
3a782003ed have argparse report the proper command name 2017-07-12 22:38:32 -07:00
Kurtis Rader
abef2cc422 convert nextd to use argparse 2017-07-12 22:38:32 -07:00
Kurtis Rader
5cf2a50269 convert isatty to use argparse 2017-07-12 22:38:32 -07:00
Kurtis Rader
3c4e3035fd switch from getopt to argparse
Convert our two functions that use `getopt` to use our new `argparse`
builtin.

Fixes #4190
2017-07-12 22:38:32 -07:00
Kurtis Rader
a4dc2b872b implement fish_opt helper command
This implements a `fish_opt` command that provides a way for people
to create option specs for the `argparse` command as an alternative to
creating such strings by hand.

Fixes #4190
2017-07-12 22:38:32 -07:00
David Marchal
e1951a32bb Fixed __fish_complete_users to better format GECOS 2017-07-11 17:00:08 +02:00
Kurtis Rader
8cc4639ea6 implement cdh command
Fixes #2847
2017-07-05 13:25:18 -07:00
tamanugi
170f11771b Add function __fish_complete_user_at_hosts
This function list hostnames;
if commandline hoge@~ , it list hoge@(hostname)
2017-07-05 16:24:45 +02:00
Kurtis Rader
4853ec0281 harden psub again an undef TMPDIR 2017-07-04 16:35:32 -07:00
Kurtis Rader
8caab103d8 harden man against undef vars 2017-07-04 13:56:35 -07:00
Kurtis Rader
2df89f4b0f check if $fish_color_cancel is set before using it 2017-07-04 13:56:35 -07:00
Fabian Homborg
9fb7037174 fish_key_reader: Add --version option
This should be there anyway, and we try to find fish_key_reader for
.app bundles, so this stops us from defining aliases to the command.

See #4179.
2017-07-04 22:55:47 +02:00
Kurtis Rader
f6d101e7ad fix undef var reference in history
The change for issue #4163 brought to light the pointless attempt to use
`$_` in the `history` function.
2017-07-03 16:26:27 -07:00
Kurtis Rader
0ec9acf0f0 harden abbr against undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 13:05:50 -07:00
Kurtis Rader
763063e741 more changes to better handle undef vars
This is only needed if we make undefined vars an error as proposed in
issue #4163 but it's a good idea anyway.
2017-07-03 10:16:31 -07:00
Kurtis Rader
ea38519a12 fix var name in __fish_git_prompt
Var `___git_ps_color_suffix_done` is supposed to be
`___fish_git_prompt_color_suffix_done`. This bug was found by an
experimental change to detect the use of undefined variables (#4163).

Similarly, we should simply test whether `__fish_git_prompt_showcolorhints`
is set rather than set to a non-empty string.
2017-07-02 20:49:40 -07:00
Kurtis Rader
85b42b22f4 define __fish_active_key_bindings before using it 2017-07-02 13:41:40 -07:00
Kurtis Rader
3284393aba cleanup some undefined var references
Testing a fix for #4163 revealed some questionable dereferencing of
variables that are not certain to be defined.
2017-07-02 13:41:40 -07:00
Fabian Homborg
db529f06b8 type: Use command -a 2017-06-28 23:13:36 +02:00
Kurtis Rader
bb29f9f990 replace __fish_urlencode with string escape
We now have a builtin that can do URL escaping so use it. I can't find
any uses of our private `__fish_urlencode` function in any Oh-My-Fish or
Fisherman code so remove it.
2017-06-23 22:46:36 -07:00
Kurtis Rader
30368d5526 implement status function when in a breakpoint
Another step to fixing #1310. This changes means that `status -L0
function` reports the correct function when inside a breakpoint.
2017-06-23 22:14:21 -07:00