16 lines
473 B
Plaintext
16 lines
473 B
Plaintext
function which-command() {
|
|
local ANSWER=$(type -t "${@}") || return $?
|
|
[[ $ANSWER == "function" ]] && printf "function " && type "${@}" | tail +2 && return
|
|
[[ $ANSWER == "alias" ]] && {
|
|
alias "${@}"
|
|
}
|
|
type -fP "${@}"
|
|
}
|
|
|
|
function add-alias-to-bash-completion-code() {
|
|
local CMD=$(printf "%s" "sed '" 's/\(complete\W.*-F\W.*' "$1" '.*$\)/\1 ' "$2/g'")
|
|
[[ -r "$3" ]] && CMD="$CMD -i $3"
|
|
[[ -n "$4" ]] && CMD="$4 $CMD"
|
|
eval "$CMD"
|
|
}
|