mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 09:46:42 +00:00
feat(mise): add command wrapper function
This commit is contained in:
27
zsh/mise.zsh
Normal file
27
zsh/mise.zsh
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#
|
||||||
|
# mise extra setup
|
||||||
|
#
|
||||||
|
|
||||||
|
if command-exists mise; then
|
||||||
|
# Wrap a tool with "mise exec" if the tool is managed by mise. Primarily this
|
||||||
|
# ensures that the tool is run with correct environment variables set with
|
||||||
|
# mise.
|
||||||
|
#
|
||||||
|
# Specifically it allows calling a tool prefixed with `MISE_ENV=<name>`, and
|
||||||
|
# have the relevant environment variables from the relevant
|
||||||
|
# `.mise.<name>.toml` files loaded.
|
||||||
|
mise-wrap-tool() {
|
||||||
|
local executable="$1"
|
||||||
|
local tool="${2:-$executable}"
|
||||||
|
|
||||||
|
eval "${executable}() {
|
||||||
|
if mise current \"${tool}\" > /dev/null; then
|
||||||
|
mise exec \"${tool}\" -- \"${executable}\" \"\$@\"
|
||||||
|
else
|
||||||
|
command \"${executable}\" \"\$@\"
|
||||||
|
fi
|
||||||
|
}"
|
||||||
|
}
|
||||||
|
|
||||||
|
mise-wrap-tool terraform
|
||||||
|
fi
|
||||||
1
zshrc
1
zshrc
@@ -193,6 +193,7 @@ source "$DOTZSH/copilot.zsh"
|
|||||||
source "$DOTZSH/emacs.zsh"
|
source "$DOTZSH/emacs.zsh"
|
||||||
source "$DOTZSH/fzf.zsh"
|
source "$DOTZSH/fzf.zsh"
|
||||||
source "$DOTZSH/less.zsh"
|
source "$DOTZSH/less.zsh"
|
||||||
|
source "$DOTZSH/mise.zsh"
|
||||||
source "$DOTZSH/neovim.zsh"
|
source "$DOTZSH/neovim.zsh"
|
||||||
source "$DOTZSH/nix.zsh"
|
source "$DOTZSH/nix.zsh"
|
||||||
source "$DOTZSH/tldr.zsh"
|
source "$DOTZSH/tldr.zsh"
|
||||||
|
|||||||
Reference in New Issue
Block a user