No description
Find a file
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
.github Use h2s in PULL_REQUEST_TEMPLATE.md 2016-07-22 18:19:57 -07:00
build_tools Only show fish greeting for interactive logins 2016-07-24 00:05:05 -07:00
debian
doc_src correct handling of history args 2016-07-20 21:18:48 -07:00
etc It's status --is-interactive (#3086) 2016-05-29 12:24:24 +02:00
fish.xcodeproj Fix fish_config in .app 2016-07-01 04:43:57 -07:00
osx Merge branch 'Integration_2.3.1' 2016-07-03 22:18:55 +08:00
pcre2-10.21 Restore aclocal.m4 2016-07-05 07:58:00 -07:00
po trivial locale cleanups 2016-06-14 19:57:07 -07:00
share Improve compatibility with 0-16 color terminals. 2016-07-24 17:02:29 -07:00
src Improve compatibility with 0-16 color terminals. 2016-07-24 17:02:29 -07:00
tests correct handling of history args 2016-07-20 21:18:48 -07:00
.clang-format config clang-format to ignore oclint pragmas 2016-05-04 18:08:26 -07:00
.cppcheck.rule implement custom cppcheck rules 2016-06-17 20:16:21 -07:00
.gitattributes Tell Linguist about our vendored code. 2016-07-09 11:59:32 -07:00
.gitignore enhance the key_reader program 2016-06-19 19:43:45 -07:00
.oclint a couple more oclint RAII error suppressions 2016-07-20 23:05:08 -07:00
.travis.yml Travis: restore clang with trusty & included clang 2016-06-20 03:27:32 -07:00
CHANGELOG.md Merge branch 'Integration_2.3.1' 2016-07-03 22:18:55 +08:00
config.guess
config.sub
configure.ac remove dependency on dcgettext() 2016-06-05 18:52:19 -07:00
CONTRIBUTING.md implement custom cppcheck rules 2016-06-17 20:16:21 -07:00
COPYING
Dockerfile
Doxyfile Improve comments, update Doxyfile 2016-06-12 11:19:44 -07:00
Doxyfile.help
Doxyfile.user
fish.pc.in Rename "snippets" to "conf" internally, and document them as snippets 2016-04-06 09:33:09 +08:00
fish.spec.in fish.spec: hostname dependency for openSUSE 2016-04-28 08:20:58 +08:00
install-sh
lexicon_filter.in Fix documentation 2016-07-16 20:22:41 -07:00
Makefile.in Fix CHANGELOG.md install 2016-07-18 07:00:35 -07:00
README.md Add further instuction for chsh (logout) to README (#3251) 2016-07-17 18:46:32 +02:00

fish - the friendly interactive shell Build Status

fish is a smart and user-friendly command line shell for OS X, Linux, and the rest of the family. fish includes features like syntax highlighting, autosuggest-as-you-type, and fancy tab completions that just work, with no configuration required.

For more on fish's design philosophy, see the design document.

Quick Start

fish generally works like other shells, like bash or zsh. A few important differences can be found at http://fishshell.com/docs/current/tutorial.html by searching for the magic phrase "unlike other shells".

Detailed user documentation is available by running help within fish, and also at http://fishshell.com/docs/current/index.html

Building

Fish can be built using a C++11 environment but only requires C++03. It builds successfully with g++ 4.2 or later, and with clang. This allows fish to run on older systems such as OS X Snow Leopard (released in 2009).

Fish can be built using autotools or Xcode. autoconf 2.60 or later is required to build from git versions, but is not required for releases.

fish depends on a curses implementation, such as ncurses. The headers and libraries are required for building.

fish requires PCRE2 due to the regular expression support contained in the string builtin. A copy is included with the source code, and will be used automatically if it does not already exist on your system.

fish requires gettext for translation support.

Building the documentation requires Doxygen 1.8.7 or newer.

Autotools Build

autoconf [if building from Git]
./configure
make [gmake on BSD]
sudo make install

Xcode Development Build

  • Build the base target in Xcode
  • Run the fish executable, for example, in DerivedData/fish/Build/Products/Debug/base/bin/fish

Xcode Build and Install

xcodebuild install
sudo ditto /tmp/fish.dst /

Help, it didn't build!

If fish reports that it could not find curses, try installing a curses development package and build again.

On Debian or Ubuntu you want:

sudo apt-get install build-essential ncurses-dev libncurses5-dev gettext autoconf

On RedHat, CentOS, or Amazon EC2:

sudo yum install ncurses-devel

Runtime Dependencies

fish requires a curses implementation, such as ncurses, to run.

fish requires PCRE2 due to the regular expression support contained in the string builtin. A bundled version will be compiled in automatically at build time if required.

fish requires a number of utilities to operate, which should be present on any Unix, GNU/Linux or OS X system. These include (but are not limited to) hostname, grep, awk, sed, which, and getopt. fish also requires the bc program.

Translation support requires the gettext program.

Some optional features of fish, such as the manual page completion parser and the web configuration tool, require Python.

In order to generate completions from man pages compressed with either lzma or xz, you may need to install an extra Python package. Python versions prior to 2.6 are not supported. For Python versions 2.6 to 3.2 you need to install the module backports.lzma. How to install it depends on your system and how you installed Python. Most Linux distributions should include it as a package named backports-lzma (or similar). From version 3.3 onwards, Python already includes the required module.

Packages for Linux

Instructions on how to find builds for several Linux distros are at https://github.com/fish-shell/fish-shell/wiki/Nightly-builds

Switching to fish

If you wish to use fish as your default shell, use the following command:

chsh -s /usr/local/bin/fish

chsh will prompt you for your password, and change your default shell. Substitute "/usr/local/bin/fish" with whatever path to fish is in your /etc/shells file.

Use the following command if you didn't already add your fish path to /etc/shells.

echo /usr/local/bin/fish | sudo tee -a /etc/shells

To switch your default shell back, you can run:

chsh -s /bin/bash

Substitute /bin/bash with /bin/tcsh or /bin/zsh as appropriate.

You may need to logout/login for the change (chsh) to take effect.

Contributing Changes to the Code

See the Guide for Developers.

Contact Us

Questions, comments, rants and raves can be posted to the official fish mailing list at https://lists.sourceforge.net/lists/listinfo/fish-users or join us on our gitter.im channel or IRC channel #fish at irc.oftc.net. Or use the fish tag on Stackoverflow.

Found a bug? Have an awesome idea? Please open an issue on this github page.