You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fish only considers $XDG_DATA_DIRS on shell startup, and thus will not dynamically load completions if $XDG_DATA_DIRS changes sometime after the shell starts. This leads to problems when using tools like direnv, which try to add completions on a per-folder basis.
Fish will search $fish_complete_path dynamically, so the idea is to implement a function which listens for changes to $XDG_DATA_DIRS, and attempts to keep that in sync with $fish_complete_path.
function fish_completion_sync --on-variable XDG_DATA_DIRS
# If there are paths in $FISH_COMPLETION_ADDITIONS,
# but not in $XDG_DATA_DIRS
# remove them from $fish_complete_path
# remove them from $FISH_COMPLETION_ADDITIONS
# if there are paths in $XDG_DATA_DIRS
# but not in $FISH_COMPLETION_ADDITIONS
# add them to $fish_complete_path
# add them to $FISH_COMPLETION_ADDITIONS
echo "got new data dirs: $XDG_DATA_DIRS"
end
Caveats
This has been working well for me, but it's stopped working a few times, and I haven't been able to pinpoint why. If you experience this, you can set the environment variable FISH_COMPLETION_DEBUG to help debug:
set-x FISH_COMPLETION_DEBUG 1
Submit an issue if the problem persists.
About
A fish plugin to help dynamically load fish completions from `$XDG_DATA_DIRS`.