fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Johannes AltmanningerMerge changes to config paths6d0cd3d9b

master
4.9 KiB135 linesraw
1# RUN: fish=%fish %fish %s
2
3function provoke-migration
4    set -U __fish_initialized 3800
5    rm -f \
6        $__fish_config_dir/conf.d/fish_frozen_theme.fish \
7        $__fish_config_dir/conf.d/fish_frozen_key_bindings.fish
8end
9
10function fake-old-uvars
11    for varname in (__fish_theme_variables --universal)
12        set $varname (string match -rv -- '--theme=.*' $$varname)
13    end
14end
15
16set -U
17echo no default universal variables
18# CHECK: no default universal variables
19
20# Existing universal variables are migrated as-is.
21{
22    echo yes | fish_config theme save default-rgb --color-theme=light
23    fake-old-uvars
24    set -U fish_key_bindings fish_vi_key_bindings
25    set -U | head -2
26    # CHECK: fish_color_autosuggestion 7f7f7f
27    # CHECK: fish_color_cancel 'ffffff' '--background=000000'
28    not path is $__fish_config_dir/conf.d/fish_frozen_theme.fish
29    and echo ok
30    # CHECK: ok
31
32    provoke-migration
33    $fish -c __fish_theme_migrate
34    # CHECK: {{\x1b\[1m}}fish:{{\x1b\[m}} {{upgraded.*}}
35    # CHECK: {{.*Color.*no.longer.*universal.*}}
36    # CHECK: Migrated {{.*}} {{\S*}}/xdg_config_home/fish/conf.d/fish_frozen_theme.fish{{\x1b\[m}}
37    # CHECK: {{.*restart.*}}
38    # CHECK: {{.*fish_key_bindings.*no.longer.*universal.*}}
39    # CHECK: Migrated {{.*}} {{\S*}}/xdg_config_home/fish/conf.d/fish_frozen_key_bindings.fish{{\x1b\[m}}
40    # CHECK: {{.*help relnotes.*}}
41    grep -v '^#' $__fish_config_dir/conf.d/fish_frozen_theme.fish | grep . | head -3
42    # CHECK: set --global fish_color_autosuggestion 7f7f7f
43    # CHECK: set --global fish_color_cancel ffffff --background=000000
44    # CHECK: set --global fish_color_command 0000ee
45    grep -v '^#' $__fish_config_dir/conf.d/fish_frozen_key_bindings.fish
46    # CHECK: set --global fish_key_bindings fish_vi_key_bindings
47    # CHECK: set --erase --universal fish_key_bindings
48
49    # But the migration is only done once, in case the user really wants these as universals.
50    set -U fish_color_autosuggestion 8e8e8e
51    $fish -c '
52        __fish_theme_migrate
53        set -eg fish_color_autosuggestion
54        echo $fish_color_autosuggestion
55        # CHECK: 8e8e8e
56    '
57    set -Ue fish_color_autosuggestion
58}
59
60# If existing universal colors match old defaults exactly (common case), don't migrate but
61# delete them.
62{
63    echo yes | fish_config theme save default
64    fake-old-uvars
65    provoke-migration
66    $fish -c __fish_theme_migrate
67    # CHECK: {{\x1b\[1m}}fish:{{\x1b\[m}} {{upgraded.*}}
68    # CHECK: {{.*Color.*no.longer.*universal.*}}
69    # CHECK: {{.*restart.*}}
70    # CHECK: {{.*help relnotes.*}}
71    not path is $__fish_config_dir/conf.d/fish_frozen_theme.fish
72    and echo ok
73    # CHECK: ok
74    set -U
75    # CHECK: __fish_initialized 4300
76}
77
78# Labeled color variables may be updated by fish.
79{
80    $fish -c '
81        fish_config theme choose default
82        set -g fish_color_autosuggestion red
83        set -g fish_color_command green --theme=default
84        __fish_theme_migrate
85        for cmd in "" "__fish_color_theme=unknown __fish_apply_theme"
86            eval $cmd
87            echo fish_color_autosuggestion $fish_color_autosuggestion
88            echo fish_color_command $fish_color_command
89        end
90        # CHECK: fish_color_autosuggestion red
91        # CHECK: fish_color_command green --theme=default
92        # CHECK: fish_color_autosuggestion red
93        # CHECK: fish_color_command --reset --theme=default
94    '
95}
96
97# If existing universal key bindings match old defaults exactly (common case), don't migrate
98# but delete them).
99{
100    set -U fish_key_bindings fish_vi_key_bindings
101    provoke-migration
102    $fish -c __fish_theme_migrate
103    # CHECK: {{\x1b\[1m}}fish:{{\x1b\[m}} {{upgraded.*}}
104    # CHECK: {{.*fish_key_bindings.*no.longer.*universal.*}}
105    # CHECK: Migrated {{.*}} {{\S*}}/xdg_config_home/fish/conf.d/fish_frozen_key_bindings.fish{{\x1b\[m}}
106    # CHECK: {{.*help relnotes.*}}
107    path is $__fish_config_dir/conf.d/fish_frozen_key_bindings.fish
108    and echo ok
109    # CHECK: ok
110    set -U
111    # CHECK: __fish_initialized 4300
112}
113
114# Test some historical values for __fish_config_theme_uvars_subset_of_historical_default.
115{
116    provoke-migration
117    echo >$__fish_config_dir/fish_variables \
118'# VERSION: 3.0
119SETUVAR __fish_initialized:0
120SETUVAR fish_color_autosuggestion:555\x1ebrblack
121SETUVAR fish_color_search_match:\x2d\x2dbackground\x3d111
122SETUVAR fish_color_selection:white\x1e\x2d\x2dbold\x1e\x2d\x2dbackground\x3dbrblack
123SETUVAR fish_pager_color_description:B3A06D\x1eyellow\x1e\x2di
124SETUVAR fish_pager_color_prefix:cyan\x1e\x2d\x2dbold\x1e\x2d\x2dunderline'
125    $fish -c __fish_theme_migrate
126    # CHECK: {{\x1b\[1m}}fish:{{\x1b\[m}} {{upgraded.*}}
127    # CHECK: * Color variables are no longer set in universal scope.
128    # CHECK:   To restore syntax highlighting in other fish sessions, please restart them.
129    # CHECK: {{.*help relnotes.*}}
130    not path is $__fish_config_dir/conf.d/fish_frozen_theme.fish
131    and echo ok
132    # CHECK: ok
133    set -U
134    # CHECK: __fish_initialized 4300
135}