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