Search code examples
fish

How to create .theme file in fish?


I see some builtin theme files in /usr/share/fish/tools/web_config/themes

How can I built a file like that and where to put that file? I want to see this theme is fish_config output.

Just to be clear, I have set the colors.

set -l base03  002b36
set -l base02  073642
set -l base01  586e75
set -l base00  657b83
set -l base0   839496
set -l base1   93a1a1
set -l base2   eee8d5
set -l base3   fdf6e3
set -l yellow  b58900
set -l orange  cb4b16
set -l red     dc322f
set -l magenta d33682
set -l violet  6c71c4
set -l blue    268bd2
set -l cyan    2aa198
set -l green   859900

I want to only use these colors. Yes, this is solarized dark theme. I want to customize the builtin Solarized Dark.theme file.


Solution

  • From https://fishshell.com/docs/current/cmds/fish_config.html:

    The themes are loaded from the theme directory shipped with fish or a themes directory in the fish configuration directory (typically ~/.config/fish/themes).

    You can use fish_config theme dump > ~/.config/fish/themes/my.theme to write out your current theme in .theme format. If you have already set the colors how you like it, that's all there is to it.

    If not, you can copy the preset theme file and edit it:

    cp /usr/share/fish/tools/web_config/themes/Solarized\ Dark.theme ~/.config/fish/themes/my.theme
    

    The format is basically just set fish_color_normal value, except without the set and no expansions, so a theme file may look like (snippet for illustration):

    # name: 'Cool Beans'
    # preferred_background: black
    
    fish_color_autosuggestion 666
    fish_color_cancel -r
    fish_color_command normal
    fish_color_comment '888'  '--italics'
    fish_color_cwd 0A0
    fish_color_cwd_root A00
    fish_color_end 009900
    # ... more colors here
    

    The introductory comments are the name to be shown in fish_config, and the background to use when showing it there.

    Because there are no expansions, you'll have to set the actual variables - your set -l base03 002b36 won't work here, you'll have to actually give the variable the value. So it may be easier to do that interactively and dump the theme out.

    Or you can always just make a full script in e.g. ~/.config/fish/conf.d/ that has all scripting powers available - variable expansions, if conditions, etc.