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

Path AutoComplete On First Argument #512

Closed
mattcargile opened this issue Jun 11, 2023 · 5 comments
Closed

Path AutoComplete On First Argument #512

mattcargile opened this issue Jun 11, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@mattcargile
Copy link

mattcargile commented Jun 11, 2023

Is your feature request related to a problem? Please describe.
It would be nice to see the autocomplete script use the ShellCompDirectiveDefault instead of ShellCompDirectiveNoFileComp on completion of the first argument. It appears that is the default too.

It appears like it could be completed with this ValidArgsFunction. I think it can be handled with this doc. And ideally maybe ShellCompDirectiveFilterFileExt for .md files or .markdown files.

I assume the edit would be somewhere here.

glow/main.go

Lines 40 to 48 in 58ec351

rootCmd = &cobra.Command{
Use: "glow [SOURCE|DIR]",
Short: "Render markdown on the CLI, with pizzazz!",
Long: paragraph(fmt.Sprintf("\nRender markdown on the CLI, %s!", keyword("with pizzazz"))),
SilenceErrors: false,
SilenceUsage: false,
TraverseChildren: true,
RunE: execute,
}

I'm not exactly sure how it works but oh-my-posh is able to do some of it below. For instance, oh-my-posh.exe print --config + <TAB> will complete a path. The code being executed is oh-my-posh.exe __complete print --config "" to get the path which will show ShellDirectiveDefault.

https://github.com/JanDeDobbeleer/oh-my-posh/blob/a0742d640b21d3ffca5af1a4910fe4e329c558ec/src/cli/print.go#L29-L91

Describe the solution you'd like
I would like paths and the sub commands to be auto completed.

Describe alternatives you've considered
Right now, I have the completion turned off as it isn't useful without the path completion. Typical usage is glow + <TAB> into a file.

Additional context
Additional context added above.

@tmzhuang
Copy link

tmzhuang commented Aug 9, 2024

This seems to be still broken for me on bash. Running glow completion bash > ~/scripts/glow_completion.sh and then sourcing the file does not seem to resolve the issue. Pressing tab gives the behavior described in the initial comment.

@caarlos0
Copy link
Member

caarlos0 commented Aug 9, 2024

are you using glow from master? I think the fix is not yet released...

@mattcargile
Copy link
Author

Speaking of release . Are we getting one anytime soon, @caarlos0 ?

Side note, this issue should probably be closed too.
#536

@caarlos0
Copy link
Member

caarlos0 commented Aug 9, 2024

Yes! I think next week! Please do test the master branch if you can, though 🙏

@mattcargile
Copy link
Author

Yes! I think next week! Please do test the master branch if you can, though 🙏

Just built it. Tab works great now on paths. 👍🏻

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

No branches or pull requests

3 participants