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

oilshell escapes completion candidates #915

Closed
rsteube opened this issue Mar 25, 2021 · 8 comments
Closed

oilshell escapes completion candidates #915

rsteube opened this issue Mar 25, 2021 · 8 comments

Comments

@rsteube
Copy link

rsteube commented Mar 25, 2021

Oil escapes special characters in the completion view which makes descriptions a bit harder to read.
Btw. is there no pager for completions?

osh$ gh issue view
 1023\ \(Allow\ editing\ the\ commit\ message\ when\ squash-merging\ a\ PR\)
 1247\ \(gh\ repo\ fork\ cannot\ fork\ to\ org\)
 1262\ \(Automatic\ WinGet\ pkg\ update\)
 1303\ \(Support\ aliases\ deeper\ than\ top\ level,\ e.g.\ \`gh\ pr\ co\`\)
 1450\ \(Select\ commit\ email\ when\ merging\ PR\)
 1575\ \(HTTP\ 414:\ Request-URI\ too\ large\)
 1634\ \(Add\ command\ to\ watch\ running\ Github\ Action\(s\)\ in\ repo\)
 1646\ \(Support\ \`gh\ pr\ create\ --browse\ --copy\`\ as\ in\ hub\ to\ open\ and\ copy\ PRs\)
 1735\ \(Skip\ certificate\ warning,\ using\ internal\ enterprise\ CA\ \"certificate\ signed\ by\ unknown\ authority\"\)
 1745\ \(Repo\ commands\ assume\ non-enterprise\ auth\ and\ fail\ trying\ to\ auth\ against\ github.com\)
 1798\ \(Installation\ failed\ on\ Kali\)
 ... and 89 more
bash$ gh issue view
Display all 100 possibilities? (y or n)
1023 (Allow editing the commit message when squash-merging a PR)
1247 (gh repo fork cannot fork to org)
1262 (Automatic WinGet pkg update)
1303 (Support aliases deeper than top level, e.g. `gh pr co`)
1450 (Select commit email when merging PR)
1575 (HTTP 414: Request-URI too large)
1634 (Add command to watch running Github Action(s) in repo)
1646 (Support `gh pr create --browse --copy` as in hub to open and copy PRs)
1735 (Skip certificate warning, using internal enterprise CA "certificate signed by unknown authority")
1745 (Repo commands assume non-enterprise auth and fail trying to auth against github.com)
1798 (Installation failed on Kali)
@andychu
Copy link
Contributor

andychu commented Mar 25, 2021

  • Hm this was sort of intentional since bash's output is ambiguous when you have multiple candidates on a line (is the space within a candidates, or separating candidates?). But I see how in this case it makes it less readable. If we can do it within the constraints of readline, I'd be open to changing it, or have an option to change it.
  • Unfortunately I don't see a way to do a pager with GNU readline.

Basically I ran into a lot of problems doing what I want with GNU readline. It may be that we have to go back to bash-style completion with scrolls the screen, and has the annoying "Display 100 candidates?" prompt.

And then we provide APIs so people can write stuff like ohmyzh or ble.sh in Oil -- issue #663

@rsteube
Copy link
Author

rsteube commented Mar 25, 2021

It's just something i noticed as other shells don't do this.
The ambigouity is probably less of a problem when you have menu completion.
Not a fan of scrollers and questions as well - e.g. powershell asks if completions should be shown if they exceed a specific number even though it has menu completion.
Seems nushell and ion use rustyline.

@andychu
Copy link
Contributor

andychu commented Mar 25, 2021

Yeah there are a lot of other choices, issue #460 is related. Unfortunately we need contributions for all the interactive stuff; I'm still focused on the language and runtime mainly.

native/line_input.c is a Python wrapper for GNU readline (forked from Python's owner wrapper). If we had a similar wrapper for other line editing libraries that would enable some experimentation with the UI and so forth.

I'm not sure if there are fancy ones in C/C++ -- I think zsh and fish have them tightly integrated and not reusable.

But in theory we can reuse one in Rust if it exposes a shared library interface.

@andychu
Copy link
Contributor

andychu commented Feb 21, 2022

Hi @rsteube , we just noticed the https://github.com/rsteube/carapace-bin project over on the Oil Zulip:

https://oilshell.zulipchat.com/#narrow/stream/146045-shell-autocompletion/topic/caraspace.20--.20A.20project.20that.20implements.20completions.20for.20te.2E.2E.2E

I wonder how it's going and if this escaping issue is still a problem? Glad to see this effort

I haven't thought about it that much, but I just did some stuff with GNU readline, so maybe we can figure out a solution ...

@rsteube
Copy link
Author

rsteube commented Feb 21, 2022

Well it's not really a problem, but yes it still has this behaviour. Descriptions are kinda "hacked in" anyway.

Recently learned about ble.sh which managed to replace readline in pure bash 😮 :
asciicast

@andychu
Copy link
Contributor

andychu commented Feb 22, 2022

In that screenshot, is that the default ble.sh, or is that running with some of your enhancements?

And yes ble.sh is almost certainly the biggest shell program in the world! We've been working on it on #653 and #1069

https://github.com/oilshell/oil/wiki/The-Biggest-Shell-Programs-in-the-World


I've never seen the stackoverflow trick for descriptions ... So does it actually work with OSH?

@rsteube
Copy link
Author

rsteube commented Feb 22, 2022

Default ble.sh with starship prompt - just enhanced with the completions.
Btw. it's an asciicast: https://asciinema.org/a/470338

andychu pushed a commit that referenced this issue Sep 12, 2023
Specifically, for complete -F bashfunc

This makes upstream git-completion.bash work!  (one old copy is in
testdata/completion/git-completion.bash)

It uncovered some bugs in 'complete -W' though.  There are more tests we
can do.

This is issue #915.
@andychu
Copy link
Contributor

andychu commented Sep 18, 2023

Sorry for the long delay on this -- we had sort of lost steam on completion, and are now back to it, for YSH

So OSH is more compatible now

Released - https://www.oilshell.org/blog/2023/09/release-0.18.0.html

@andychu andychu closed this as completed Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants