Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shell completion issues (zsh & fish) #359

Open
xenoterracide opened this issue Jul 17, 2021 · 20 comments
Open

shell completion issues (zsh & fish) #359

xenoterracide opened this issue Jul 17, 2021 · 20 comments
Labels

Comments

@xenoterracide
Copy link

when typing yadm add <tab> files are never listed, and my shell seems to hang. This may be related to #292 but I don't know.

❯ yadm --version && zsh --version && uname -a                                                   # ~
yadm 3.1.0
zsh 5.8 (x86_64-pc-linux-gnu)
Linux CarbonX1-8-Manjaro 5.10.49-1-MANJARO #1 SMP PREEMPT Sun Jul 11 12:59:43 UTC 2021 x86_64 GNU/Linux
@primeapple
Copy link

Having the same issue with fish shell on MacOS.

> yadm --version && fish --version && uname -a
yadm 3.1.0
fish, version 3.3.1
Darwin my-mbpro.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64

@kkga
Copy link

kkga commented Jul 20, 2021

Same problem on yadm 3.1.0, fish 3.3.1, Linux

@Animeshz
Copy link

Same problem yadm 3.1.0, fish 3.3.1.

@moritzreiter
Copy link

moritzreiter commented Dec 20, 2021

Is there really no fix or workaround in sight for this?

I read through two closed issues in the fish repo to try and find a hint for a solution.

One of the main fish developers (@faho) seems to basically say that tab completion to be very slow is to be expected when using $HOME as a git repo, because $HOME is usually very large (as in a huge number files).

I tried multiple variations of a ~/.gitignore to ignore most of $HOME as a workaround. One of the variations seemed to speed things up a little bit, but it was still way too slow to be pleasantly usable. I wonder if all yadm users who also use fish or zsh have this problem or just some?

Also I just tried, and the path completion works just fine with bash.

@kkga
Copy link

kkga commented Dec 20, 2021

yeah, I still have the same issue.

I did manage to speed it up significantly by putting almost everything in ~/.gitignore though:

~ 1.7s » cat .gitignore
/notes
/tmp
/downloads
/sync
/repos
/projects
/pictures
/videos
/.local/share/fish
/.local/share/kak
/.config/chromium
.terminfo
.npm
.mozilla
.cargo
.local/cargo
.local/go
.local/lib
.local/share/Trash
.local/share/trash
.cache/

@joshzcold
Copy link

joshzcold commented Dec 20, 2021

how about this work around? For me when I want to yadm add something its because I added a new config file that's untracked. for everything else that is tracked I use yadm add -u.
unless there is a more supported way to manage our dotfiles that keeps the git add completion intact I would think it would be better to make this the functionality by default because the freeze on yadm add is confusing for new users.

# ~/.zshrc
function _yadm-add(){ _ls }

Peek 2021-12-20 11-15

Edit: with a bit more trickery we could have the best of both worlds.

function _yadm-add(){
  yadm_path="$(yadm rev-parse --show-toplevel)"
  yadm_options=$(yadm status --porcelain=v1 |
      awk -v yadm_path=${yadm_path} '{printf "%s/\"%s\"\\:\"%s\" ",  yadm_path, $2, $1 }' )
  _alternative \
    "args:custom arg:(($yadm_options))" \
    'files:filename:_files'
}

(anything better to do the formatting than awk?)

2021-12-20.14.13.46.mp4

@kvokka
Copy link

kvokka commented Jan 23, 2022

Same problem with MacOs 12.1, yadm 3.1.1 & zsh 5.8

@yxnan
Copy link

yxnan commented Jan 26, 2022

Same on Fedora 35, yadm 3.1.1, fish 3.3.1

However on fish there is a workaround to only use Ctrl+F to complete, which is a built-in functionality of the fish shell.

@joshzcold
Copy link

To move this along I made a pull request #417
From there we can look into improving the completion script to something ideal for everyone.

@TheLocehiliosan TheLocehiliosan changed the title zsh add completions broken shell completion issues (zsh & fish) Jan 23, 2023
@cmer
Copy link

cmer commented Feb 22, 2023

I can confirm that Fish tab completion is still broken in 3.2.2.

@jc00ke
Copy link

jc00ke commented Jun 30, 2023

@TheLocehiliosan I somehow missed your comment, just happened to see it now.

❯ yadm --version && fish --version && uname -a
bash version 5.2.2(1)-release
 git version 2.37.2
yadm version 3.2.2
fish, version 3.5.1
Linux igor 5.19.0-45-generic #46-Ubuntu SMP PREEMPT_DYNAMIC Wed Jun 7 09:08:58 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Is there any other information I can provide that would be helpful?

@lkirkwood
Copy link

Bump on this — love yadm (3.1.1) but tab completion hangs with fish (3.3.1) is a big deal when adding previously untracked files.
Anybody found a fix for this in fish?

@matt-oakes
Copy link

This appears to be an issue with the git completions bundles inside fish and not an issue with yadm.

You can see this behaviour by creating a new repo in your home with git init then entering git add and pressing tab. It will hang, likely due to the number of files which are untracked from your home directory.

@joshzcold
Copy link

joshzcold commented Feb 20, 2024

I fixed this in zsh for yadm by just overwriting the default completions and putting in completion based on yadm status and ls

https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/completion/zsh/_yadm#L10

I'm sure we can just copy a fish equivalent function over

@matt-oakes
Copy link

The autocomplete for the git commands in fish come from telling complete that it's wrapping all of git, which passes through all of the git autocompletes which are bundled inside fish itself.

https://github.com/TheLocehiliosan/yadm/blob/0a5e7aa353621bd28a289a50c0f0d61462b18c76/completion/fish/yadm.fish#L74-L77

I tried adding my own autocomplete for add but it still seemed to use the git one for some reason. It's the first time I've tried to create autocompletions though.

@joshzcold
Copy link

joshzcold commented Feb 23, 2024

This is what I have so far

function __fish_yadm_status_options
    # set -l fish_trace on
    set -l yadm_path (yadm rev-parse --show-toplevel)
    set -l yadm_status (yadm status --porcelain=v1 | awk '{print $2}')
    set -l yadm_options (echo "$yadm_status" | awk -v yadm_path="$yadm_path" '{printf "%s/%s%s\n",  yadm_path, $2, $1}' )
    echo $yadm_options
end

complete -e yadm --wraps 'git --git-dir=/home/joshua/.local/share/yadm/repo.git'
complete -c yadm -n "__fish_seen_subcommand_from add" -a "(__fish_yadm_status_options)"
complete -c yadm -n "__fish_seen_subcommand_from add" -F
complete -c yadm -n "__fish_seen_subcommand_from checkout" -a "(__fish_yadm_status_options)"
complete -c yadm -n "__fish_seen_subcommand_from checkout" -F

The part I haven't fixed yet is that when applied complete -e yadm --wraps 'git --git-dir=/home/joshua/.local/share/yadm/repo.git' will delete all the completions, but what I want is just to overwrite specific completions for git add and git checkout

I think the solution would be to wrap git completions for specific command and not everything.

Put into .config/fish/completions/yadm.fish to test, but will remove the default completions.

I don't think fish has to ability to wrap specific completions from git but ignore a couple.
To fully fix this I think you would have to loop through the git completion file and ignore specific lines, which is ugly.

@matt-oakes
Copy link

Thanks for looking into this @joshzcold. It looks like we got to the same point in deciding that it wasn't possible to wrap a command but overwrite just some of the completions.

I have posted on the Fish Shell mailing list to ask if there is the ability to do this currently. Hopefully someone who knows more about Fish completions can provide some help from there.

@kleutzinger
Copy link

kleutzinger commented Apr 4, 2024

A slight workaround I do for yadm add ... on fish is to type the first couple characters of the file I want, then use ctrl + e or right arrow key to complete the filename. Not quite as powerful as true tab completion, but it's something.

You can also do yadm add (ls <tab>) for hacky tab completion.

@radutomy
Copy link

This bug is ridiculously annoying. It freezes my terminal for 20sec :(

@meseck
Copy link

meseck commented Dec 19, 2024

This bug is ridiculously annoying. It freezes my terminal for 20sec :(

If this happens you can interrupt the completion process with 'Ctrl-c'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests