kakoune/share/kak/kakrc

52 lines
1.6 KiB
Plaintext
Raw Normal View History

def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
-shell-candidates %{
find -L "${kak_runtime}/colors" "${kak_config}/colors" -type f -name '*\.kak' \
| while read -r path_colorscheme; do
basename="${path_colorscheme##*/}"
printf %s\\n "${basename%.*}"
done | sort -u
2015-07-03 22:14:34 +02:00
} \
colorscheme %{ %sh{
find_colorscheme() {
find -L "${1}" -type f -name "${2}\\.kak" | head -n 1
}
if [ $# -lt 1 ]; then
echo "echo -markup '{Error}Usage: colorscheme <scheme name>'"
else
path_colorscheme=$(find_colorscheme "${kak_config}/colors" "${1}")
if [ -z "${path_colorscheme}" ];then
path_colorscheme=$(find_colorscheme "${kak_runtime}/colors" "${1}")
fi
if [ -z "${path_colorscheme}" ]; then
echo "echo -markup '{Error}No such colorscheme'"
else
printf 'source %%{%s}' "${path_colorscheme}"
fi
2015-07-03 22:14:34 +02:00
fi
}}
%sh{
autoload_directory() {
find -L "$1" -type f -name '*\.kak' \
-exec printf 'try %%{ source "%s" } catch %%{ echo -debug Autoload: could not load "%s" }\n' '{}' '{}' \;
}
echo "colorscheme default"
if [ -d "${kak_config}/autoload" ]; then
autoload_directory ${kak_config}/autoload
elif [ -d "${kak_runtime}/autoload" ]; then
autoload_directory ${kak_runtime}/autoload
fi
if [ -f "${kak_runtime}/kakrc.local" ]; then
echo "source '${kak_runtime}/kakrc.local'"
fi
if [ -f "${kak_config}/kakrc" ]; then
echo "source '${kak_config}/kakrc'"
fi
}