1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-18 08:51:46 +03:00

Merge remote-tracking branch 'lenormf/fix-colorscheme-recursive-directory'

This commit is contained in:
Maxime Coste 2018-02-23 08:12:12 +11:00
commit 9bd9fecb53

View File

@ -1,22 +1,29 @@
def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \ def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
-shell-candidates %{ -shell-candidates %{
for col in ${kak_runtime}/colors/*.kak ${kak_config}/colors/*.kak; do find -L "${kak_runtime}/colors" "${kak_config}/colors" -type f -name '*\.kak' \
candidate=$(basename "${col}" .kak) | while read -r path_colorscheme; do
case ${candidate} in basename="${path_colorscheme##*/}"
\**) ;; printf %s\\n "${basename%.*}"
*) echo ${candidate} ;; done | sort -u
esac
done
} \ } \
colorscheme %{ %sh{ colorscheme %{ %sh{
if [ $# -eq 1 ]; then find_colorscheme() {
if [ -f "${kak_config}/colors/$1.kak" ];then find -L "${1}" -type f -name "${2}\\.kak" | head -n 1
echo "source '${kak_config}/colors/$1.kak'" }
else
echo "source '${kak_runtime}/colors/$1.kak'" if [ $# -lt 1 ]; then
fi echo "echo -markup '{Error}Usage: colorscheme <scheme name>'"
else else
echo "echo -color Error 'Usage: colorscheme <scheme name>'" 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
fi fi
}} }}