summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-02-24 16:43:42 +1100
committerMaxime Coste <mawww@kakoune.org>2018-02-24 16:43:42 +1100
commit1c4f3534e17971ad051a4921373af8e77792d669 (patch)
treed1f1b6f3d798c2746070e4986f2e531167acbd6f /share
parentaf21d4ca1e19ca3890475c41c24f48c82e26f4a2 (diff)
kakrc: refactor colorscheme implementation
Style tweaks, and remove check for parameter count as this is already done by Kakoune itself (the command is specified to take 1 parameter)
Diffstat (limited to 'share')
-rw-r--r--share/kak/kakrc28
1 files changed, 13 insertions, 15 deletions
diff --git a/share/kak/kakrc b/share/kak/kakrc
index a5d9cec3..fb8d16c7 100644
--- a/share/kak/kakrc
+++ b/share/kak/kakrc
@@ -1,29 +1,27 @@
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##*/}"
+ | while read -r filename; do
+ basename="${filename##*/}"
printf %s\\n "${basename%.*}"
done | sort -u
} \
colorscheme %{ %sh{
find_colorscheme() {
- find -L "${1}" -type f -name "${2}\\.kak" | head -n 1
+ 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 [ -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
- if [ -z "${path_colorscheme}" ]; then
- echo "echo -markup '{Error}No such colorscheme'"
- else
- printf 'source %%{%s}' "${path_colorscheme}"
- fi
+ if [ -n "${filename}" ]; then
+ printf 'source %%{%s}' "${filename}"
+ else
+ echo "echo -markup '{Error}No such colorscheme'"
fi
}}