ohmybash / oh-my-bash

A delightful community-driven framework for managing your bash configuration, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.
https://ohmybash.github.io
MIT License
5.59k stars 628 forks source link

Re-write zsh autosuggestions to bash. #377

Open chiddekel opened 1 year ago

chiddekel commented 1 year ago

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

akinomyoga commented 1 year ago

@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 commented 1 year ago

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

akinomyoga commented 1 year ago

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?

chiddekel commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

Ble can be module of BASH ( it's rather clean solution ;)) like 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

akinomyoga commented 1 year ago

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

As I have already replied,

https://github.com/ohmybash/oh-my-bash/issues/377#issuecomment-1344351789 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 commented 1 year ago

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

akinomyoga commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

How about this? https://bytexd.com/how-to-use-fzf-command-line-fuzzy-finder/

akinomyoga commented 1 year ago

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

akinomyoga commented 1 year ago

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 commented 1 year ago

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

RDhar commented 1 year ago

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