What is my current colorscheme?

Hi there,
how would a chunk of coal like myself go about and let kakoune show me, what colorscheme this session is using?
Many greetings

You mean the one that comes loaded by default? It’s literally just called default haha. You can find it in %val{runtime}/colors/default.kak.

Colorschemes are just .kak files that are executed when running the colorscheme command. Kakoune doesn’t remember the name of the loaded one.

Hi @SeerLite

This answers my question. Thank you. When using the :colorscheme command I was expecting to see the colorscheme in use being highlighted, you know, in the suggestions. Maybe this will be added in future.
Best regards

the thing is, since colorschemes are just .kak scripts that simply modify values of a bunch of variables, there’s no such thing as active colorscheme at all.

To explain what I mean, if colorscheme “A” changes all existing faces, and colorscheme “B” only changes a small subset of existing faces, applying colorscheme “A” and colorscheme “B” in that order will give you a mix of “A” and “B”, but applying “B” and then “A” will give you just “A”, because “A” overrides every face that was set by “B”.

Hope this makes sense

Hey @andreyorst,
this makes sense. So you could have a basic colorscheme and then swap sub-schemes, say, according to filetype. This is quite cool, much better than having the colorschemes name highlighted. Thanks for the comprehensive answer.
Many greetings

yeah, this is possible in theory, although I’ve never seen such thing in practice

I find color schemes generally confusing, especially in Kakoune where a visual aspect applied on top of another one will merge with the previous one instead of overriding it–unless the last applied colorscheme relies on the Final attribute (see :doc faces).

I find the result to be a mess (just my two cents–YMMV). Isnt’ the whole point of a colorscheme to provide a unified look for the widest range (ideally, all) of visual aspects, instead of piecemeal changes that (at worst) may even depend on what was applied before?

From this perspective, it does make sense to speak of the “current” (or perhaps, dominant) colorscheme at a given time.

To answer dornhe’s question, the default colorscheme command is defined at the top of your /usr/share/kak/kakrc script file (please have a look at it to see how it works). The good news is that you can override the default command by writing your own. Here is a version that does what you want:

# Redefine the 'colorscheme' command so as to highlight the current colorscheme
# in the selection menu.

declare-option str colorscheme_current default

define-command \
-docstring \
'colorscheme <name>: enable named colorscheme' \
-override \
-params 1 \
-shell-script-candidates %{
    current=$kak_opt_colorscheme_current
    find -L "${kak_runtime}/colors" "${kak_config}/colors" \
    -type f -name '*.kak' \
    | while read -r filename; do
        basename=${filename##*/}
        scheme=${basename%.*}
        #
        # Add marking to colorscheme names.
        if [ "$scheme" = "$current" ]; then
            scheme='*'$scheme
        else
            scheme='-'$scheme
        fi
        printf %s\\n "$scheme"
    done
} \
colorscheme %{
    evaluate-commands %sh{
        #
        find_scheme() {
            path=$1
            target="$2.kak"
            find -L "$path" -type f -name "$target" | head -n 1
        }
        #
        # Remove marking so as to load the colorscheme file correctly.
        wanted=$1
        wanted=${wanted#\*}
        wanted=${wanted#\-}
        #
        filename=
        if [ -d "$kak_config/colors" ]; then
            filename=$(find_scheme "$kak_config/colors" "$wanted")
        fi
        if [ -z "$filename" ]; then
            filename=$(find_scheme "$kak_runtime/colors" "$wanted")
        fi
        if [ -n "$filename" ]; then
            printf %s\\n "source '$filename'"
            printf %s\\n "set-option global colorscheme_current '$wanted'"
        else
            echo 'fail "No such colorscheme"'
        fi
    }
}

You can include these lines in your kakrc, or you can store them in a colorscheme.kak somewhere in your autoload path. It will load at the start of your session. Then typing : colorscheme [space] will show you the list of available color schemes, with the “current” one at the top marked with an asterisk.

(This script is just an elaboration of the default version found at /usr/shared/kak/karc).

Hi @ftonneau,

thank you for your reply. I think I understand the problem you have with the normal way, kakoune handles colorschemes. Yet I like the potential of high adaptability in it. Nevertheless right now I use colorschemes as you envision them. In this sense your script works like a charm and does exactly what I had hoped for. Publishing it es very kind of you. Possibly in future there will be a plugin, that can handle a per scope colorscheme commit history. This might help in handling complex colorscheme setups.

Have a nice easter
– dornhe