Refactor variables names
This commit is contained in:
@@ -8,7 +8,7 @@ _sqn_completions()
|
||||
# Extract alias command with buildins same as:
|
||||
# local curCmd="$(alias $1 | sed "s/^alias.*\" \"\(.*\)\"'$/\1/")"
|
||||
local curCmd=
|
||||
curCmd="$(alias "$1")"
|
||||
curCmd="$(alias "${1:-}")"
|
||||
curCmd="${curCmd##*\" \"}"
|
||||
curCmd="${curCmd%\"\'*}"
|
||||
COMPREPLY=()
|
||||
@@ -66,24 +66,25 @@ installCompletion() {
|
||||
|
||||
. "${script_dir}/sequencer.cfg" >/dev/null 2>&1
|
||||
|
||||
local SEQBASE="${script_dir}/seqs"
|
||||
local SEQPREFIX="sqn_"
|
||||
local SEQSHORT=()
|
||||
local seq_base="${script_dir}/seqs"
|
||||
local seq_prefix="sqn_"
|
||||
local seq_short=()
|
||||
local seq_list=()
|
||||
|
||||
# Check for user selected sequences
|
||||
[ -e "$SEQUENCER_USER_SEQS" ] && SEQBASE="$SEQUENCER_USER_SEQS"
|
||||
[ -e "$SEQUENCER_USER_SEQS" ] && seq_base="$SEQUENCER_USER_SEQS"
|
||||
|
||||
# Create aliases and command (alias) list for "complete" command"
|
||||
IFS=$'\n' read -r -d '' -a SEQLIST < <(ls -1 "$SEQBASE/${cur}"*.sh)
|
||||
for i in "${!SEQLIST[@]}"; do
|
||||
SEQLIST[$i]="${SEQLIST[$i]##*/}"
|
||||
SEQLIST[$i]="${SEQLIST[$i]%.*}"
|
||||
SEQSHORT[$i]="${SEQPREFIX}${SEQLIST[$i]/[[:blank:]]/_}"
|
||||
IFS=$'\n' read -r -d '' -a seq_list < <(ls -1 "${seq_base}/${cur}"*.sh)
|
||||
for i in "${!seq_list[@]}"; do
|
||||
seq_list[$i]="${seq_list[$i]##*/}"
|
||||
seq_list[$i]="${seq_list[$i]%.*}"
|
||||
seq_short[$i]="${seq_prefix}${seq_list[$i]/[[:blank:]]/_}"
|
||||
# shellcheck disable=SC2139,SC2086
|
||||
# alias should be expanded when defined
|
||||
alias ${SEQSHORT[$i]}="_SQN_ALIAS=\"${SEQSHORT[$i]}\" \"$SEQBASE/${SEQLIST[$i]}.sh\""
|
||||
alias ${seq_short[$i]}="_SQN_ALIAS=\"${seq_short[$i]}\" \"${seq_base}/${seq_list[$i]}.sh\""
|
||||
done
|
||||
complete -o nosort -o bashdefault -o default -F _sqn_completions "${SEQSHORT[@]}"
|
||||
complete -o nosort -o bashdefault -o default -F _sqn_completions "${seq_short[@]}"
|
||||
}
|
||||
|
||||
installCompletion
|
||||
|
Reference in New Issue
Block a user