fish-shell icon indicating copy to clipboard operation
fish-shell copied to clipboard

fish_config provides no easy way to use terminal colours

Open akdor1154 opened this issue 9 years ago • 12 comments

Most modern terminals provide a UI to set RGB values for named colours, however fish's default configuration, and all other colour schemes available in fish_config, specifies RGB values for all colours instead of named colours.

(1) IMO default behaviour should be to use named colours for the default colours scheme, so that users can edit their colours in their terminal settings to change fish's appearance.

If (1) is not acceptable, then: (2) it would still be useful to have a "shell colours" theme available in fish_config that uses named colours, so users can easily opt in to the above behaviour.

Finally, if even (2) is not acceptable, then (3) it would be useful to have a "shell colours" palette above the RGB palette, so users can at least build their own scheme that users their shell's native colours without having to edit colorutils.js or specify variable overrides.

Fish 2.3.1 on OS X.

akdor1154 avatar Oct 11 '16 02:10 akdor1154

Note that it is not quite sufficient to just edit the default scheme to use named colours (e.g. "blue", "brblue"), as GET /colors mangles any incoming named colours into RGB values, and as such editing the "current config" with the web UI will once again send RGB values to fish instead of named colours.

akdor1154 avatar Oct 11 '16 02:10 akdor1154

Thanks for filing this. This is certainly a reasonable thing to want to do.

One obstacle is that fish has no easy way of accessing the terminal colors, so the preview won't be accurate.

A second obstacle is that the color picking UI is already very busy, so this might be hard to integrate.

I think if we wanted to do this, the right way is to have a special theme called "Terminal Colors" or something, where the colors would map to named colors instead of RGB. This would enable the feature without complicating the UI much.

Of course, you can always do this manually, e.g. set -U fish_color_command blue. set | grep fish_color will show the list of colors too.

ridiculousfish avatar Oct 13 '16 23:10 ridiculousfish

I wrote a little function to show the colors

function print_fish_colors --description 'Shows the various fish colors being used'
    set -l clr_list (set -n | grep fish | grep color | grep -v __)
    if test -n "$clr_list"
        set -l bclr (set_color normal)
        set -l bold (set_color --bold)
        printf "\n| %-38s | %-38s |\n" Variable Definition
        echo '|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯|'
        for var in $clr_list
            set -l def $$var
            set -l clr (set_color $def ^/dev/null)
            or begin
                printf "| %-38s | %s%-38s$bclr |\n" "$var" (set_color --bold white --background=red) "$def"
                continue
            end
            printf "| $clr%-38s$bclr | $bold%-38s$bclr |\n" "$var" "$def"
        end
        echo '|________________________________________|________________________________________|'\n
    end
end

Looks like this: fish_colors

(Note: Image may contain colors that are no longer used and/or I could possibly have made some up)

Darkshadow2 avatar Oct 14 '16 15:10 Darkshadow2

I asked for this very same feature today in the official chat. I agree that it would be super handy to have a special theme that matches terminal's palette. Customizability matters, plus we have plenty of transparent and blurred terminal nowadays (think of macOS and KDE Plasma) in which a readable theme is essential.

livingsilver94 avatar Dec 29 '18 18:12 livingsilver94

I would like to see this feature implemented as well. To me, it doesn't make much sense that some 3rd party Fish prompts use terminal colors by default but Fish itself does not. That means that if you use a terminal theme that doesn't go well with the supported fish_config colors, you have to set your own colors manually, which is a bit of a pain. I think if Fish used terminal colors by default like Vim, Fzf, etc. do that would be a sane default.

jswny avatar Jul 10 '19 16:07 jswny

You can set -U each of those fish_*color_* variables to ANSI colours. No GUI, but since you're not fine-tuning the colours anyway, it's not a big deal.

For example, I'm testing this scheme right now, and it seems to work reasonably well with the Tango palette in Gnome Terminal:

set -U fish_color_autosuggestion      brblack
set -U fish_color_cancel              -r
set -U fish_color_command             brgreen
set -U fish_color_comment             brmagenta
set -U fish_color_cwd                 green
set -U fish_color_cwd_root            red
set -U fish_color_end                 brmagenta
set -U fish_color_error               brred
set -U fish_color_escape              brcyan
set -U fish_color_history_current     --bold
set -U fish_color_host                normal
set -U fish_color_match               --background=brblue
set -U fish_color_normal              normal
set -U fish_color_operator            cyan
set -U fish_color_param               brblue
set -U fish_color_quote               yellow
set -U fish_color_redirection         bryellow
set -U fish_color_search_match        'bryellow' '--background=brblack'
set -U fish_color_selection           'white' '--bold' '--background=brblack'
set -U fish_color_status              red
set -U fish_color_user                brgreen
set -U fish_color_valid_path          --underline
set -U fish_pager_color_completion    normal
set -U fish_pager_color_description   yellow
set -U fish_pager_color_prefix        'white' '--bold' '--underline'
set -U fish_pager_color_progress      'brwhite' '--background=cyan'

(I'll probably ditch Tango for a similar but brighter pastel variant, and then maybe I'll be able to use more basic colours and less bright ones.)

Vim colorschemes, by the way, usually don't use terminal colours. I don't know about its default, but it sucks so it doesn't matter :)

emarsk avatar Jul 14 '19 19:07 emarsk

@emarsk Thanks, I'll try doing it manually, I agree that that's the best way to go for now.

And yeah you are right most Vim colorschemes don't use terminal colors. The default one does to some extent but like you said it sucks.

jswny avatar Jul 15 '19 01:07 jswny

@emarks Thanks, I'll try doing it manually, I agree that that's the best way to go for now.

And yeah you are right most Vim colorschemes don't use terminal colors. The default one does to some extent but like you said it sucks.

Please check the username spelling on your reply. emarks != emarsk

emarks avatar Jul 15 '19 02:07 emarks

@emarsk Try this vim theme: https://github.com/jeffkreeftmeijer/vim-dim. Uses terminal colors and doesn't suck.

ismay avatar Aug 06 '19 07:08 ismay

Does anyone know the color variable for the ~ (tilda i.e. home directory) operator?

Edited: Found the documentation for them here: https://fishshell.com/docs/current/index.html#variables-color

creeefs avatar Dec 06 '19 02:12 creeefs

This has been open for a while now. Since @emarsk proposed a color scheme that uses named colors, how about using that to implement @akdor1154’s second suggestion?

Using named colors is the best way to have all your terminal applications adapt to a new theme instantly. Allowing people to implement this easily would be very nice to have. And yes, I know it’s easy to create such a theme myself, I’ve been doing that for years. It just seems weird to not have this supported more directly in fish.

ismay avatar Mar 13 '22 12:03 ismay

I think it's a fine idea although it will need some thought into how it displays in the preview.

zanchey avatar Mar 19 '22 12:03 zanchey

The default theme now uses only named colors, have fun.

faho avatar Jul 25 '23 14:07 faho