mirror of
https://gitlab.com/mlunax/dotfiles.git
synced 2025-04-19 08:45:36 +00:00
migrate to mise
This commit is contained in:
parent
6ec6d1c1bf
commit
977f50d858
2 changed files with 55 additions and 36 deletions
55
.zsh/mise.zsh
Normal file
55
.zsh/mise.zsh
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
export MISE_SHELL=zsh
|
||||||
|
export __MISE_ORIG_PATH="$PATH"
|
||||||
|
|
||||||
|
MISE_BIN_PATH=$(whereis mise | cut -d ':' -f2 | xargs)
|
||||||
|
if iscmd mise; then
|
||||||
|
mise() {
|
||||||
|
local command
|
||||||
|
command="${1:-}"
|
||||||
|
if [ "$#" = 0 ]; then
|
||||||
|
command $MISE_BIN_PATH
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
|
||||||
|
case "$command" in
|
||||||
|
deactivate|s|shell)
|
||||||
|
# if argv doesn't contains -h,--help
|
||||||
|
if [[ ! " $@ " =~ " --help " ]] && [[ ! " $@ " =~ " -h " ]]; then
|
||||||
|
eval "$(command $MISE_BIN_PATH "$command" "$@")"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
command $MISE_BIN_PATH "$command" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_mise_hook() {
|
||||||
|
eval "$($MISE_BIN_PATH 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
|
||||||
|
|
||||||
|
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 $MISE_BIN_PATH 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
|
||||||
|
fi
|
36
.zsh/rtx.zsh
36
.zsh/rtx.zsh
|
@ -1,36 +0,0 @@
|
||||||
export RTX_SHELL=zsh
|
|
||||||
RTX_BIN_PATH=$(whereis rtx | cut -d ':' -f2 | xargs)
|
|
||||||
if iscmd rtx; then
|
|
||||||
rtx() {
|
|
||||||
local command
|
|
||||||
command="${1:-}"
|
|
||||||
if [ "$#" = 0 ]; then
|
|
||||||
command $RTX_BIN_PATH
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
shift
|
|
||||||
|
|
||||||
case "$command" in
|
|
||||||
deactivate|shell)
|
|
||||||
eval "$($RTX_BIN_PATH "$command" "$@")"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
command $RTX_BIN_PATH "$command" "$@"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
_rtx_hook() {
|
|
||||||
trap -- '' SIGINT;
|
|
||||||
eval "$("$RTX_BIN_PATH" hook-env -s zsh)";
|
|
||||||
trap - SIGINT;
|
|
||||||
}
|
|
||||||
typeset -ag precmd_functions;
|
|
||||||
if [[ -z "${precmd_functions[(r)_rtx_hook]+1}" ]]; then
|
|
||||||
precmd_functions=( _rtx_hook ${precmd_functions[@]} )
|
|
||||||
fi
|
|
||||||
typeset -ag chpwd_functions;
|
|
||||||
if [[ -z "${chpwd_functions[(r)_rtx_hook]+1}" ]]; then
|
|
||||||
chpwd_functions=( _rtx_hook ${chpwd_functions[@]} )
|
|
||||||
fi
|
|
||||||
fi
|
|
Loading…
Add table
Reference in a new issue