This is my next forus area. chezmoi all the things.
This commit is contained in:
53
.zshrc
Normal file
53
.zshrc
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
export MISE_SHELL=zsh
|
||||||
|
export __MISE_ORIG_PATH="$PATH"
|
||||||
|
|
||||||
|
mise() {
|
||||||
|
local command
|
||||||
|
command="${1:-}"
|
||||||
|
if [ "$#" = 0 ]; then
|
||||||
|
command mise
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
deactivate|shell|sh)
|
||||||
|
# if argv doesn't contains -h,--help
|
||||||
|
if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
|
||||||
|
eval "$(command mise "$command" "$@")"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
command mise "$command" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_mise_hook() {
|
||||||
|
eval "$(mise hook-env -s zsh)";
|
||||||
|
}
|
||||||
|
typeset -ag precmd_functions;
|
||||||
|
if [[ -z "${precmd_functions[(r)_mise_hook]+1}" ]]; then
|
||||||
|
precmd_functions=( _mise_hook ${precmd_functions[@]} )
|
||||||
|
fi
|
||||||
|
typeset -ag chpwd_functions;
|
||||||
|
if [[ -z "${chpwd_functions[(r)_mise_hook]+1}" ]]; then
|
||||||
|
chpwd_functions=( _mise_hook ${chpwd_functions[@]} )
|
||||||
|
fi
|
||||||
|
|
||||||
|
_mise_hook
|
||||||
|
if [ -z "${_mise_cmd_not_found:-}" ]; then
|
||||||
|
_mise_cmd_not_found=1
|
||||||
|
[ -n "$(declare -f command_not_found_handler)" ] && eval "${$(declare -f command_not_found_handler)/command_not_found_handler/_command_not_found_handler}"
|
||||||
|
|
||||||
|
function command_not_found_handler() {
|
||||||
|
if [[ "$1" != "mise" && "$1" != "mise-"* ]] && mise hook-not-found -s zsh -- "$1"; then
|
||||||
|
_mise_hook
|
||||||
|
"$@"
|
||||||
|
elif [ -n "$(declare -f _command_not_found_handler)" ]; then
|
||||||
|
_command_not_found_handler "$@"
|
||||||
|
else
|
||||||
|
echo "zsh: command not found: $1" >&2
|
||||||
|
return 127
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fi
|
Reference in New Issue
Block a user