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

add completion file for bash/zsh (mainly for use in WSL/WSL2) #2978

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

hltdev8642
Copy link

@hltdev8642 hltdev8642 commented Jan 16, 2023

Description Of Changes

Add completion file for zsh (Mainly for use in WSL/WSL2).
Note: I can also create a bash completion file, if that is of interest

Motivation and Context

I use choco on a daily basis, mainly via WSL with the windows choco executable in my path and linked with an alias.

I thought it would be useful to have tab-completion in the linux shell, as otherwise you either have to continually execute the choco --help command, or switch to a powershell prompt to utilize the provided ps1 completion file provided.

Thus, I made this completion file, using the helpers/ChocolateyTabExpansion.ps1 file as a reference.

Testing

N/A: Has no effect on any functionality, just a completion file.

Adding the completion file into terminal (zsh):

sudo cp _chocolatey /usr/local/share/zsh/site-functions
sudo chmod 755  /usr/local/share/zsh/site-functions/_chocolatey

restart shell: (can be done via:)

. ~/.zshrc`)

To test:

chocolatey.exe [tab]

Note: You may have to add chocolatey to your path (if in WSL/WSL2) which is done by adding the following line to either your ~/.zsh_aliases or ~/.bash_aliases file:

alias choco="/mnt/c/ProgramData/chocolatey/bin/chocolatey.exe"`

(you can use choco, chocolatey, chocolatey.exe, etc ... (anything you want for a command name, and the completion will work regardless)

Operating Systems Testing

N/A: Has no effect on any functionality, just a completion file.

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v2 compatibility checked?

Related Issue

Fixes #2977

@CLAassistant
Copy link

CLAassistant commented Jan 16, 2023

CLA assistant check
All committers have signed the CLA.

@gep13
Copy link
Member

gep13 commented Jan 17, 2023

@hltdev8642 thank you for taking the time to submit this PR!

For the testing section, can I ask that you provide some additional information? While it is correct that this addition isn't changing any Chocolatey functionality, it still has to be tested. i.e. what are the steps for adding the completion file into the terminal? Is it necessary to reboot the shell to take effect, etc. All of these types of things should be captured in this section so that anyone in the team, perhaps who aren't familiar with completion files (myself included), would be able to verify that things are working as expected.

@gep13
Copy link
Member

gep13 commented Jan 25, 2023

@hltdev8642 I wanted to follow up with the above request. Is this something that you can help us with? I would like to see this change land, however, in it's current state, we won't be able to move forward with this change.

@hltdev8642
Copy link
Author

@gep13 , I was just a bit busy but going to work on this today ! I will have it done by the end of the day today 😉👍.

@gep13
Copy link
Member

gep13 commented Jan 25, 2023

@hltdev8642 said...
@gep13 , I was just a bit busy but going to work on this today ! I will have it done by the end of the day today 😉👍.

Woot! That is great news, thank you!

@hltdev8642
Copy link
Author

@hltdev8642 thank you for taking the time to submit this PR!

For the testing section, can I ask that you provide some additional information? While it is correct that this addition isn't changing any Chocolatey functionality, it still has to be tested. i.e. what are the steps for adding the completion file into the terminal? Is it necessary to reboot the shell to take effect, etc. All of these types of things should be captured in this section so that anyone in the team, perhaps who aren't familiar with completion files (myself included), would be able to verify that things are working as expected.

All set @gep13 , let me know if there is anything else needed 😉
I can also make the mentioned bash completion file (+ testing/usage) if you'd like as well. Shouldn't take too long to implement!

Best,
@hltdev8642

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

Successfully merging this pull request may close these issues.

completion file for bash/zsh in WSL/WSL2
3 participants