e7cbf38af7
Makes it easier for users who want to locate their kakrc file, and does not require to go through shell expansion to get it as "${XDG_CONFIG_DIR:-${HOME}/.config}/kak" Fixes #1740
45 lines
1.3 KiB
Plaintext
45 lines
1.3 KiB
Plaintext
def -params 1 -docstring "colorscheme <name>: enable named colorscheme" \
|
|
-shell-candidates %{
|
|
for col in ${kak_runtime}/colors/*.kak ${kak_config}/colors/*.kak; do
|
|
candidate=$(basename "${col}" .kak)
|
|
case ${candidate} in
|
|
\**) ;;
|
|
*) echo ${candidate} ;;
|
|
esac
|
|
done
|
|
} \
|
|
colorscheme %{ %sh{
|
|
if [ $# -eq 1 ]; then
|
|
if [ -f "${kak_config}/colors/$1.kak" ];then
|
|
echo "source '${kak_config}/colors/$1.kak'"
|
|
else
|
|
echo "source '${kak_runtime}/colors/$1.kak'"
|
|
fi
|
|
else
|
|
echo "echo -color Error 'Usage: colorscheme <scheme name>'"
|
|
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
|
|
}
|