diff --git a/src/const.ts b/src/const.ts index 71bb4ad..0c83058 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,5 +1,6 @@ import { xdgConfig } from 'xdg-basedir' +import { join as joinPath } from '@std/path' -export const XDG_CONFIG_HOME = xdgConfig ?? Deno.makeTempDirSync() +export const WK_CONFIG_HOME = joinPath(xdgConfig ?? Deno.makeTempDirSync(), 'wk') export const PRINTABLE_ASCII = /^[ -~]$/ diff --git a/src/run.ts b/src/run.ts index 6dfb349..5102b8f 100644 --- a/src/run.ts +++ b/src/run.ts @@ -2,7 +2,7 @@ import { Command, EnumType } from '@cliffy/command' import { join as joinPath } from '@std/path' import { parse as parseYaml } from '@std/yaml' import { Binding } from './types/Binding.ts' -import { XDG_CONFIG_HOME } from './const.ts' +import { WK_CONFIG_HOME } from './const.ts' import { TUI } from './tui.ts' import { defaultContext, mergeContext, PartialContext } from './types/Context.ts' import { Dependencies, main } from './main.ts' @@ -31,9 +31,7 @@ For example, this simulates pressing "g", "p", and "f".`, ) .action(async ({ upOneLine, inputs }) => { const fetchContextWaiting = (async () => { - const found = await loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'config.yaml')).catch(() => - undefined - ) + const found = await loadYaml(joinPath(WK_CONFIG_HOME, 'config.yaml')).catch(() => undefined) if (found === undefined) { return defaultContext } @@ -41,9 +39,9 @@ For example, this simulates pressing "g", "p", and "f".`, })() const fetchBindingsWaiting = Promise.all([ - loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'bindings.yaml')).catch(() => []).catch(() => []), - loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => []).catch(() => []), - ]).then(([globalBindings, localBindings]) => [...globalBindings, ...localBindings]) + loadYaml(joinPath(WK_CONFIG_HOME, 'bindings.yaml')).catch(() => [] as Binding[]), + loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => [] as Binding[]), + ]).then(([globalBindings, localBindings]) => globalBindings.concat(localBindings)) const tty = await Deno.open('/dev/tty', { read: true, write: true }) const tui = new TUI(tty, inputs === undefined ? [] : inputs.split(' ').map(unescapeAnsi)) diff --git a/src/widget.eta b/src/widget.eta index 4f9097d..63cfbf7 100644 --- a/src/widget.eta +++ b/src/widget.eta @@ -28,8 +28,8 @@ _wk_widget() { ;; esac - # `p` flag does NOT work with the ${var} format; must use $var instead. - # See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion + <%- /* `p` flag does NOT work with the ${var} format; must use $var instead. */ _%> + <%- /* See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion */ _%> local delimiter=$res[1] reply=("${(@ps:$delimiter:)${res:2}}")