fish-shell / fish-shell

The user-friendly command line shell.
https://fishshell.com
Other
26.09k stars 1.91k forks source link

Custom completions do not work in tmux #10822

Closed stevalkr closed 4 hours ago

stevalkr commented 6 hours ago

I have a simple completion for custom command ws under ~/.config/fish/completions like:

complete --command ws -f -a icloud --description "iCloud" --condition "__fish_use_subcommand"
complete --command ws -f -a config --description "~/.config" --condition "__fish_use_subcommand"

In normal fish shell, I can have completions pressing tab. But in tmux, this completion is ignored, only showing files under current directory. This also happens for other commands having complete files under ~/.config/fish/completions, like nix, fisher.

krobelus commented 6 hours ago

On Thu, Oct 31, 2024 at 04:40:10AM -0700, Steve Walker wrote:

I have a simple completion for custom command ws under ~/.config/fish/completions like:

complete --command ws -f -a icloud --description "iCloud" --condition "__fish_use_subcommand"
complete --command ws -f -a config --description "~/.config" --condition "__fish_use_subcommand"

In normal fish shell, I can have completions pressing tab. But in tmux, this completion is ignored, only showing files under current directory. This also happens for other commands having complete files under ~/.config/fish/completions, like nix, fisher.

are the outputs of printf %s\n $__fish_config_dir $fish_complete_path and of fish_trace=1 complete -C 'ws ' different outside and inside tmux?

stevalkr commented 6 hours ago

They are different. Original path was inherited as one variable separated by space.

Outside tmux:

~> printf %s\n $fish_complete_path
/Users/walker/.config/fish/completions
/opt/homebrew/etc/fish/completions
/Users/walker/.local/share/fish/vendor_completions.d
/Applications/kitty.app/Contents/Resources/kitty/shell-integration/fish/vendor_completions.d
/opt/homebrew/share/fish/vendor_completions.d
/opt/homebrew/Cellar/fish/3.7.1/share/fish/completions
/Users/walker/.local/share/fish/generated_completions
/Users/walker/.nix-profile/share/fish/vendor_completions.d

Inside tmux:

~> printf %s\n $fish_complete_path
/Users/walker/.config/fish/completions /opt/homebrew/etc/fish/completions /Users/walker/.local/share/fish/vendor_completions.d /Applications/kitty.app/Contents/Resources/kitty/shell-integration/fish/vendor_completions.d /opt/homebrew/share/fish/vendor_completions.d /opt/homebrew/Cellar/fish/3.7.1/share/fish/completions /Users/walker/.local/share/fish/generated_completions /Users/walker/.nix-profile/share/fish/vendor_completions.d
/opt/homebrew/Cellar/fish/3.7.1/share/fish/completions
/Users/walker/.nix-profile/share/fish/vendor_completions.d
krobelus commented 5 hours ago

On Thu, Oct 31, 2024 at 05:18:11AM -0700, Steve Walker wrote:

They are different. Original path was inherited as one variable separated by space.

confirm by running set -S fish_complete_path (it says whether it was inherited). If yes, you are exporting fish_complete_path which is wrong. Fish should figure out the path; at most you should add entries to it. Also try bisecting you tmux config.

stevalkr commented 4 hours ago

Thank you so much! Removing -x in

set -x fish_complete_path $fish_complete_path $HOME/.nix-profile/share/fish/vendor_completions.d

in my config solves the problem!