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

bashly completions for Bash, Fish, Zsh #384

Closed
EmilyGraceSeville7cf opened this issue Apr 18, 2023 · 17 comments · Fixed by #393
Closed

bashly completions for Bash, Fish, Zsh #384

EmilyGraceSeville7cf opened this issue Apr 18, 2023 · 17 comments · Fixed by #393
Labels
enhancement New feature or request

Comments

@EmilyGraceSeville7cf
Copy link
Collaborator

Description

It would be nice to have them. :)

@EmilyGraceSeville7cf EmilyGraceSeville7cf added the enhancement New feature or request label Apr 18, 2023
@DannyBen
Copy link
Owner

My thoughts on the subject:

  1. This is a headache to maintain.
  2. It adds another "ball and chain" on the command line - any change requires changing 3 other scripts.
  3. There is no other Ruby Gem that installs completions (to my knowledge) - if there is, I am curious to take a look at it.
  4. Continuing the above, it will probably mean that users have to install this completion script manually, which detaches it from the installation (or to have another bashly install-completions command, which is another overhead).
  5. Writing (and testing) completion scripts is tedious, especially since each shell wants its own format, but not only.
  6. Writing simple (read: basic) completion scripts for bash (that can work in other shells if they load bash completions) is relatively easy for me, using my completely gem (which is used by bashly itself to let users create completions for their generated script).
  7. The bashly CLI (as well as most of my other CLIs) intentionally have short and easy to write commands. bashly g is the same as bashly generate and one keystroke shorter than bashly g<tab>.

All that said - I am open to it, if most of the above concerns can be mitigated.

@EmilyGraceSeville7cf
Copy link
Collaborator Author

I've heard about carapace package to generate completions. I just need to play with it a little bit to create completions for shells. :)

@DannyBen
Copy link
Owner

I've heard about carapace package to generate completions

Interesting.

I see it also has a list of CLIs it provides completions to. Perhaps adding bashly to it is easier than other implementation routes.

@DannyBen
Copy link
Owner

DannyBen commented Jun 20, 2023

@EmilySeville7cfg - since you raised this issue, if you want to test my implementation, it would be nice.

With #393, it is now possible to:

  1. Run bashly completions and get a completions script to stdout (for manual copying to anywhere)
  2. Run bashly completions --install and (hopefully) get the script installed in one of the system's bash completions directories
  3. Download the bash completions script manually and copy it wherever.

@EmilyGraceSeville7cf
Copy link
Collaborator Author

I'll check it out today. :)

@DannyBen
Copy link
Owner

All the patterns that can be completed can be easily seen in the completely.yaml file.

@DannyBen DannyBen reopened this Jun 23, 2023
@DannyBen
Copy link
Owner

Refactored completions installation, thanks to the new Completely::Installer class introduced in DannyBen/completely#51

@EmilyGraceSeville7cf
Copy link
Collaborator Author

Trying to built the latest version of bashly, gem install bashly.gem fails with:

Fetching requires-1.0.1.gem
Fetching docopt_ng-0.7.1.gem
Fetching colsole-1.0.0.gem
Fetching mister_bin-0.7.6.gem
Fetching lp-0.2.1.gem
Fetching gtx-0.1.0.gem
Fetching module_methods-0.1.0.gem
Fetching filewatcher-2.1.0.gem
Fetching completely-0.6.0.gem
ERROR:  While executing gem ... (Gem::FilePermissionError)

output. sudo solves this issue. Maybe add some note about it?

@EmilyGraceSeville7cf
Copy link
Collaborator Author

@DannyBen, I am not sure but I would like to suggest to add bashly completions --uninstall option too.

@EmilyGraceSeville7cf
Copy link
Collaborator Author

EmilyGraceSeville7cf commented Jun 23, 2023

After installation and session restart I have no working completions for bashly. I've tried run bash as: bash and bash --norc (as I use BLE).

image

What is shown with white background is a BLE stuff (it shows the most recent command starting with bashly like Fish does).

@EmilyGraceSeville7cf
Copy link
Collaborator Author

EmilyGraceSeville7cf commented Jun 23, 2023

Solution: install bash-completion package. ;) Can you mention that this package is required for making bashly completions --install work? Maybe add a warning while installation and suggestion to pull bash-completion package when the latter one is missing.

@DannyBen
Copy link
Owner

sudo solves this issue. Maybe add some note about it?

Gems should normally not be installed with sudo

Solution: install bash-completion package

On non-bash shells, this is needed, yes.
What did you run? brew install bash-completions or apt install bash-completions?

bashly completions --uninstall

Yes. But this will require an update to completely as well.

@EmilyGraceSeville7cf
Copy link
Collaborator Author

EmilyGraceSeville7cf commented Jun 23, 2023

What did you run? brew install bash-completions or apt install bash-completions?

The later one.

Gems should normally not be installed with sudo

So... is it my personal issue or not? I use Linux 22.04 Ubuntu.

@DannyBen
Copy link
Owner

So... is it my personal issue or not? I use Linux 22.04 Ubuntu.

It is weird that you needed bash-completions then. I am also on Ubuntu.
You are probably using the system ruby, which is not ideal.

  1. People who use Ruby regularly, install Ruby with a version manager. I am using rbenv and installing my Ruby with rush get ruby
  2. People who do not use Ruby regularly, should probably use the bashly docker image, or take the time to set up a proper ruby environment.

A quick search of your error comes up with a StackOverflow question, with answers to install a version manager.

All that said - it would help if you tell me after your trial-and-errors - what you believe other users should be aware of, if there is anything other than apt install bash-completions.

@EmilyGraceSeville7cf
Copy link
Collaborator Author

You are probably using the system ruby, which is not ideal.

I've installed it via ruby-full package. 🤔

@DannyBen
Copy link
Owner

Added bashly completions --uninstall and pushed to a docker edge so you dont have to mess with ruby.

@DannyBen
Copy link
Owner

Released in 1.0.6.

DannyBen added a commit to DannyBen/bashly-book that referenced this issue Jun 29, 2023
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

Successfully merging a pull request may close this issue.

2 participants