-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathzsh-mise.plugin.zsh
31 lines (25 loc) · 931 Bytes
/
zsh-mise.plugin.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env zsh
# shellcheck disable=SC1090
# Exit if the 'mise' command can not be found
if ! (( $+commands[mise] )); then
return
fi
# Activate `mise` within the zsh shell and provide access to any
# globally insstalled tools within your `.zshrc` file.
# https://mise.jdx.dev/dev-tools/shims.html#zshrc-bashrc-files
source <(mise activate zsh)
source <(mise hook-env -s zsh)
# Completions directory for `mise` command
local COMPLETIONS_DIR="${0:A:h}/completions"
# Add completions to the FPATH
typeset -TUx FPATH fpath
fpath=("$COMPLETIONS_DIR" $fpath)
# If the completion file does not exist yet, then we need to autoload
# and bind it to `mise`. Otherwise, compinit will have already done that.
if [[ ! -f "$COMPLETIONS_DIR/_mise" ]]; then
typeset -g -A _comps
autoload -Uz _mise
_comps[mise]=_mise
fi
# Generate and load completion in the background
mise completions zsh >| "$COMPLETIONS_DIR/_mise" &|