Commit graph

125 commits

Author SHA1 Message Date
Fabian Homborg
db63be7909 Add support for bracketed paste
This is a terminal feature where pastes will be "bracketed" in
\e\[200~ and \e\[201~.

It is more of a "security" measure (since particularly copying from a
browser can copy text different from what the user sees, which might
be malicious) than a performance optimization.

Work towards #967.
2017-03-06 00:19:46 +01:00
Fabian Homborg
9598218a94 Don't call fish in the background to generate completions
Fixes #3803 even harder.
2017-02-12 14:56:36 +01:00
Kurtis Rader
0970cc8736 time for another make style-all 2017-02-07 21:52:35 -08:00
David Adam
49e98cde4c Merge branch 'Integration_2.5.0' 2017-02-03 21:14:40 +08:00
Kurtis Rader
06282f02fd don't run fish_update_completions in unit tests
Running `fish_update_completions` in unit tests is not needed and
hideously expensive. To the point it can cause flakey test behavior.
2017-01-29 18:00:48 -08:00
Fabian Homborg
5996962749 Use normal fish_title in Terminal.app
This needs to be done only for new enough Terminal.app versions, which
we don't have enough time to figure out for 2.5.0.

Fixes #3629.
2017-01-19 14:38:11 +01:00
mathbunnyru
7a80610300 Delete trailing spaces 2017-01-15 14:57:21 -08:00
Kurtis Rader
11a60c8374 reformat all fish scripts
I hate doing this but I am tired of touching a fish script as part of
some change and having `make style` radically change it. Which makes
editing fish scripts more painful than it needs to be. It is time to do
a wholesale reformatting of these scripts to conform to the documented
style as implemented by the `fish_indent` program.
2016-11-27 21:27:22 -08:00
Fabian Homborg
9ad1b86e4e Reset bindings if the new value was bogus.
See #3590.
2016-11-27 14:17:24 +01:00
Aaron Gyes
4f6ac06b21 Don't automatically generate completions without python
This is doomed to cause a messy error on every launch on any systems
that are using fish without python installed. Fixes #3588
2016-11-27 02:00:21 -08:00
Aaron Gyes
18cc06b38f Don't no-op terminal.app title if it's customized
We only want to override the internal fish hardcoded title.
Fixes #3578
2016-11-26 20:02:51 -08:00
Aaron Gyes
668de88e69 Supress fish_title only for Terminal.app
VTE terminals apparently do not use the OSC sequence to compose
title components.
2016-10-23 12:02:01 -07:00
Aaron Gyes
c7e26e494e Fix Terminal.app title
Defining fish_title here is too late because there will already be a
title set. Work around issue by clearing it at same time.
2016-10-22 10:47:46 -07:00
Aaron Gyes
2c8bc05826 Skip OSC 7 inside emacs, let VTE/Terminal do title
these modern terminals both compose a nicer title if we don't try to provide a custom one (no path in title twice, "fish" in title twice) - and the user can configure which components they'd like in their terminal inside the terminal preferences.

Also make test "$VTE_VERSION" -ge .. work once I commit `test` strtoi
fix - the trick is to add a zero before it so the numeric comparison
works even if it's empty.

Fixes #107
2016-09-19 18:44:44 -07:00
Aaron Gyes
be0bd999ad Commit __fish_config_interactive where I have it
Nuke the cool surprise deletion feature
2016-09-18 04:18:33 -07:00
Kurtis Rader
f9115b5ef1 fix use of subcommand in __fish_config_interactive.fish 2016-09-12 18:47:59 -07:00
Fabian Homborg
c57b30cba1 Check /etc/os-release for Suse's CNF-handler
This has the same name and path as ubuntu's, but takes less arguments.

So we need to actually find if the distro thinks it is suse, and then
use it.

Fixes #3366.
2016-09-12 22:59:35 +02:00
Aaron Gyes
90e535f66f Update pager colors, tweak pager.cpp
Adds a color reset thing, to ensure fish tries to use hard colors during
testing.

Also, work on a discrepancy (not introduced by my changes, afaik) when
with some combinations of color settings, and usage of --bold, caused super
flakey color paninting in the pager. Downwards movements that trigger
scrolling vs. upwards movement in the pager would only apply bold to
selections when moving upwards. The bold state of the command completions in
the pager was flipping flops on and off, depending on if there is a description
on the preceding line.

Implement a lame fix by reseting the color to normal and applying a
different style on the rightmost ')' which seems to be what was influencing it.

Makes fish use terminfo for coloring the newline glich char.
2016-09-11 03:04:53 -07:00
Aaron Gyes
af95813514 Merge branch 'master' of https://github.com/fish-shell/fish-shell into colorfix 2016-09-10 15:09:12 -07:00
Aaron Gyes
82b298dcc5 __fish_config_interactive: remove Linux exception
And update colors.
2016-09-10 15:07:58 -07:00
Kurtis Rader
cfefaaf4ee revert the --shadow-builtin flag
Implementing the --shadow-builtin flag has proven to be highly controversial.
Revert the introduction of that flag to the `function` command. If someone
shoots themselves in the foot by redefining a builtin as a function that's
their problem and not our responsibility to protect them from doing so.

Fixes #3319
2016-08-24 22:56:19 -07:00
Fabian Homborg
790968120d Give up earlier when we can't find default key bindings.
This relates to #3302.
2016-08-15 22:39:51 +02:00
Aaron Gyes
b77e2a67f8 Only do fish_greeting if interactive
Even if __fish_config_interactive, it can be shown when a script
uses `read`.

Fixes #3261, #1401.
2016-07-30 22:47:17 -07:00
Aaron Gyes
3669805627 Improve compatibility with 0-16 color terminals.
Fish assumed that it could use tparm to emit escapes to set colors
as long as the color was under 16 or max_colors from terminfo was 256::

 if (idx < 16 || term256_support_is_native()) {
    // Use tparm to emit color escape
    writembs(tparm(todo, idx);

If a terminal has max_colors = 8, here is what happenened, except
inside fish:

 > env TERM=xterm tput setaf 7 | xxd
   00000000: 1b5b 3337 6d                             .[37m
 > env TERM=xterm tput setaf 9 | xxd
   00000000: 1b5b 3338 6d                             .[39m

The first escape is good, that second escape is not valid.
Bright colors should start at \e[90m:

 > env TERM=xterm-16color tput setaf 9 | xxd
   00000000: 1b5b 3931 6d                             .[91m

This is what caused "white" not to work in #3176 in Terminal.app, and
obviously isn't good for real low-color terminals either.

So we replace the term256_support_is_native(), which just checked if
max_colors is 256 or not, with a function that takes an argument and
checks terminfo for that to see if tparm can handle it. We only use this
test, because otherwise, tparm should be expected to output garbage:

 /// Returns true if we think tparm can handle outputting a color index
 static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; }
...

 if (term_supports_color_natively(idx) {

And if terminfo can't do it, the "forced" escapes no longer use the fancy
format when handling colors under 16, as this is not going to be compatible with
low color terminals. The code before used:

 else {
     char buff[16] = "";
     snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);

I added an intermediate format for colors 0-15:

 else {
     // We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
     char buff[16] = "";
     if (idx < 16) {
         snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
     } else {
         snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
     }

Restores harmony to white, brwhite, brblack, black color names.
We don't want "white" to refer to color color #16, but to the
standard color #8. #16 is "brwhite".

Move comments from output.h to output.cpp

Nuke the config.fish set_color hack for linux VTs.

Sync up our various incomplete color lists and fix all color values.
Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing!

Using this table:
 <http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html>

Fixes #3176
2016-07-24 17:02:29 -07:00
ridiculousfish
46fba342db Revert "Only show greeting on interactive login sessions"
This reverts commit 3d0ea5fe79.
2016-07-24 16:39:44 -07:00
ridiculousfish
5eedb0ee9c Revert "Only show fish greeting for interactive logins"
This reverts commit 3a7a6f16ef.
2016-07-24 16:39:43 -07:00
ridiculousfish
325f047803 Revert "Update __fish_config_interactive.fish"
This reverts commit ec292ec51b.
2016-07-24 16:39:41 -07:00
ridiculousfish
c76f896f69 Revert "Revert "Only show greeting on interactive login sessions""
This reverts commit 88688d02b2.
2016-07-24 16:39:40 -07:00
Aaron Gyes
88688d02b2 Revert "Only show greeting on interactive login sessions"
This reverts commit 3d0ea5fe79.
2016-07-24 03:53:27 -07:00
Aaron Gyes
ec292ec51b Update __fish_config_interactive.fish 2016-07-24 01:42:58 -07:00
Aaron Gyes
3a7a6f16ef Only show fish greeting for interactive logins
This is a regression introduced by 834ebef53c
Bolster with a check for only login sessions too -- hopefully makes it
less annooying on subshells in general.

Fixes #3261
2016-07-24 00:05:05 -07:00
Aaron Gyes
3d0ea5fe79 Only show greeting on interactive login sessions
Fixes #3261
2016-07-23 23:33:20 -07:00
Aaron Gyes
cfe3fc301c string escape some eval calls 2016-06-15 21:41:37 -07:00
Jorge Bucaran
aee9d2c9d7 Do not hardcode RGB values in color definitions. 2016-06-01 21:50:19 -07:00
Fabian Homborg
60317190bd Check validity of fish_key_bindings
This potentially leads to an unusable session (when fish_key_bindings is
set in config.fish to a value without corresponding function), so we
should take care.
2016-05-22 19:56:47 +02:00
Kurtis Rader
51468b7646 add function --shadow-builtin flag
It's currently too easy for someone to bork their shell by doing something
like `function test; return 0; end`. That's obviously a silly, contrived,
example but the point is that novice users who learn about functions are
prone to do something like that without realizing it will bork the shell. Even
expert users who know about the `test` builtin might forget that, say, `pwd`
is a builtin.

This change adds a `--shadow-builtin` flag that must be specified to
indicate you know what you're doing.

Fixes #3000
2016-05-14 20:38:32 -07:00
Kurtis Rader
3626c39398 fix the style of several functions
I'm going to modify these functions as part of dealing with issue #3000
and don't want those changes to be masked by running the files through
`make style`.
2016-05-08 16:27:15 -07:00
Jorge Bucaran
08c29727e0 Add missing color definitions to __fish_init_1_50_0 reset. (#2987)
* Add missing color definitions to __fish_init_1_50_0 reset.

The values where determined by inspecting the values of:

* fish_color_end
* fish_color_user
* fish_color_host

after resetting the color theme via fish_config.

* Add documentation for fish_color_user and fish_color_host.
2016-05-01 11:58:43 +02:00
Fabian Homborg
8558561650 Move 24bit setup into config.fish
Fixes #2941.
2016-04-18 14:19:34 +02:00
Fabian Homborg
4b2495f28f Skip greeting on empty variable
It used to be that way and we recommend `set fish_greeting` (i.e. set to
empty) in the docs - possibly since we check if the variable is defined
on upgrade.
2016-01-18 21:56:59 +01:00
Fabian Homborg
7a8cbcda06 Disable 24bit-color on neovim's terminal
Unfortunately, nvim will, even when running in a terminal that supports
it, swallow the sequences whole, rendering the displayed text _white_.

This means falling back to 256 colors is the lesser evil as at least a
blue-ish color will display as blue while a red-ish will be red, instead
of both showing white.

nvim's behavior does _not_ change depending on
$NVIM_TUI_ENABLE_TRUE_COLOR or any other option I could find and neovim-qt
exhibits the same behavior.

Fixes #2600.
2016-01-14 15:17:49 +01:00
Nathan Zadoks
92d0d98a24 Pass the full argv to the NixOS command-not-found handler
This patch is currently floated from the NixOS side as part of
https://github.com/NixOS/nixpkgs/pull/12000, but prior versions of the
hook ignore anything but the first argument anyway, so this is
backwards-compatible.
2016-01-03 14:32:12 +01:00
Fabian Homborg
1a12071a48 Immediately define command-not-found handler
This skips the weird dance where we'd define a simple handler and then
later overwrite with a fancier one, once the first event came in.

It turns out that isn't necessary, as it doesn't actually improve
startup speed because the checks needed to define fancier handlers are fast.

In case we are non-interactive, still define the simple handler, and
keep the default handler for users to switch to.
2015-12-30 16:26:54 +01:00
Fabian Homborg
759b45ad79 Remove temporary set_default function
This could potentially delete a user-defined set_default on first start.

It's also trivially done with set -q var; or set -U var val.
2015-12-30 12:49:44 +01:00
Fabian Homborg
834ebef53c Simplify greeting
We have already confirmed we're interactive, and `echo` is a builtin now.
2015-12-29 15:58:48 +01:00
Fabian Homborg
6c8518dd10 Update vte cwd on launch
Fixes #2418
2015-12-12 12:22:08 +01:00
Fabian Homborg
b73bf53bd3 Enable 24-bit mode for selected terminals
Unfortunately, there's no standard way to detect support (importantly,
terminfo doesn't encode it), but there's a variety of terminals that
support it that we can detect.

It's better than letting this functionality go to waste.

Check KONSOLE_PROFILE_NAME instead of DBUS_SESSION because Konsole can be compiled without dbus support.

Check ITERM_SESSION_ID's format for 24bit support

This has changed since the last release, just like 24bit support. So if
we check one, we get the other.
2015-12-10 12:47:45 +01:00
Fabian Homborg
b231ab7238 Allow set_color options in general for linux VTs 2015-09-10 15:12:02 +02:00
Fabian Homborg
40df11b162 Also allow bold, underline and printing colors in linux kernel VTs
bold works, printing colors doesn't change anything and underline
doesn't _break_.
2015-09-10 12:27:09 +02:00
Fabian Homborg
5f080fcfc9 Load fish_user_key_bindings for any binding (including vi)
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
2015-09-01 11:50:50 +02:00