Commit Graph

1624 Commits

Author SHA1 Message Date
Fabian Homborg
33dbd98200 Remove x-bit from function 2019-07-15 21:02:08 +02:00
Fabian Homborg
56e122866c fish_svn_prompt: Shorten a return 2019-07-15 21:02:08 +02:00
Per Bothner
2dcaf4f5c0 Emit 'fish_cancel' at end of __fish_cancel_commandline.
This helps with shell integration - see issue #5973
"shell-integration - how distringuish winch repaint from ctrl-c cancel".
2019-07-15 21:01:49 +02:00
Fabian Homborg
47e9e8ab8a fish_vcs_prompt: Stop at first success
Closes #5980.
2019-07-15 17:32:22 +02:00
Leonard Hecker
ca5427865d Fixed invalid assignments in fish_print_git_action 2019-07-03 17:37:44 +02:00
Fabian Homborg
c392a05db0 functions/__fish_anypython: Also try python{3,2}.7
NetBSD!!!!! *shakes fist*
2019-06-25 19:40:22 +02:00
Fabian Homborg
427a18c1ea fish_git_prompt: Add a way to use the informative chars
$__fish_git_prompt_use_informative_chars will use the informative
chars without requiring informative mode (which is really frickin'
slow!).

See #5726.

[ci skip]
2019-06-25 16:11:18 +02:00
Fabian Homborg
3bc392a6b3 functions/__fish_print_hostnames: Check getent's status
This previously effectively checked `string split ' '`s return status,
which was false if it didn't split anything. And while that should be
true if getent fails (because it should produce no output), it's also
true if it doesn't print a line with multiple aliases. Which should be
fairly typical.

Instead we use our new-found $pipestatus to check what getent returns,
in the assumption that it'll fail if it doesn't support hosts.

Follow up to 8f7a47547e.

[ci skip]
2019-06-25 08:40:31 +02:00
Fabian Homborg
8f7a47547e functions/__fish_print_hostnames: Don't run getent hosts twice
`getent hosts` is expensive-ish - ~50ms, so we don't want to run it
twice just to figure out it works.

Apparently this works everywhere but CYGWIN and possibly older
OpenBSD, but we don't want to explicitly blacklist those.

[ci skip]
2019-06-24 19:19:31 +02:00
Fabian Homborg
77103ddbab Dishonour
[ci skip]
2019-06-12 10:22:46 +02:00
Fabian Homborg
c0ca4d3236 functions/history: Read the search term if none is given
Fixes #5791.
2019-06-06 15:07:46 +02:00
Fabian Homborg
d0921489ee fish_git_prompt: Fix changing show_informative_status
If you changed $__fish_git_prompt_show_informative_status, it
triggered a variable handler, which erased the chars, but neglected to
unset $___fish_git_prompt_init, so we just kept chugging along with
empty characters.

What's the hardest thing in CS again? Cache something something?

[ci skip]
2019-05-29 10:36:14 +02:00
Fabian Homborg
dcf017ff57 fish_complete_directories: Use complete -C
This way we use our core file completion code, which is much more
flexible than we can easily achieve directly in script (which would
require e.g. an `expand` builtin, and case-insensitive globs).

Fixes #5896.
2019-05-27 19:33:52 +02:00
Fabian Homborg
7ddae68645 Restyle a few stragglers
THERE WERE TABS! TABS!

TABS!

[ci skip]
2019-05-20 21:07:37 +02:00
ridiculousfish
3d25ce1fd4 Merge remote-tracking branch 'takoyaki/ant_completion' into master 2019-05-11 23:22:45 -07:00
Fabian Homborg
816df47c10 fish_clipboard_paste: Only trim leading whitespace on first line
We remove leading spaces so a paste isn't histignored, but we did so
on all lines, which removed indentation.

[ci skip]
2019-05-11 11:19:21 +02:00
Fabian Homborg
cc205a134b Disable fish_title in emacs 2019-05-06 17:06:40 +02:00
Fabian Homborg
afff93bdb2 Disable vi-cursor in tests
Otherwise this breaks if run inside a terminal that could do the cursor.
2019-05-05 17:31:33 +02:00
Fabian Homborg
bcce6d691f Keep "; and" and "; or" on fish files
This reformats *.fish files from before commit
c2970f9618 with the changes to fish_indent.

[ci skip]
2019-05-05 13:34:38 +02:00
Fabian Homborg
46b804cf19 fish_vi_cursor: Don't fail if --force-iterm is given in non-iterm
Otherwise this would have used it as the terminal.

Fixup!

[ci skip]
2019-05-05 13:05:19 +02:00
Fabian Homborg
e952f60b02 functions/fish_vi_cursor: Disable on iTerm, allow override
I still don't get #3696, so let's just offer an override for now.

[ci skip]
2019-05-05 13:01:02 +02:00
Fabian Homborg
7451443050 functions/fish_vi_cursor: Cleanup
Removes the unused "uses_echo" variable and adds some comments.

[ci skip]
2019-05-05 12:57:14 +02:00
Fabian Homborg
7d2eb9649c functions/fish_vi_cursor: Detect a few more terms
These have $TERM entries of their own, so detecting them is quite easy.
2019-05-05 12:57:14 +02:00
Fabian Homborg
c22af0d8c7 functions/fish_vi_cursor: Simplify detection
This was quite famously rather complicated.

We drop a bunch of cases - we can't handle tmux-starting-terminals
100% accurately, so we just don't try. It should be quite rare that
somebody starts a different terminal from tmux.

We drop the `tput` since it is useless (like terminfo in general for
feature-detection, because everyone claims to be xterm).

So we just check if we are in konsole, iTerm, vte or genuine-xterm.

Fixes #3696.

See #3481.
2019-05-05 12:57:14 +02:00
Fabian Homborg
787ef3e558 functions/fish_vi_cursor: Move $XTERM_VERSION check earlier
Saves us from having to do it again and again.
2019-05-05 12:56:31 +02:00
Fabian Homborg
ce245704d7 Reformat completion scripts
These were excluded from style.fish
2019-05-05 12:53:09 +02:00
Fabian Homborg
c2970f9618 Reformat all files
This runs build_tools/style.fish, which runs clang-format on C++, fish_indent on fish and (new) black on python.

If anything is wrong with the formatting, we should fix the tools, but automated formatting is worth it.
2019-05-05 12:09:25 +02:00
Fabian Homborg
3b532fc793 functions/fish_vi_key_bindings: Pass "-s" to shared bindings
Fixes #5853.

[ci skip]
2019-04-30 11:41:26 +02:00
Fabian Homborg
82052a6cc9 Don't start focus reporting until later
[ci skip]
2019-04-21 20:26:57 +02:00
Fabian Homborg
b5351bce1b Bind tmux focus reporting as --preset bindings
Purely cleanup, basically.

[ci skip]
2019-04-21 19:48:46 +02:00
Aaron Gyes
51e963bf44 fixup last commit 2019-04-21 09:07:29 -07:00
Aaron Gyes
9d84b45256 __fish_print_help: remove indent
Do this lame replacement in order to make some_builtin --help
output less tacky.
2019-04-21 02:06:29 -07:00
Fabian Homborg
46911a5e7f Revert "__fish_describe_command: Remove awk"
Dealing with macOS output in a fast manner using `string` is surprisingly hard, given that it features lines like

    gls(1), ls(1)            - list directory contents

Printing the "gls" with the description and the "ls" with the description requires a `while read` loop, and that's too slow.

This reverts commit 7784a5f23c.

[ci skip]
2019-04-19 20:57:45 +02:00
Aaron Gyes
92f4a009b3 __fish_config_interactive: disable file completions for builtins
Calling `complete` once here is preferable to adding a bunch of
1 line files to be autoloaded.
2019-04-15 12:49:24 -07:00
Mahmoud Al-Qudsi
e0e0fe9dd3 Re-implement eval as a regular builtin
I did not realize builtins could safely call into the parser and inject
jobs during execution. This is much cleaner than hacking around the
required shape of a plain_statement.
2019-04-12 07:04:15 -05:00
Geographer
9cf1b18b26 Honor dirprev scope (#5796)
* Honour `dirprev` scope

Honour the scope of the `dirprev` variable if it is universal
and avoid to shadow it with a global. This enables to share
the `cd` history between sessions.

* Honor dirnext and __fish_cd_direction scope

If these variables exist in the universal scope, do not shadow them
2019-04-12 09:43:34 +02:00
Fabian Homborg
e672b03993 functions/fish_hg_prompt: Remove --color and --pager
These weren't added long enough ago, and I only added them
speculatively.

So it should make it work with old hg versions.

CC @zanchey.

[ci skip]
2019-04-12 09:01:34 +02:00
Mahmoud Al-Qudsi
0cf0829c5f Add comment clarifying presence of empty eval function 2019-04-11 12:59:04 -05:00
Mahmoud Al-Qudsi
2fe2169065 Make eval a decorator
`eval` has always been implemented as a function, which was always a bit
of a hack that caused some issues such as triggering the creation of a
new scope. This turns `eval` into a decorator.

The scoping issues with eval prevented it from being usable to actually
implement other shell components in fish script, such as the problems
described in #4442, which should now no longer be the case.

Closes #4443.
2019-04-11 10:36:49 -05:00
Fabian Homborg
25dd22242d Adjust __fish_print_help for sphinx
This is beyond cheesy, but it seems to work.

Fixes #5782.
2019-04-10 18:20:25 +02:00
Aaron Gyes
b002eb350c Get rid of __fish_repaint_root
it's identical to __fish_repaint - so just register that for both
variable change events.
2019-04-09 00:29:22 -07:00
Fabian Homborg
8ff866b26b Add repaint-mode bind function
If we switch the bind mode, we add a "force-repaint" there just to
redraw the mode indicator.

That's quite wasteful and annoying, considering that sometimes the prompt can take
half a second.

So we add a "repaint-mode" function that just reexecutes the
mode-prompt and uses the cached values for the others.

Fixes #5783.
2019-04-01 15:59:39 +02:00
Fabian Homborg
0d72912641
Expand abbr explicitly (#5762)
* Add "expand-abbr" bind function

This can be used to explictly allow expanding abbreviations.

* Make expanding abbr explicit

NOTE: This accepts them for space only, we currently also do it for \n
and \r.

* Remove now dead code

We no longer trigger an abbr implicitly, so we can remove the code
that does it.

* Fix comment

[ci skip]
2019-04-01 15:59:15 +02:00
Fabian Homborg
21d8b465cc nextd/prevd: Print BEL instead of "Hit end of history"
That message is just hugely annoying.

Hat-tip to @floam and d524bad5f16b5a18c22fefe440.
2019-03-28 11:58:53 +01:00
Fabian Homborg
e2ce63ff62 functions/help: Adjust command paths to sphinx
We now build a separate page per-command in cmds/$cmd.html instead of
a section in the "commands.html" page.

See #5696.

[ci skip]
2019-03-27 12:46:51 +01:00
Fabian Homborg
2a51e42ee0 functions/help: Try harder to find a browser on WSL
We now try cmd.exe via $PATH and via a common location, wsl-open, and
an open command.

Fixes #5756.

[ci skip]
2019-03-27 09:06:11 +01:00
Fabian Homborg
248200520e functions/help: Prefer xdg-open/cygstart over open
Some systems like Debian have "open" as a symlink to "openvt" (for... historical
reasons).

See #5756.

[ci skip]
2019-03-27 09:06:11 +01:00
Fabian Homborg
5afd1336e8 functions/fish_npm_helper: Use physical pwd
This searched for package.json in any parent, so just like finding
.git and .hg directories it _needs_ to use the physical pwd because
that's what git/hg/yarn use.

In general, if you do _any_ logic on $PWD, it should be the physical
path. Logical $PWD is basically only good for display and cd-ing
around with symlinks.

[ci skip]
2019-03-24 10:49:04 +01:00
Fabian Homborg
25ba16d4b6 functions/help: Cleanup 2019-03-22 12:48:26 +01:00
Fabian Homborg
4c61691377 functions/help: Don't eval to check for lynx
This called `eval $fish_browser --version` to figure out if it is
lynx.

That's really not worth it just to support edge-cases using a rather
unusual browser, to work around a bug in it.

Instead we just see if the browser name starts with "lynx", which
should work in 99.9% of cases.
2019-03-22 12:38:23 +01:00
Fabian Homborg
21c8be8cd1 functions/help: Use open command everywhere
See #5756.

[ci skip]
2019-03-22 09:09:57 +01:00
Fabian Homborg
a649c5293e functions/fish_git_prompt: Fix space prefix for verbose showupstream
This created another local version of the variable just for the if-block.

Can't say I love the space prefix, but then I think we have too many
of these modes anyway.
2019-03-19 10:27:52 +01:00
Fabian Homborg
f6226f0802 functions/fish_git_prompt: Useful status for show_upstream
Returns 0 if there is no diversion, 1 otherwise.
2019-03-19 10:24:40 +01:00
Fabian Homborg
632c47be54 functions/fish_git_prompt: Remove literal tabs 2019-03-19 10:24:34 +01:00
Fabian Homborg
05ef157757 functions/fish_git_prompt: Let helper functions return useful status
If you use these to figure out if there _are_ staged files, or dirty
or whatever, you currently need to check the output, which relies on
the configured character.

Instead, we let them also return a useful status.
Notably, this is *not* simply the status of the git call.

__fish_git_prompt_X returns 0 if the repo is X.

This works for untracked, but the "diff" things return 1 if there is a
diff, so we invert the status for them.

See #5748.

[ci skip]
2019-03-19 10:11:37 +01:00
ykai
f56bce3f97 Fixed mount -o<TAB> exception 2019-03-19 09:28:14 +01:00
Fabian Homborg
805a8db7ef functions/fish_hg_prompt: Show untracked files
Apparently "status --quiet" actually inhibits showing untracked files,
which explains why it's 20% faster (though it's quite weird use of
that option!)

Fixes #5749.

[ci skip]
2019-03-18 22:26:43 +01:00
Fabian Homborg
a7ab8c6a4b Remove __fish_test_arg helper function
This was a remnant from before `string` existed, and was only used by
the xterm completions.

Part of #5279

[ci skip]
2019-03-15 19:58:01 +01:00
Fabian Homborg
2de3f7c686 Move ninja functions into ninja completions
Part of #5279

[ci skip]
2019-03-15 19:57:56 +01:00
Fabian Homborg
1c3c76165e Move xrandr functions into randr completions
Part of #5279.

[ci skip]
2019-03-15 19:57:51 +01:00
Fabian Homborg
a1380a736b Move __fish_print_make_targets into make completions
A function file for a function used only by one completion (and
unlikely to be used anywhere else).

If another user shows up, we can move it out again.

Part of #5279

[ci skip]
2019-03-15 19:57:46 +01:00
Fabian Homborg
83932441bb Fix fish_clipboard_paste with string-replace-fewer-backslashes
This is the one place in fish where we use a `\` in the replacement of
a `string replace -r`, so we'll have to check the feature.
2019-03-15 15:18:19 +01:00
Fabian Homborg
a7a12c5c96
Merge pull request #5709 from zabereer/prompts_with_pipestatus
Prompts with pipestatus
2019-03-15 14:32:33 +01:00
Fabian Homborg
18d7123ff4 fish_git_prompt: Use count from stdin
Removes any uses of `wc` in our codebase.
2019-03-15 14:31:36 +01:00
Fabian Homborg
912ba177ec functions/__fish_append: Stringify
This called `sed`, twice.
2019-03-14 13:23:48 +01:00
Fabian Homborg
c5d5089871 fish_svn_prompt: Stringify
This was the only remaining use of `grep` in functions/.
2019-03-14 13:23:47 +01:00
Fabian Homborg
7784a5f23c __fish_describe_command: Remove awk
This is really the only important place we're using it.

See #5553.
2019-03-14 13:23:47 +01:00
Fabian Homborg
29556efebd Drop rc.d completions
This was an arch utility that it used shortly before introducing
systemd.

It's been dropped upstream for years.
2019-03-14 13:23:47 +01:00
Fabian Homborg
a5a643f854 Bracketed paste: Strip leading spaces if they'd trigger histignore
Similar to the last commit, only for the in-terminal-paste stuff.

Also cleans up the comments on bracketed paste a bit - nobody has
stepped forward to report problems with old emacsen or windows, so
there's no need for a TODO comment.

See #4327.
2019-03-13 12:39:08 +01:00
Fabian Homborg
ad0c8cfb83 fish_clipboard_paste: Don't add histignore spaces
If we're at the beginning of the commandline, we trim leading whitespace so we don't trigger histignore.

Since that's the main issue of problems with histignore:
Closes #4327.
2019-03-13 12:39:08 +01:00
hyperfekt
8a0d794337 fish_git_prompt: optionally show stash state in informative mode 2019-03-12 18:47:28 +01:00
Aaron Gyes
eaf496c1d4 seq.fish: use gseq if available.
Apparently if you install gnu coreutils on OpenBSD, the tools are
g-prefixed. So we definitely want to just alias that rather than
provide our lousy shell script implementation.
2019-03-09 13:44:03 -08:00
Fabian Homborg
ba1249763b functions/__fish_npm_helper: Use python for json
[ci skip]
2019-03-09 18:30:17 +01:00
Fabian Homborg
9b1fb6938e Add __fish_anypython helper function
This just finds the first usable python and echos it, so it can then
be used.

We have a few places where we use it and I'm about to add some more.
2019-03-09 18:04:21 +01:00
Fabian Homborg
bd5232e0e2 functions/seq: Fix negative numbers
25d83ed0d7 (included in 3.0.0) added a `string` check that
did not use `--`, so negative numbers were interpreted as options.

Apparently nobody is using this.

(Again, this is for the `seq` fallback used on OpenBSD)
2019-03-07 22:50:17 +01:00
Fabian Homborg
b5b0e68044 functions/seq: Stop using bc in the fallback
Just to remove the dependency - performance is probably about the
same.

This is used, AFAICT, exclusively on OpenBSD (not Free or Net).

CC @zanchey.
2019-03-07 14:04:32 +01:00
Aaron Gyes
91e70e38e7 Handle TERM_PROGRAM_VERSION with junk after the number.
We only care about the major version number.

Fixes #5725
2019-03-06 13:52:54 -08:00
Fabian Homborg
60ce10ad84 functions/eval: Return 0 for empty arguments
Fixes #5692.
2019-03-05 21:10:11 +01:00
zabereer
a634356bcc remove redundant comment from __fish_print_pipestatus.fish 2019-03-05 18:25:16 +00:00
zabereer
d71e39f756 Revert "use global variables for $pipestatus in prompts to allow users to customize the look"
This reverts commit d5c18350a7.
2019-03-05 18:19:57 +00:00
Fabian Homborg
60f162db19 Remove single-argument test
This is an awful bit of `test` functionality that only exists to have
a clever shortcut and confuse people.

[ci skip]
2019-03-05 17:57:50 +01:00
zabereer
d5c18350a7 use global variables for $pipestatus in prompts to allow users to customize the look 2019-03-01 19:55:28 +00:00
zabereer
e157ba131b add $pipestatus to informative.fish prompt 2019-02-28 06:37:56 +00:00
zabereer
ead26881f0 create __fish_print_pipestatus function to reduce code duplication in other prompts when adding $pipestatus 2019-02-28 06:19:28 +00:00
zabereer
a6f9140963 remove redundant echo from __fish_pipestatus_with_signal.fish 2019-02-27 05:39:17 +00:00
zabereer
0071ad0409 add __fish_status_to_signal.fish and __fish_pipestatus_with_signal.fish 2019-02-26 18:09:37 +00:00
Fabian Homborg
ddc0e68f29 functions/fish_update_completions: Stop cleaning up in ~/.config
That seems suspect.

It removes files starting with "# Autogenerated", but those files
usually do not show up in ~/.config - they're in ~/.local/share.

So let's be careful and not mess with the user's config.

(I'm pretty sure that the previous commit re-enabled cleanup as the
`~` was quoted before then)

[ci skip]
2019-02-26 09:24:38 +01:00
Fabian Homborg
4b6c682b2d functions/fish_update_completions: Let the python parse options
This did `argparse`, but only handled "--help". Any other options
would be ignored.

Instead, we just pass all the options through to python, and that'll
display help if needed.

This allows passing e.g. `--verbose 1` to help with debugging.

[ci skip]
2019-02-26 09:22:09 +01:00
Max Nordlund
44ad92ef50 Fix typo 2019-02-20 16:00:59 -08:00
Fabian Homborg
8a93c7d0ea abbr: Add "-q"/"--query" option
[ci skip]
2019-02-19 11:02:58 +01:00
Aaron Gyes
05701a779b isatty: command [ instead of command test
I don't know why but Go users keep having random tools installed into
PATH named `test`. Fixes #5665
2019-02-16 17:15:52 -08:00
Aaron Gyes
f10c0dde3b __init_uvar: match previous behavior
query for any set variable, not just universals, lest someone
avoiding uvars intentionally has a problem.
2019-02-14 21:42:42 -08:00
Aaron Gyes
619a248a35 Clean up uvar initialization with a wrapper function
Adds __init_uvar
2019-02-14 17:09:16 -08:00
Fabian Homborg
5814b1b8e2 Fix man function for NetBSD
NetBSD's man is unusual in that it doesn't understand an empty
$MANPATH component as "the system man path", and doesn't have a
`manpath` or `man --path`.

It has a `-m` option that would be useful, but other mans also have a
`-m` option that isn't, so detecting it is tough.

It does have a `-p` option that almost does what one would want here,
so we hack around it to make things work.

Fixes #5657.

[ci skip]
2019-02-14 10:57:38 +01:00
Fabian Homborg
02ca7be416 functions/_.fish: Use ggetext if available
It turns out the default gettext on the sunny operating system with
the many names interprets at least `\n` itself, so we'd end up
swallowing it.

This allows us to move past the interactive tests and onto the expect
ones.

See #5472.
2019-02-13 13:05:50 +01:00
Fabian Homborg
df28f76698 git-prompt: Test untracked the right way around
This only showed untracked files if showuntrackedfiles was != true.

That's just exactly wrong.

Fortunately this wasn't in a release.

[ci skip]
2019-02-10 14:54:32 +01:00
Fabian Homborg
9c82979459 Rename __fish_hg_prompt -> fish_hg_prompt 2019-02-10 14:44:50 +01:00
Fabian Homborg
c29023b3e8 Rename __fish_svn_prompt -> fish_svn_prompt 2019-02-10 14:44:50 +01:00
Fabian Homborg
c771334924 Rename __fish_vcs_prompt -> fish_vcs_prompt
Still keep a stub under the old name for compatibility.
2019-02-10 14:44:50 +01:00
Fabian Homborg
cb7762b7c0 Move __fish_git_prompt -> fish_git_prompt
This exposes it more, since it's quite an important function.

We should do the same with the other vcs functions.

We leave a compatibility shim in place for now.
2019-02-10 14:44:50 +01:00
Mahmoud Al-Qudsi
2445a76d2e Fix typo in yarn/npm completions helper script
Hat-tip @billyjanitsch
2019-02-10 00:09:21 -06:00
Aaron Gyes
0abcf9265e {forward,backward}-bigword on Shift-Left/Right
There was no way to do this at all without vi keybindings,
and it turns out shift-left/shift-right was available.

Fixes #1605
2019-02-07 13:11:34 -08:00
Fabian Homborg
7c8b444927 Reduce default escape delay
300ms was waaay too long, and even 100ms wasn't necessary.

Emacs' evil mode uses 10ms (0.01s), so let's stay a tad higher in case
some terminals are slow.

If anyone really wants to be able to type alt+h with escape, let them
raise the timeout.

Fixes #3904.
2019-02-07 12:19:36 +01:00
Fabian Homborg
1a3471fa7d Revert "edit_command_buffer: Use variable-as-command"
This reverts commit 3c6844d4f4.

See #5625.
2019-02-07 09:47:24 +01:00
Fabian Homborg
8e60ebcd34 Revert "funced: Use variable-as-command"
This reverts commit 3253893923.

Fixes #5625.
2019-02-07 09:47:15 +01:00
ridiculousfish
6c22c8893b Switch from tee to cat in psub --fifo
Prior to this fix, we would write to a fifo via cat >$filename & .
However in some cases (and soon in all cases) we open the file before
the fork, not after. This results in a deadlock because the file open
cannot succeed until a write begins.

Switch to using tee to write to the file. Because tee opens the file itself,
fish is no longer responsible and the deadlock is resolved.
2019-02-03 01:58:49 -08:00
ridiculousfish
6ba0d4c88a Revert io_bufferfill_t stack
This reverts commit 88dc484858 onwards.
2019-02-02 17:53:40 -08:00
ridiculousfish
b956f13880 Switch from tee to cat in psub --fifo
Prior to this fix, we would write to a fifo via cat >$filename & .
However in some cases (and soon in all cases) we open the file before
the fork, not after. This results in a deadlock because the file open
cannot succeed until a write begins.

Switch to using tee to write to the file. Because tee opens the file itself,
fish is no longer responsible and the deadlock is resolved.
2019-02-02 14:21:46 -08:00
ridiculousfish
fd1908e973 Switch TMUX check to FISH_UNIT_TESTS_RUNNING
Per discussion in https://github.com/fish-shell/fish-shell/commit/0c17210f056
2019-02-01 16:59:05 -08:00
ridiculousfish
0c17210f05 Fix the expect tests under tmux by inspecting TERM
We were checking for the $TMUX variable to determine if we were
running under tmux. However when running the tests, the terminal becomes
expect, even though the TMUX variable is still set, so we spew tmux-isms
at expect. Check the value of $TERM for 'screen'.
2019-01-31 12:30:41 -08:00
ridiculousfish
4064ab8183 Stop emitting extra new lines under tmux 2019-01-28 16:49:31 -08:00
Fabian Homborg
c776414674 functions/trap: Don't test with one argument
That's a POSIX misfeature.

Also there was one actually wrong `test sig` that should have been
`test $sig`.
2019-01-27 15:38:03 +01:00
Fabian Homborg
a0fbb8dea7 Redraw vi cursor if tmux pane focus changes
Fixes #4788.
2019-01-26 19:38:28 +01:00
Fabian Homborg
c775335b2a functions/__fish_print_cmd_args_without_options: Stringify
[ci skip]
2019-01-26 19:20:16 +01:00
Fabian Homborg
b8fd08811c functions/__terlar_git_prompt: Stringify
[ci skip]
2019-01-26 19:20:11 +01:00
Fabian Homborg
0640e7bae9 Move prt-get functions into the completion script
These were not used elsewhere.

Part of #5279.

[ci skip]
2019-01-26 19:16:25 +01:00
Fabian Homborg
7ad779ac00 Remove __fish_can_complete_switches
This was only used in __fish_should_complete_switches, and is a tiny
helper function that is better integrated directly.

Part of #5279.

[ci skip]
2019-01-26 19:16:18 +01:00
Fabian Homborg
882da75d29 Remove __fish_commandline_test function
This was only ever used in the commandline completions, and is
equivalent to (a weird example of) __fish_contains_opt.

Part of #5279.

[ci skip]
2019-01-26 19:16:12 +01:00
Fabian Homborg
1e3a46f423 Remove __fish_bind_test* functions
These were only used in the bind completions, so there's no need to
keep these two separate.

Part of #5279.

[ci skip]
2019-01-26 19:16:06 +01:00
Fabian Homborg
354c6b1b67 git_prompt: Read "bash.showInformativeStatus" git config variable
This allows disabling _just_ the informative status.

We still also use the dirty and untracked variables, but only if
informative status hasn't explicitly been enabled.
2019-01-26 14:52:37 +01:00
Fabian Homborg
15cf45a2a0 git_prompt: Allow overriding informative status via git config
If either of the two git config variables:

- bash.showDirtyState
- bash.showUntrackedFiles

is explicitly set to false, we will disable informative status, and
fall back on the non-informative version (most likely still with
either dirty or untracked files, since we already use the variables
for that).

These vars are read by the official git prompt, so we use them instead
of inventing our own "fish.showInformativeStatus".

(Note: This also uses $__fish_git_prompt_showdirtystate and friends,
but only when there's nothing set in the repo, and there's really no
reason to set those to false if using the informative status)

Fixes #5551.

[ci skip]
2019-01-26 14:52:37 +01:00
Hideki Hamada (jakalada)
5c689bb50c fix dirh output with reversed $dirnext 2019-01-26 13:30:45 +01:00
Matan Kushner
4567d3ae52 Fix typo setting fish_color_error (#5577) 2019-01-23 17:34:28 -08:00
wyahiro
e9f0a8cf2c Redo ant completions
Closes #5475
2019-01-23 18:00:21 -06:00
Mahmoud Al-Qudsi
d651cdacbe Extend type --path to print path to script defining named function
Expands the utility of `type -p foo` by allowing it to print the path to
the script that defines `foo` when `foo` is a valid function that was
sourced from a path on disk (rather than interactively defined).

This does not change the behavior of `type -P`/`type --force-path`,
which should have already been used if the desire was to resolve the
path to an executable file (otherwise the output would have been blank
if a function was shadowing an executable file of the same namea), so no
backwards compatibility issues are expected.
2019-01-23 17:51:47 -06:00
Johannes Altmanninger
eee4dd8248 __fish_complete_man.fish: escape for regex
Previously, using special regex characters or slashes would result in an
error message, when pressing tab in a command-line such as
"man /usr/bin/time ".
2019-01-23 11:58:30 +01:00
Aaron Gyes
b23403ee6b Revert "__fish_complete_suffix: do not show description when not passed one"
This reverts commit 367661d4f1.

This was the wrong way to address this annoyance of mine.
2019-01-21 22:55:56 -08:00
Aaron Gyes
367661d4f1 __fish_complete_suffix: do not show description when not passed one
Make it so that the generated completion has the form \t\n
when the optional description has been ommitted - otherwise
the original option's description gets inherited and is seen hundreds
of times repeating in the pager.
2019-01-21 22:37:45 -08:00
Aaron Gyes
a5e5f90f73 ls.fish: fix colorless ls not taking options
That -- no-op would have the effect that a user can not pass more
options to ls, they would be interpreted as file names.
2019-01-21 07:52:26 -08:00
Aaron Gyes
488e208cca ls.fish: also show indicators on non-GNU ls, refactor
GNU ls's --indicator-style=classify is the same as POSIX -F.

Refactor and change command testing logic so that we define the
function in the same place for all platforms, and use -F on all
the platforms when stdout is a TTY.
2019-01-21 06:56:57 -08:00
Aaron Gyes
5dc0ff0a90 ls.fish: remove for loop
`command -s` can take multiple arguments to try.
2019-01-21 03:15:43 -08:00
takoyaki9n
db671e8518
Merge branch 'master' into ant_completion 2019-01-21 16:32:51 +09:00
wyahiro
9a7079190d change validation of buildfile 2019-01-18 10:24:14 +09:00
wyahiro
2c52c5285d Fix fail back value for XDG_CACHE_HOME 2019-01-17 16:32:57 +09:00
Fabian Homborg
5779d99a81 fish_vi_cursor: Check for tput before using
If tput isn't available, that's the same as if it failed.

This is the last bit necessary to make the tests work on alpine on builds.sr.ht.
2019-01-16 11:08:47 +01:00
Aaron Gyes
c94adb9d3e fish_config: make clear python 2 or 3 will both work.
A person stuck installing it just for fish on their server
doesn't want to waste time installing the wrong one, so assuage that.

Also tweak to look nicer with 80 columns
2019-01-14 03:29:57 -08:00
Aaron Gyes
7d16714dd3 fish_config: tell the user some nice things without Python
As discussed in #5492, it would be good if running fish_config without
Python actually told the user to install Python.

Further, let's give the person some hints on how to configure these
things by hand, since they may have to.
2019-01-14 03:08:44 -08:00
wyahiro
71f15f70ea Fixed logic for cache file generation 2019-01-14 13:08:29 +09:00
Mahmoud Al-Qudsi
2fdcc4544a Fix extra space in fish_title
Closes #5517. Credit goes to @jadenPete.

[skip-ci]
2019-01-13 16:14:58 -06:00
wyahiro
480e95147c use cache file for ant targets 2019-01-13 21:36:05 +09:00
Aaron Gyes
6c9065e9ef abbr -e: use same exit code as set -e if abbr doesn't exist
Which is 4, apparently.. (builtin_set.cpp returns ENV_NOT_FOUND)
here. This was previously hardcoded to our 121, which used to be
what builtins used for invalid arguments.

4 is pretty arbitrary but at least this is more consistent.
2019-01-11 00:50:01 -08:00
Mahmoud Al-Qudsi
6ea7aa8a00 Share code between yarn and npm completions
I had previously introduced a lot of updates and fixes to npm registry
based completions for `yarn` but hadn't ported them to `npm` as well
(although they can be dropped in as-is). This patch shares the code
between the two, which resides in an explicitly sourced multi-function
fish script.
2019-01-10 23:12:49 -06:00
John McKay
827bce6c88 Use mandoc when nroff not available
mandoc users do not need to install nroff to be able to format and view
manual pages. If both nroff and mandoc cannot be found it will show an
error.
2019-01-08 18:25:28 +01:00
wyahiro
a6062c4cdd improved completion for ant 2019-01-03 23:17:53 +09:00
Sean Molenaar
41b3331175 Add support for wayland copy/paste 2019-01-02 16:46:04 +01:00
Curtis Jiang
f871951a87 fix OpenWrt and opkg support (#5454)
* add OpenWrt and opkg support

Signed-off-by: Curtis Jiang <jqqqqqqqqqq@qq.com>

* fix opkg list

Signed-off-by: Curtis Jiang <jqqqqqqqqqq@qq.com>
2018-12-31 16:48:03 +01:00
Fabian Homborg
dabd05f2e3 Remove string fallback function
We already have a fallback here, and upgrading from 2.3.0 to 3.X will be rare.

This costs every shell on every start.

See #5279.
2018-12-30 19:24:03 +01:00
Leonard Hecker
082450b1e7 Severely extended the sorin theme (#5411)
* Severely extended the sorin theme

This theme should now mostly match the original.

* Removed superfluous whitespace

* Inlined external links as ASCII art

* Made myself the author of the sorin theme

* Removed superfluous read delemiter

* Renamed __fish_git_action to fish_print_git_action

* Adde a minor comment
2018-12-18 15:01:38 +01:00
Mahmoud Al-Qudsi
3855c2217f Remove scripted XDG_CONFIG_HOME uses
Cleaned up the code to no longer replicate in fishscript what fish
already does (and caches to boot) in C++ in setting up the paths to the
user configuration directory.

Also introduced a `$__fish_user_data_dir` instead of the sporadic
definitions of `$userdatadir` that may or may not go through
`XDG_DATA_HOME`.
2018-12-14 22:09:29 -06:00
Aaron Gyes
c1be3284c1 __fish_config_interactive: inline combinational logic
Boost readability of this long, logic-heavy script with the new
&& and || syntax added to fish 3.
2018-12-14 05:49:08 -08:00
Aaron Gyes
ba9c387590 __fish_config_interactive: tighten up checks for OSC 7 feature
I spent some time figuring out $TERM_PROGRAM_VERSION and Terminal.app's
capabilities over time. [1]

Only use OSC 7 if running on the version of Terminal.app that added it
or newer. In the past this would have been harder because `test` couldn't
do float comparisons.

cleanup:
Don't bother setting a local $TERM_PROGRAM if it's unset: quoting
is enough to keep test happy. For the version numbers, 0"$var" is safe
against unset variables for numerical comparisons.

[1]: https://github.com/fish-shell/fish-shell/wiki/Terminal.app-characteristics
2018-12-14 05:00:55 -08:00
Fabian Homborg
99ba07354a fish_vi_key_bindings: Remove weird argv handling
Instead of maybe adding "-s" and "-M" if "-s" hasn't already been
given, just add "-s" to _every_ bind invocation, and "-M" to those who
need it.

Fixes #5028.
2018-12-13 17:33:48 +01:00
David Adam
79d53a32dc history: drop use of fish_indent
Largely reverts 007d794b6e.

fish_indent is extremely resource-intensive on large inputs and can crash; it also does not handle
invalid characters gracefully.

Work on #5402.
2018-12-13 21:57:24 +08:00
Fabian Homborg
d20b3c688b Remove unused portage_print_*_categories functions
These weren't used anywhere, and were only added in
44e2c28255, which isn't in a release yet.

[ci skip]
2018-11-30 21:35:20 +01:00
Fabian Homborg
176c84fb9f Extract code to print hg root from the prompt
This is useful in other prompts, and potentially also to users.

Don't use a dunderscore because we do way too many of them.
2018-11-30 20:57:59 +01:00
Fabian Homborg
f0aa63cc11 man: Use new data_dir variable name 2018-11-29 20:28:29 +01:00
Bjorn Neergaard
958e46882f Slightly restructure man.fish for clarity
man.fish can be clarified a bit, by removing a superfluous early return. Additionally, performance can be
(ever so slightly) improved, by using the empty string to suffix an extra colon when `$MANPATH` is empty, as
described in `manpath(1)`. As `man` will internally call `manpath` as it starts, this eliminates a redundancy.
2018-11-29 15:29:18 +01:00
Fabian Homborg
20099774a0 fish_clipboard_copy: Use selection, if any
See #5368.
2018-11-25 17:33:14 +01:00
Aaron Gyes
c1af29f641 __fish_config_interactive: tell complete that [ wraps test
We want to show our completions for the `[` (`test`) builtin, but
we don't want to create a [.fish.
2018-11-25 02:04:56 -08:00
Fabian Homborg
60fa9da3a7 Rewrite __fish_complete_proc
- No longer uses sed, sort, uniq, uname
- Stop doing too-clever filtering (e.g. the kernel thread stuff never
- really worked)
- Don't truncate for all OSen, instead just use the (correctly
- truncated) comm field.
2018-11-22 15:23:05 +01:00
Fabian Homborg
3a835ebd61 Make --help work
See #5361.
2018-11-22 12:43:35 +01:00
Fabian Homborg
b383e29a24 type: Make "--help" work
This tripped over argparse --min-args=1, but we already return 1 above
if there really is no argument.

Fixes #5361.
2018-11-22 12:27:25 +01:00
Aaron Gyes
007d794b6e history: improve interactive pager experience
- Colorize history search output when interactive, using
  fish_indent. This is the same way we colorize `type` output.

- Ask less to act like `cat` if the output will fit in the
  terminal window, so it's less jaring with short output.

- history is viewed in a pager when interactive, but pagers
  typically strip escape codes. We accomplish the above by
  doing exactly what `git` does[1] when it has colored output
  for a pager:
        if $LESS is unset, set it to enable -R, -F, and -X options.
	if $LV is unset, set it to -c.

[1]: 398dd4bd03/pager.c (L87)
2018-11-20 05:01:12 -08:00
Mahmoud Al-Qudsi
59197d12e0 Better handling of cases where man is not installed
Thanks to @floam, adapted to reduce nesting.

Works around override of command-not-found handler in previous solution
(c.f. 13e025bdb0).
2018-11-17 22:05:48 -06:00
Fabian Homborg
7b21f1c3cb Revert "mount completions: don't truncate mounts with spaces in them"
This does not work with util-linux mount, because that prints a "type" in between.

This reverts commit 1c364722a7.
2018-11-17 14:06:15 +01:00
Aaron Gyes
1c364722a7 mount completions: don't truncate mounts with spaces in them 2018-11-17 04:46:25 -08:00
Mahmoud Al-Qudsi
13e025bdb0 Clean up error message for man wrapper when man isn't installed
Closes #5329
2018-11-16 20:04:43 -06:00
Mahmoud Al-Qudsi
ab0f1d33fe Make use of the new PCRE2 escaping feature
Fixes some potentially unsafe uses of direct substitution into regex
expressions and also switches some completions to regex-based now that
there is a safe way of using it.
2018-11-15 12:37:29 -06:00
Aaron Gyes
920be02fe9 __update_cwd_osc: Use $hostname var instead of hostname command
Changing directories should be a few ms faster.
2018-11-13 15:40:19 -08:00
David Adam
5bd0472682 abbr: tidy description 2018-11-13 21:42:49 +08:00
Mahmoud Al-Qudsi
d6ab3db159 fixup! Extend __fish_complete_suffix to support a virtual $PWD 2018-11-08 16:17:56 -06:00
Mahmoud Al-Qudsi
da6937e0cf Extend __fish_complete_suffix to support a virtual $PWD
In writing the completion script for openocd I found the need to
complete paths at the command-line as if they were relative to a
path other than the current $PWD. Given that `$PWD` is currently
global in fish (i.e. no side-effect free `cd` within a subshell)
this is probably good to have for other completions too.

This also fixes a bug in support for explicitly supplying the
description for completions via a `$argv` parameter, which prefixed
the description with `\t` (which is correct) except it did so in
the local scope within an `if` statement, meaning the changes never
had any effect and in the output the description was directly
concatenated to the completions, instead of separated by a tab.
2018-11-07 20:08:16 -06:00
Moritz Wilhelmy
9afc4b419e Allow cd . to re-enter the current directory
Closes #4543.
2018-11-04 21:46:24 +08:00
Mahmoud Al-Qudsi
1288877033 Update yarn completions
Don't attempt to complete against package names if the user is trying to
enter a switch to speed things up.

Also work around #5267 by not wrapping unfiltered `all-the-package-name`
calls in a function.
2018-10-29 13:56:40 -05:00
ridiculousfish
e09e1e8e41 Fix funced when using the built-in editor 2018-10-27 17:19:43 -07:00
Fabian Homborg
121d61cf31 Revert "help: Use variable-as-command instead of eval"
We do a bunch of escaping before to make `eval` work, and that needs to be removed as well or fragment-urls don't work.

This reverts commit e9568069a7.
2018-10-26 10:52:02 +02:00
Fabian Homborg
c78e6a3ccf edit_command_buffer: repaint
Thanks @amosbird on gitter.
2018-10-25 17:34:01 +02:00
Fabian Homborg
fb0c1460a9 __fish_complete_pgrep: Truncate to 15 characters
Fixes #4132.
2018-10-25 12:10:17 +02:00
Mahmoud Al-Qudsi
5ad292328a Add dynamic clang completions via clang --autocomplete
Use clang/clang++'s own autocompletion support to complete arguments. It
is rather convoluted as clang generates autocompletions for a portion of
the current token rather than the entire token, e.g. while `--st` will
autocomplete to `--std=` (which is fine by fish), `--std=g` will
autocomplete to `gnu...` without the leading `--std=` which breaks fish'
support for the completion.

Additionally, on systems where clang/clang++ is the system compiler
(such as FreeBSD), it is very often for users to invoke a newer version
of clang/clang++ installed as clang[++]-NN instead of clang. Using a
monkey-patched version of `complete -p` to support that without breaking
(future) completions for commands like `clang-format`.

Closes #4174.
2018-10-24 23:14:55 -05:00
Mahmoud Al-Qudsi
ebb3a3a16e Set $fish_private_mode and show a message on private mode startup
The message can be localized and is set as a global variable shadowing
the universally-defined $fish_greeting.
2018-10-24 19:33:48 +02:00
Fabian Homborg
b427cd1823 ls.fish: Use gdircolors if available
See #5278.
2018-10-24 19:27:51 +02:00
Fabian Homborg
d727e32934 __fish_print_help: Just use $COLUMNS
This had an undocumented internal feature that would pass the tty
width along. Instead, just have it read $COLUMNS, which we always
define anyway.
2018-10-23 15:05:15 +02:00
Fabian Homborg
6c988abe28 Add $__fish_config_dir variable
Contains the path to the user config.fish (e.g. ~/.config/fish)
without having to do the `set -q XDG_CONFIG_HOME` dance.

See #5270.
2018-10-21 15:42:25 +02:00
Fabian Homborg
162af88c9a __fish_parse_configure: Move some comments
This contained a commented-out `eval`, which drew my attention.
2018-10-21 15:38:31 +02:00
Fabian Homborg
3c6844d4f4 edit_command_buffer: Use variable-as-command 2018-10-21 15:34:42 +02:00
Fabian Homborg
3253893923 funced: Use variable-as-command 2018-10-21 15:34:19 +02:00
Fabian Homborg
e9568069a7 help: Use variable-as-command instead of eval 2018-10-21 15:33:29 +02:00
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