Files
fish-shell/share/themes/default.theme
Johannes Altmanninger 190d367bc4 Use globals for color variables, react to light/dark mode
Implicitly-universal variables have some downsides:
- It's surprising that "set fish_color_normal ..."
  and "set fish_key_bindings fish_vi_key_bindings" propagate to other
  shells and persist, especially since all other variables (and other
  shells) would use the global scope.
- they don't play well with tracking configuration in Git.
- we don't know how to roll out updates to the default theme (which is
  problematic since can look bad depending on terminal background
  color scheme).

It's sort of possible to use only globals and unset universal variables
(because fish only sets them at first startup), but that requires
knowledge of fish internals; I don't think many people do that.

So:
- Set all color variables that are not already set as globals.
  - To enable this do the following, once, after upgrading:
    copy any existing universal color variables to globals, and:
    - if existing universal color variables exactly match
      the previous default theme, and pretend they didn't exist.
    - else migrate the universals to ~/.config/fish/conf.d/fish_frozen_theme.fish,
      which is a less surprising way of persisting this.
    - either way, delete all universals to do the right thing for most users.
- Make sure that webconfig's "Set Theme" continues to:
  - instantly update all running shells
    - This is achieved by a new universal variable (but only for
      notifying shells, so this doesn't actually need to be persisted).
      In future, we could use any other IPC mechanism such as "kill -SIGUSR1"
      or if we go for a new feature, "varsave" or "set --broadcast", see
      https://github.com/fish-shell/fish-shell/issues/7317#issuecomment-701165897
      https://github.com/fish-shell/fish-shell/pull/8455#discussion_r757837137.
  - persist the theme updates, completely overriding any previous theme.
    Use the same "fish_frozen_theme.fish" snippet as for migration (see above).
    It's not meant to be edited directly. If people want flexibility
    the should delete it.
    It could be a universal variable instead of a conf snippet file;
    but I figured that the separate file looks nicer
    (we can have better comments etc.)
- Ask the terminal whether it's using dark or light mode, and use an
  optimized default. Add dark/light variants to themes,
  and the "unknown" variant for the default theme.
  Other themes don't need the "unknown" variant;
  webconfig already has a background color in context,
  and CLI can require the user to specify variant explicitly if
  terminal doesn't advertise colors.
- Every variable that is set as part of fish's default behavior
  gets a "--label=default" tacked onto it.

  This is to allow our fish_terminal_color_theme event handler to
  know which variables it is allowed to update. It's also necessary
  until we revert 7e3fac561d (Query terminal only just before reading
  from it, 2025-09-25) because since commit, we need to wait until
  the first reader_push() to get query results.  By this time, the
  user's config.fish may already have set variables.

  If the user sets variables via either webconfig, "fish_config theme
  {choose,save}", or directly via "set fish_color_...", they'd almost
  always remove this label.
- For consistency, make default fish_key_bindings global
  (note that, for better or worse, fish_add_path still remains as
  one place that implicitly sets universal variables, but it's not
  something we inject by default)
- Have "fish_config theme choose" and webconfig equivalents reset
  all color variables. This makes much more sense than keeping a
  hardcoded subset of "known colors"; and now that we don't really
  expect to be deleting universals this way, it's actually possible
  to make this change without much fear.

Should have split this into two commits (the changelog entries are
intertwined though).

Closes #11580
Closes #11435
Closes #7317
Ref: https://github.com/fish-shell/fish-shell/issues/12096#issuecomment-3632065704
2025-12-14 17:03:03 +01:00

101 lines
3.1 KiB
Plaintext

# name: fish default
[light]
# preferred_background: ffffff
fish_color_normal 000000
fish_color_autosuggestion 7f7f7f
fish_color_cancel ffffff --background=000000
fish_color_command 0000ee
fish_color_comment cd0000
fish_color_cwd 00cd00
fish_color_cwd_root cd0000
fish_color_end 00cd00
fish_color_error ff0000
fish_color_escape 00cdcd
fish_color_history_current --bold
fish_color_host 000000
fish_color_host_remote a0a000
fish_color_keyword 0000ee
fish_color_operator 00cdcd
fish_color_option 00a0a0
fish_color_param 00a0a0
fish_color_quote a0a000
fish_color_redirection 00a0a0 --bold
fish_color_search_match 060606 --bold --background=cdcdcd
fish_color_selection 060606 --bold --background=cdcdcd
fish_color_status cd0000
fish_color_user 00cd00
fish_color_valid_path --underline
fish_pager_color_description a0a000 --italics
fish_pager_color_prefix 000000 --bold --underline
fish_pager_color_progress ffffff --background=00a0a0 --bold
fish_pager_color_selected_background --background=cdcdcd
fish_pager_color_selected_prefix 060606 --bold
fish_pager_color_selected_completion 060606 --bold
fish_pager_color_selected_description 060606 --bold --italics
[dark]
# preferred_background: 000000
fish_color_normal ffffff
fish_color_autosuggestion 9f9f9f
fish_color_cancel 000000 --background=ffffff
fish_color_command 5c5cff
fish_color_comment cd5c5c
fish_color_cwd 00ff00
fish_color_cwd_root 00cd00
fish_color_end 00ff00
fish_color_error ff0000
fish_color_escape 00ffff
fish_color_history_current --bold
fish_color_host ffffff
fish_color_host_remote cdcd00
fish_color_keyword 5c5cff
fish_color_operator 00ffff
fish_color_option 00cdcd
fish_color_param 00cdcd
fish_color_quote cdcd00
fish_color_redirection 00cdcd --bold
fish_color_search_match ffffff --bold --background=7f7f7f
fish_color_selection ffffff --bold --background=7f7f7f
fish_color_status 00cd00
fish_color_user 00ff00
fish_color_valid_path --underline
fish_pager_color_description cdcd00 --italics
fish_pager_color_prefix ffffff --bold --underline
fish_pager_color_progress ffffff --background=00cdcd --bold
fish_pager_color_selected_background --background=7f7f7f
fish_pager_color_selected_prefix ffffff --bold
fish_pager_color_selected_completion ffffff --bold
fish_pager_color_selected_description ffffff --bold --italics"
[unknown]
# 16 color palette
fish_color_normal normal
fish_color_autosuggestion brblack
fish_color_cancel -r
fish_color_command normal
fish_color_comment red
fish_color_cwd green
fish_color_cwd_root red
fish_color_end green
fish_color_error brred
fish_color_escape brcyan
fish_color_history_current --bold
fish_color_host normal
fish_color_host_remote yellow
fish_color_keyword normal
fish_color_operator brcyan
fish_color_option cyan
fish_color_param cyan
fish_color_quote yellow
fish_color_redirection cyan --bold
fish_color_search_match white --background=brblack --bold
fish_color_selection white --background=brblack --bold
fish_color_status red
fish_color_user brgreen
fish_color_valid_path --underline
fish_pager_color_description yellow --italics
fish_pager_color_prefix normal --bold --underline
fish_pager_color_progress brwhite --background=cyan --bold
fish_pager_color_selected_background -r