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

Re-write zsh autosuggestions to bash. #377

Open
chiddekel opened this issue Dec 9, 2022 · 15 comments
Open

Re-write zsh autosuggestions to bash. #377

chiddekel opened this issue Dec 9, 2022 · 15 comments

Comments

@chiddekel
Copy link

Rewrite this zsh plugin to bash to support autosuggestions:
https://github.com/zsh-users/zsh-autosuggestions

Bash Reference Manual:
https://www.gnu.org/software/bash/manual/html_node/index.html

@chiddekel chiddekel changed the title Re-write zsh autosugestions to bash. Re-write zsh autosuggestions to bash. Dec 9, 2022
@akinomyoga
Copy link
Contributor

@chiddekel Is this a request? Or is this something that you are now working on? Could you explain the background of the issue in a bit more detail?

@chiddekel
Copy link
Author

chiddekel commented Dec 9, 2022

No. No. I can help with research - how to rewrite it line to line.

@akinomyoga
Copy link
Contributor

akinomyoga commented Dec 9, 2022

Are you sure it is possible to achieve the autosuggestions in Bash by rewriting zsh-autosuggestions for Bash? It seems to be impossible to me because zsh-autosuggestions relies on two important features that are available in Zsh but not in Bash. One is the ability to call the built-in widgets from the script, and the other is the ability to specify the color of a part of the string in the text buffer. Both are impossible in Bash. The former is needed to insert the processing of the autosuggestion keeping the existing keybindings. The latter is needed to make the appearance of the suggested text different from the already input text.

Anyway, what is your true purpose?

  • If your interest is just to rewrite zsh-autosuggestions but not the autosuggestion itself, I wouldn't stop you, but I have to say that the rewritten script would never work for the above reasons.
  • If your purpose is to implement autosuggetions in Bash, I must say rewriting zsh-autosuggestions is not the right way to achieve that. You should consider a different approach.
  • If your purpose is to use autosuggestions in Bash, this issue is a duplicate of an existing one autosuggestion suppprt #108. In this case, consider using existing implementations of autosuggestions for Bash, such as ble.sh.

@chiddekel
Copy link
Author

chiddekel commented Dec 9, 2022

Nice. Zsh use zle - and provide that way widget's so basically rewriting the plugin zsh-autosuggestion can be test/Guide for how to Bash ble.sh can be upgrade. So instead write everything in ble.sh - add after rewrite ble.sh as a extension bash - that missing zle features then develop as a plugin on system like oh my zsh. And even when stable enough can be (ble) official part of bash.

@akinomyoga
Copy link
Contributor

Nice. Zsh use zle - and provide that way widget's so basically rewriting the plugin zsh-autosuggestion can be test/Guide for how to Bash ble.sh can be upgrade.

Bash/Readline doesn't provide the necessary feature to port zsh-autosuggestions, but ble.sh already provides the necessary features to port zsh-autosuggestions, so I currently do not see any necessity in upgrading ble.sh. However, to begin with, ble.sh already supports the proper autosuggestions, so there is no need to do a dirty hack that zsh-autosuggestions is doing. I'm not interested in porting a dirty implementation of zsh-autosuggestions for ble.sh when we already have a proper implementation of autosuggetions.

So instead write everything in ble.sh - add after rewrite ble.sh as a extension bash

What do you specifically mean by "rewrite ble.sh as an extension of Bash"? It's already a kind of an extension written in "shell", but are you thinking of rewriting it in C? If so, I'm not interested in it. See also my reply in ble.sh#214.

that missing zle features then develop as a plugin on system like oh my zsh. And even when stable enough can be (ble) official part of bash.

It is unlikely that ble.sh becomes a part of an official part of Bash. First of all, the license is incompatible. It is troublesome to switch the license of ble.sh because it contains some contributed codes for which I don't own the copyright.

@chiddekel
Copy link
Author

chiddekel commented Dec 9, 2022

@akinomyoga
Copy link
Contributor

Ble can be module of BASH ( it's rather clean solution ;)) like

As I have already replied,

#377 (comment) It is unlikely that ble.sh becomes a part of an official part of Bash. First of all, the license is incompatible.

Anyway, I'm not the Bash maintainer so have nothing to do about it. You should discuss the upgrading of the official Bash in the official place instead of here. Bash already has an independent line editor called Readline, so you want to consider extending Readline. The problem is that no one else seems to be interested in working on extending Readline in the official community, so you should work on it by yourself to extend Readline.


Zle is module for ZSH :)
https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html
https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins
https://zsh.sourceforge.io/Doc/Release/Zsh-Line-Editor.html#Zle-Widgets

I know that because I took the name from ZLE as explained in ble.sh's README.md.

@chiddekel
Copy link
Author

Ble as Module of Bash as third party, because of license.
Redline can be as God as ZLE?

@akinomyoga
Copy link
Contributor

Ble as Module of Bash as third party, because of license.

Yes, and it's already a third-party module.

Redline can be as God as ZLE?

If you work hard to improve Readline, why not?

@chiddekel
Copy link
Author

chiddekel commented Dec 9, 2022

Thanks - Time to list features of zsh-autosuggestions using ZLE, and to migrate, using Ble or Readline extended - and start developing. If any can help I will create a new repo in two weeks.

@chiddekel
Copy link
Author

@akinomyoga
Copy link
Contributor

fzf is different from autosuggestions. Also, fzf is already available in Bash.

@akinomyoga
Copy link
Contributor

akinomyoga commented Dec 12, 2022

In the meantime, someone is positing a new implementation of Bash autosuggestions in Reddit [1]. The project [2] seems to have started just on December 8th and is active now.

@chiddekel
Copy link
Author

So it's good to add it to oh my bash - 😎 when production ready.

@rdhar
Copy link

rdhar commented Feb 1, 2023

With initial support for bash-completions just introduced, perhaps this isn't so far away, @armoar334!

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

No branches or pull requests

3 participants