bash: not trap last cmd error but create ? function
This commit is contained in:
@@ -52,14 +52,9 @@ export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || pr
|
|||||||
export DOCKER_BUILDKIT=0
|
export DOCKER_BUILDKIT=0
|
||||||
export COMPOSE_DOCKER_CLI_BUILD=0
|
export COMPOSE_DOCKER_CLI_BUILD=0
|
||||||
|
|
||||||
__trap_not_cmd_found_error() {
|
function ? {
|
||||||
code="$?"
|
cmd=$(history | tail -n 2 | head -n 1 | awk '{ printf $2 }')
|
||||||
if [[ "$code" == "127" ]]; then
|
echo "$cmd"
|
||||||
prevCmd=$(history | tail -n 1 | awk '{ printf $2 }')
|
|
||||||
echo "$prevCmd"
|
|
||||||
|
|
||||||
xdg-open "https://command-not-found.com/$prevCmd"
|
xdg-open "https://command-not-found.com/$cmd"
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
trap "__trap_not_cmd_found_error" ERR
|
|
||||||
|
|||||||
Reference in New Issue
Block a user