Search code examples
ubuntuenvironment-variablesglobal-variablesfishcolor-scheme

System-wide default color scheme for fish shell running on Ubuntu


I would like to make certain fish color scheme available to all users of a certain computer running Ubuntu, as a user on the system reported that the default fish color scheme is too dark for them to view over PuTTY, when SSHing into the system from a Windows box. Setting a color scheme for a specific user involves saving a bunch of universal variables into the file $HOME/.config/fish/fish_variables. In the case of a color scheme, the file would contain lines such as

SETUVAR fish_color_autosuggestion:707A8C
SETUVAR fish_color_cancel:\x2d\x2dreverse
SETUVAR fish_color_command:5CCFE6
SETUVAR fish_color_comment:5C6773
SETUVAR fish_color_cwd:73D0FF
SETUVAR fish_color_cwd_root:red
SETUVAR fish_color_end:F29E74
SETUVAR fish_color_error:FF3333
SETUVAR fish_color_escape:95E6CB
SETUVAR fish_color_history_current:\x2d\x2dbold
SETUVAR fish_color_host:normal
SETUVAR fish_color_host_remote:\x1d
SETUVAR fish_color_keyword:\x1d
SETUVAR fish_color_match:F28779
SETUVAR fish_color_normal:CBCCC6
SETUVAR fish_color_operator:FFCC66
SETUVAR fish_color_option:\x1d
SETUVAR fish_color_param:CBCCC6
SETUVAR fish_color_quote:BAE67E
SETUVAR fish_color_redirection:D4BFFF
SETUVAR fish_color_search_match:\x2d\x2dbackground\x3dFFCC66
SETUVAR fish_color_selection:\x2d\x2dbackground\x3dFFCC66
SETUVAR fish_color_status:red
SETUVAR fish_color_user:brgreen
SETUVAR fish_color_valid_path:\x2d\x2dunderline
SETUVAR fish_key_bindings:fish_default_key_bindings
SETUVAR fish_pager_color_background:\x1d
SETUVAR fish_pager_color_completion:normal
SETUVAR fish_pager_color_description:B3A06D
SETUVAR fish_pager_color_prefix:normal\x1e\x2d\x2dbold\x1e\x2d\x2dunderline
SETUVAR fish_pager_color_progress:brwhite\x1e\x2d\x2dbackground\x3dcyan
SETUVAR fish_pager_color_secondary_background:\x1d
SETUVAR fish_pager_color_secondary_completion:\x1d
SETUVAR fish_pager_color_secondary_description:\x1d
SETUVAR fish_pager_color_secondary_prefix:\x1d
SETUVAR fish_pager_color_selected_background:\x2d\x2dbackground\x3dFFCC66
SETUVAR fish_pager_color_selected_completion:\x1d
SETUVAR fish_pager_color_selected_description:\x1d
SETUVAR fish_pager_color_selected_prefix:\x1d

I figured that the same would apply for system-wide fish settings, so I saved the above lines into /etc/fish/fish_variables, and logged in as a test user. However, the color scheme of the test user was not updated to the above one.

What would I need to do to set a brighter default color scheme for all users of fish shell on Ubuntu?

Edit

It did occur to me that I could simply export non-universal variables with the same names in /etc/fish/config.fish by using set -x variable_name value, but that seems a bit dirty, and I'm a bit concerned the scoping rules might mess with any settings a user might themselves wish to make. Comments on this?


Solution

  • I saved the above lines into /etc/fish/fish_variables

    There is no /etc/fish/fish_variables, fish only reads the universal variables from the user's directory.

    It did occur to me that I could simply export non-universal variables with the same names in /etc/fish/config.fish by using set -x variable_name value, but that seems a bit dirty, and I'm a bit concerned the scoping rules might mess with any settings a user might themselves wish to mak

    You can put the variables into /etc/fish/config.fish (or a file in /etc/fish/conf.d as long as it ends in ".fish"), but exporting them isn't necessary.

    You would want to make them global - set -g, not set -x.

    Of course this means a user would also have to use global variables.

    An alternative is that you set the variables only if they haven't been set yet:

    set -q fish_color_comment
    or set -g fish_color_comment 5C6773