2022-09-27 10:32:00 +00:00
|
|
|
function which-command() {
|
2022-10-06 01:49:54 +00:00
|
|
|
local ANSWER=$(type -t "${@}") || return $?
|
|
|
|
[[ $ANSWER == "function" ]] && printf "function " && type "${@}" | tail +2 && return
|
|
|
|
[[ $ANSWER == "alias" ]] && {
|
|
|
|
alias "${@}"
|
|
|
|
}
|
2022-09-27 10:32:00 +00:00
|
|
|
type -fP "${@}"
|
|
|
|
}
|
2022-06-18 18:44:42 +00:00
|
|
|
|
2022-08-02 11:26:18 +00:00
|
|
|
function add-alias-to-bash-completion-code() {
|
2022-08-04 02:43:35 +00:00
|
|
|
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"
|
2022-08-02 11:26:18 +00:00
|
|
|
eval "$CMD"
|
|
|
|
}
|