Add custom path support for cli/tui in terminal config
This commit is contained in:
@@ -26,6 +26,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-*; do
|
||||
[[ -f "${file}" ]] || continue
|
||||
mnemonic="${file##*/}"
|
||||
[[ "${mnemonic}" == "$1"* ]] && printf '%s\n' "${mnemonic}"
|
||||
done
|
||||
}
|
||||
|
||||
# @description
|
||||
# Main completion dispatcher invoked by bash's `complete -F`.
|
||||
# It determines context (command/subcommand/argument position) and then mixes:
|
||||
@@ -39,10 +52,10 @@ _{{FUNC_NAME}}_completions() {
|
||||
_init_completion || return
|
||||
|
||||
# If the previous token is `-m/--mnemonic-file`, this argument expects a
|
||||
# mnemonic file alias/path. Ask the helper for mnemonic suggestions.
|
||||
# mnemonic file alias/path. List mnemonic aliases directly from disk.
|
||||
if [[ "${prev}" == "-m" || "${prev}" == "--mnemonic-file" ]]; then
|
||||
local mnemonics
|
||||
mnemonics=$(__xo_complete mnemonics "${cur}")
|
||||
mnemonics=$(__xo_complete_mnemonics "${cur}")
|
||||
if [[ -n "${mnemonics}" ]]; then
|
||||
while IFS= read -r line; do
|
||||
COMPREPLY+=("$line")
|
||||
|
||||
Reference in New Issue
Block a user