Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the command_not_found_handle function #97

Closed
benknoble opened this issue Aug 25, 2017 · 2 comments
Closed

Add the command_not_found_handle function #97

benknoble opened this issue Aug 25, 2017 · 2 comments

Comments

@benknoble
Copy link
Owner

Handles what happens when a command cannot be found.

Args: command_name [command_arg1 command_arg2 ...]

Exit status: 127

@benknoble benknoble added this to the Version 1.4 milestone Aug 25, 2017
@benknoble benknoble self-assigned this Aug 25, 2017
@benknoble
Copy link
Owner Author

benknoble commented Aug 25, 2017

Prototype:

function command_not_found_handle() {
    {
        echo -e "$BRed"Command not found: "$NC$BYellow$1$NC"
        shift
        if [[ $# > 0 ]]; then
            echo "$#" args: "$(join_by ', ' "${@@Q}")"
        fi
        echo -e Try "$BGreen"'`displayPath`'"$NC" to see the path
    } >&2
    return 127
}

function join_by { local d=$1; shift; echo -n "$1"; shift; printf "%s" "${@/#/$d}"; echo; }

join_by from here

@benknoble
Copy link
Owner Author

Consider conditionally defining it (so as not to override):

[[ "$(type -t command_not_found_handle)" = function ]] || # def function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant