dotfiles.2022/_home/dot_sz.shrc.d/bash.pre/21_aliases

16 lines
473 B
Plaintext
Raw Normal View History

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 "${@}"
}
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"
}