From 6ca8e38727f61f1be6a64f418b8c75cbb7bc62c4 Mon Sep 17 00:00:00 2001 From: Luna Komorebi Date: Thu, 29 Aug 2024 11:18:57 +0200 Subject: [PATCH] change mise install --- .zsh/mise.zsh | 103 ----------------------------------------------- install-mise.zsh | 4 ++ 2 files changed, 4 insertions(+), 103 deletions(-) delete mode 100644 .zsh/mise.zsh create mode 100644 install-mise.zsh diff --git a/.zsh/mise.zsh b/.zsh/mise.zsh deleted file mode 100644 index 78b0160..0000000 --- a/.zsh/mise.zsh +++ /dev/null @@ -1,103 +0,0 @@ -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 -#compdef mise -local curcontext="$curcontext" - -# caching config -_usage_mise_cache_policy() { - if [[ -z "${lifetime}" ]]; then - lifetime=$((60*60*4)) # 4 hours - fi - local -a oldp - oldp=( "$1"(Nms+${lifetime}) ) - (( $#oldp )) -} - -_mise() { - typeset -A opt_args - local curcontext="$curcontext" spec cache_policy - - if ! command -v usage &> /dev/null; then - echo >&2 - echo "Error: usage CLI not found. This is required for completions to work in mise." >&2 - echo "See https://usage.jdx.dev for more information." >&2 - return 1 - fi - - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z $cache_policy ]]; then - zstyle ":completion:${curcontext}:" cache-policy _usage_mise_cache_policy - fi - - if ( [[ -z "${_usage_mise_spec:-}" ]] || _cache_invalid _usage_mise_spec ) \ - && ! _retrieve_cache _usage_mise_spec; - then - spec="$(mise usage)" - _store_cache _usage_mise_spec spec - fi - - _arguments "*: :(($(usage complete-word --shell zsh -s "$spec" -- "${words[@]}" )))" - return 0 -} - -if [ "$funcstack[1]" = "_mise" ]; then - _mise "$@" -else - compdef _mise mise -fi - -# vim: noet ci pi sts=0 sw=4 ts=4 - -fi diff --git a/install-mise.zsh b/install-mise.zsh new file mode 100644 index 0000000..7a4eaeb --- /dev/null +++ b/install-mise.zsh @@ -0,0 +1,4 @@ +#!/bin/bash +curl https://mise.run | sh +~/.local/bin/mise --version +echo 'eval "$(~/.local/bin/mise activate zsh)"' >> $HOME/.zsh/mise.zsh