Skip to content

Commit

Permalink
Add setup for mise-en-place
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiX committed Sep 12, 2024
1 parent 9bd1ac6 commit 6d74826
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
14 changes: 14 additions & 0 deletions zsh/funcs/_cache-completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generate a completion function from the output of a specific command, but
# only if the binary is newer then the completion script

local funcdir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/funcs"
local bin="$1"
local cmd="$2"
local target="$funcdir/_$bin:t"

if [[ ! -e "$target" || "$target" -ot "$bin" ]]
then
mkdir -p "$funcdir"
$=cmd > "$target"
fi

8 changes: 8 additions & 0 deletions zsh/rc.apps
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ then
}
fi

# mise-en-place
if [[ -x =mise ]]
then
eval "$(mise activate zsh)"
# TAB completion needs the "usage" tool (install with "mise use -g usage")
[[ -x =usage ]] && _cache-completion =mise "mise completion zsh"
fi

# PostgreSQL XDG redirects
if [[ -x =psql ]]
then
Expand Down
7 changes: 1 addition & 6 deletions zsh/rc.k8s
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
if [[ -x =kubectl ]]
then
funcdir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/funcs"
mkdir -p "$funcdir"
if [[ ! -e "$funcdir/_kubectl" || "$funcdir/_kubectl" -ot =kubectl ]]
then
kubectl completion zsh > "$funcdir/_kubectl"
fi
unset funcdir
_cache-completion =kubectl "kubectl completion zsh"

alias k='kubectl'

Expand Down
8 changes: 1 addition & 7 deletions zsh/rc.python
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,7 @@ unset p register_argcomp

if [[ -x =poetry ]]
then
funcdir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/funcs"
mkdir -p "$funcdir"
if [[ ! -f "$funcdir/_poetry" || "$funcdir/_poetry" -ot =poetry ]]
then
poetry completions zsh > "$funcdir/_poetry"
fi
unset funcdir
_cache-completion =poetry "poetry completions zsh"
fi

# vim: set ts=4 sw=4 ft=zsh:

0 comments on commit 6d74826

Please sign in to comment.