Skip to content

Instantly share code, notes, and snippets.

@reitzig
Last active February 24, 2025 16:33
Show Gist options
  • Save reitzig/2885464e5c2fcc0f84bda9e1dae4f7b1 to your computer and use it in GitHub Desktop.
Save reitzig/2885464e5c2fcc0f84bda9e1dae4f7b1 to your computer and use it in GitHub Desktop.
mise: MWE for project setup with project-local completions
[env]
LOCAL_FISH_COMPLETION_DIR = "{{config_root}}/.config/fish/completions"
[hooks]
postinstall = 'mkdir -p "$LOCAL_FISH_COMPLETION_DIR"'
[tasks.install-local-completions]
description = 'Install shell completions into project directory'
hide = true
run = '''
{{arg(name="command")}} {{arg(name="completion_command", var=true)}} \
> "$LOCAL_FISH_COMPLETION_DIR/{{arg(name="command")}}.fish"
'''
[tools.lefthook]
version = "1.10.10"
postinstall = 'mise run install-local-completions lefthook completion fish'
# TODO: can we (trigger) change(s) in env vars from hooks?
# we want to (re-)source after writing completions!
# TODO: can we remove the completion (complete -e) on leave?
# not a big deal, ut would be cleaner
# add to ~/.config/fish/conf.d/source-completions.fish
function source_completions --on-variable LOCAL_FISH_COMPLETION_DIR
for cf in $LOCAL_FISH_COMPLETION_DIR/*.fish
# mise exec gum -- gum log --level=debug "loading completion "(basename $cf)
# TODO: log doesn't work?
source < $cf
end
end
@reitzig
Copy link
Author

reitzig commented Feb 24, 2025

💡 You can move everything except [tools.lefthook] to a mise.local.toml.

💡 You can even move [hooks] and [tasks.install-local-completions] to your user config.

refs: jdx/mise#3757, jdx/mise#4514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment