2015-12-01 17:00:55 +03:00
|
|
|
def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
|
2018-09-27 00:42:01 +03:00
|
|
|
-shell-script-candidates %{
|
2018-02-22 13:35:39 +03:00
|
|
|
find -L "${kak_runtime}/colors" "${kak_config}/colors" -type f -name '*\.kak' \
|
2018-02-24 08:43:42 +03:00
|
|
|
| while read -r filename; do
|
|
|
|
basename="${filename##*/}"
|
2018-02-22 13:35:39 +03:00
|
|
|
printf %s\\n "${basename%.*}"
|
|
|
|
done | sort -u
|
2015-07-03 23:14:34 +03:00
|
|
|
} \
|
2018-05-07 00:29:52 +03:00
|
|
|
colorscheme %{ evaluate-commands %sh{
|
2018-02-22 13:35:39 +03:00
|
|
|
find_colorscheme() {
|
2018-02-24 08:43:42 +03:00
|
|
|
find -L "${1}" -type f -name "${2}".kak | head -n 1
|
2018-02-22 13:35:39 +03:00
|
|
|
}
|
|
|
|
|
2018-02-24 08:43:42 +03:00
|
|
|
if [ -d "${kak_config}/colors" ]; then
|
|
|
|
filename=$(find_colorscheme "${kak_config}/colors" "${1}")
|
|
|
|
fi
|
|
|
|
if [ -z "${filename}" ]; then
|
|
|
|
filename=$(find_colorscheme "${kak_runtime}/colors" "${1}")
|
|
|
|
fi
|
2018-02-22 13:35:39 +03:00
|
|
|
|
2018-02-24 08:43:42 +03:00
|
|
|
if [ -n "${filename}" ]; then
|
|
|
|
printf 'source %%{%s}' "${filename}"
|
|
|
|
else
|
|
|
|
echo "echo -markup '{Error}No such colorscheme'"
|
2015-07-03 23:14:34 +03:00
|
|
|
fi
|
2015-07-02 15:56:38 +03:00
|
|
|
}}
|
|
|
|
|
2018-05-07 00:29:52 +03:00
|
|
|
evaluate-commands %sh{
|
2017-05-09 04:35:48 +03:00
|
|
|
autoload_directory() {
|
2017-05-15 22:27:22 +03:00
|
|
|
find -L "$1" -type f -name '*\.kak' \
|
2018-07-08 16:18:31 +03:00
|
|
|
| sed 's/.*/try %{ source "&" } catch %{ echo -debug Autoload: could not load "&" }/'
|
2015-05-30 16:32:04 +03:00
|
|
|
}
|
|
|
|
|
2015-07-19 06:38:52 +03:00
|
|
|
echo "colorscheme default"
|
|
|
|
|
2018-01-19 02:05:08 +03:00
|
|
|
if [ -d "${kak_config}/autoload" ]; then
|
|
|
|
autoload_directory ${kak_config}/autoload
|
2015-05-30 16:32:04 +03:00
|
|
|
elif [ -d "${kak_runtime}/autoload" ]; then
|
2017-05-09 04:35:48 +03:00
|
|
|
autoload_directory ${kak_runtime}/autoload
|
2012-09-10 22:45:34 +04:00
|
|
|
fi
|
2015-05-30 16:32:04 +03:00
|
|
|
|
2016-03-27 21:34:59 +03:00
|
|
|
if [ -f "${kak_runtime}/kakrc.local" ]; then
|
|
|
|
echo "source '${kak_runtime}/kakrc.local'"
|
|
|
|
fi
|
|
|
|
|
2018-01-19 02:05:08 +03:00
|
|
|
if [ -f "${kak_config}/kakrc" ]; then
|
|
|
|
echo "source '${kak_config}/kakrc'"
|
2012-12-06 23:30:34 +04:00
|
|
|
fi
|
2012-09-10 22:45:34 +04:00
|
|
|
}
|