git has options that can appear before commands, but not all of
them, and some of them need an argument. This means
`__fish_seen_subcommand_from` will give too many false-positives, while
`[ (count $cmd) -eq 2 ]` will give too many false-negatives.
Instead go through all arguments and check if they are in that list of
options that can be before a command and skip the argument for them, if
any.
This is to the benefit of systems with ancient GNU sed, which does not
recognize "-E", but only "-r".
Fixes#2305 - even if it doesn't replace all `sed -E` invocations in the
codebase, the others are unlikely to occur on CentOS and other similarly
crusty systems.
`__fish_apm_using_command` was incorrectly taking lists of commands, new function added to support multiple a command having synonyms.
Simplify switch statement
Also remove superfluous function.
Allow for multiple completions after a command
Useful for removing packages, will complete for more than one.
Code improvements
`sort -u | uniq` is completely redundant, calling grep for every
status-pair is unnecessary, `contains` doesn't take the word "in" as
special.
None of these are critical and there's basically no performance benefit
since this function is utterly dominated by hg calls.
This doesn't add anything except slowing the function down by about
33%. Checking for a branch is just as good and that is displayed in the
prompt anyway.
According to the newer code below:
xdg_data_home = os.getenv('XDG_DATA_HOME', '~/.local/share')
the actual default path is ~/.local/share/fish/generated_completions/
This is used in at least 4 places, all of which have a bug in that they
print "options" as a valid repo. It seems better to fix it once,
especially given that there are tons of AUR helpers and pacman wrappers,
all of which might need this info.
net_tools, which provides `ifconfig` and `netstat`, among other things,
has last been updated in 2013. This means `ifconfig` on linux is
basically dead.
Instead of ifconfig, use `ip` (from iproute2), which is much more powerful and
provides a much more annoying commandline syntax.
Instead of netstat, just look at /sys/class/net.
fish_user_key_bindings is the user's, and they should know if they want
vi-ish bindings or emacs-ish (or nano-ish). If they want to define
multiple, they can also do that (e.g. via checking what
$fish_key_bindings is set to).
Fixes#2254
CC @kballard
This doesn't work with fish_config.
For terlar and pythonista, remove unnecessary color setting.
For informative+git and pythonista, move variable setup into fish_prompt
Fixes#1141
See #1925: This allows users to disable the cnf-logic which can be quite
slow on small hardware (like a raspberry pi).
Squashed commit of the following:
commit 742a59e30d8db24b6bb5067d4204d4b5cc01c1c3
Author: Fabian Homborg <FHomborg@gmail.com>
Date: Sun Aug 30 18:23:41 2015 +0200
Erase startup cnf-handler early
Simplifies the code a bit - in particular it removes the special-casing
from the startup handler.
commit 638a97e7f31f302b65e044c93c638c03a69e31f5
Author: Fabian Homborg <FHomborg@gmail.com>
Date: Mon Aug 24 20:14:46 2015 +0200
Make overriding cnf-handler work
Do this by renaming the __fish_command_not_found_handler used during
startup to __fish_startup_command_not_found_handler. That allows us to
check if __fish_command_not_found_handler has been defined and skip the
setup of the normal one.
Now disabling cnf-handling can be done via defining an empty
__fish_command_not_found_handler in config.fish
This adds a special colorscheme and prompt function guaranteed to work
on a VT and activates them automatically if $TERM = "linux".
set_color is overridden to only allow the 8 colors VTs have (under the
assumption those are always the same) and the color variables are
shadowed with global ones so they don't pollute our nice capable terms.
This is already done by fish before calling the completion.
It breaks completion with combiners (#2025) and also with wrappers.
(This does not include git because that's better solved in #2145)
There are two main problems in the existing Fossil autocompletion that this
patch solves:
* Because Fossil lacks an alias system similar to those in Hg and Git,
wrapper scripts are common, and aliasing them to `fossil` is also fairly
common. The lack of the `command fossil` pattern in the completions script
meant that the actual fossil command might not be called, but rather the
alias. This problem has been fixed by introducing a __fish_fossil command,
similar to the __fish_hg and __fish_git commands in those completion shells,
that does this, and converting all explicit fossil calls in the completion
script to use __fish_fossil instead
* Because there's now a centralized location for calling Fossil, I also moved
all of the repetitive stderr redirects that function.
This results in more robust and cleaner code.
This was too simplistic, among other things it completed things that
looked like key ids but weren't, didn't turn "\x3a" back into
colons (which made the argument invalid)....
gpg is weird.
Might fix#2150
Bit one: Make all the fossil command invocations throw away stderr so we don't
get annoying messages when not in a repository.
Also:
- Move checkout into alphabetical order.
- Fix ls to complete against tags for -r option, not no option.
- Add missing option to delete command.
- Make commit complete against modified files.
- Make add only complete against extra files.
- Remove now ununused function to list extra & modified files.
- Add -f option in a number of places where it seemd appropriate.
__fish_complete_mime used in that way is a no-op on current fish anyway,
and emacs is by no means useful for just text files (it can also view
PDFs, images, ...).
Otherwise this completion currently only offers options, not arguments.
For most these are pretty much incompletable (lisp code, for example),
and for others it's just not all that useful.
Signed-off-by: David Adam <zanchey@ucc.gu.uwa.edu.au>
This used to be a function because we didn't have complete -w
Use that and it becomes a bit simpler.
This also simplifies the code in a few other ways (like removing a
useless-use-of-cat)
and adds comments about a few edgecases.
New sample prompt from Acidhub (github.com/acidhub)
This prompt show user|path (full), and a small symbol to
show last command status.
If in a git repository, it's show after the path several
symbols to indicate the branch status and the branch name.
Very handy to me so far.
Signed-off-by: Fernando Manfredi <contact@acidhub.click>
changed `function __trap_handler_EXIT --on-exit %self` to `function __trap_handler_EXIT --on-process-exit %self`
I'm guessing the on-exit syntax was from an older version? Trapping EXIT with that syntax caused errors.
The following behaviour is added:
- an empty pushd exchanges the top two directories in the stack;
- pushd +<n> rotates the stack so that the n-th directory (counting from the left of the list shown by dirs, starting with zero) is at the top;
- pushd -<n> rotates the stack so that the nth directory (counting from the right of the list shown by dirs, starting with zero) is at the top.
1. When run with no arguments, make abbr do the equivalent
of `abbr --show`
2. Enable "implicit add", e.g. `abbr gco git checkout`
3. Teach `abbr --show` to not use quotes for simple cases
4. Teach abbr to output -- when the abbreviation has
leading dashes
Add some basic tests to abbr too.
Add a new function fish_mode_prompt which (if it is defined) has its output
prepended to the left prompt. Rather than replacing the prompt wholesale, make
fish_vi_mode enable this function by setting a variable __fish_vi_mode. This
enables vi mode to interoperate nicely with custom prompts. Users who want
to change how the mode is reported can either redefine this function or
erase it entirely. Fixes#1988.
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
Notification is sent using an OSC 777 escape sequence as described at
http://known.phyks.me/2014/local-notifications-for-weechat-and-urxvt.
The specific notification is crafted to match that emitted by bash
when running under Fedora 22 with the "vte-profile" RPM installed.
See the code for "__vte_prompt_command" starting at
http://pkgs.fedoraproject.org/cgit/vte291.git/tree/vte291-command-notify.patch#n307
to see exactly what bash produces. My approach is, however, a bit
more paranoid about control characters embedded in commands.
Gnome-terminal 3.16 responds to this escape sequence by posting a
desktop notification if the containing terminal window does not have
focus. This lets the user know that a long-running background command
has completed. Job notification is promoted as a Fedora 22 feature
(http://fedoramagazine.org/terminal-job-notifications-in-fedora-22-workstation/),
so it would be good for fish users to be benefit from it.
Conversely, anyone who does not want this feature can use "functions
--erase __notify_vte_command_completed" to turn it off.
With the fix for #365, fish_command_not_found event handlers
receive the command and all of its arguments. But commands
like /usr/lib/command-not-found expect only the command name.
So when invoking an external command, just pass the command
name, not all of the arguments.
In 73f344f41b, we allowed autoloaded functions to be deleted.
For some reason, funcsave immediately deletes the function it
creates. This previously did very little, since the function would
immediately be re-autoloaded, but with the fix for 73f344f41b
the function gets tombstoned. So the effect is that funcsave
makes the function disappear! This simply removes the erase call,
which dates back to fish 1.x.
It seems that `ul` can't handle the escape sequences for bold text that `nroff` generates on my system. Fixed by either removing `| ul`, or adding `-c` to the `nroff` command.
Needs testing for old (OSX?) versions of nroff.
Unfortunately, list-unit-files doesn't understand --state=loaded
This needs a new function to explicitly use list-units
This reverts commit 9f521b7694.