Add custom path support for cli/tui in terminal config
This commit is contained in:
@@ -25,6 +25,19 @@ __xo_complete() {
|
||||
[[ -n "${__xo_complete_bin}" ]] && "${__xo_complete_bin}" "$@" 2>/dev/null
|
||||
}
|
||||
|
||||
# @description
|
||||
# Lists mnemonic aliases directly from the config directory without starting
|
||||
# the dynamic Node helper.
|
||||
__xo_complete_mnemonics() {
|
||||
local config_dir="${XO_CONFIG_DIR:-${HOME}/.config/xo-cli}"
|
||||
local file mnemonic
|
||||
for file in "${config_dir}"/mnemonics/mnemonic-*(N); do
|
||||
[[ -f "${file}" ]] || continue
|
||||
mnemonic="${file:t}"
|
||||
[[ "${mnemonic}" == "$1"* ]] && print -r -- "${mnemonic}"
|
||||
done
|
||||
}
|
||||
|
||||
# @description
|
||||
# Main zsh completion dispatcher registered via `compdef`.
|
||||
# It resolves command context from `$words`/`$CURRENT` and serves:
|
||||
@@ -38,7 +51,7 @@ _{{FUNC_NAME}}_completions() {
|
||||
# If previous token is `-m/--mnemonic-file`, complete mnemonic sources.
|
||||
if [[ "${words[CURRENT-1]}" == "-m" || "${words[CURRENT-1]}" == "--mnemonic-file" ]]; then
|
||||
local mnemonics
|
||||
mnemonics=("${(@f)$(__xo_complete mnemonics "${words[CURRENT]}")}")
|
||||
mnemonics=("${(@f)$(__xo_complete_mnemonics "${words[CURRENT]}")}")
|
||||
if [[ ${#mnemonics[@]} -gt 0 ]]; then
|
||||
compadd -- "${mnemonics[@]}"
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user