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 -s auto-complete option #3523

Closed
wants to merge 3 commits into from
Closed

Conversation

animaone
Copy link
Contributor

@animaone animaone commented Oct 7, 2022

Add -s auto-complete option.

Commented at the following issue: #3522

Add -s auto-complete option.
Copy link
Collaborator

@rom1v rom1v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you. 👍

Could you also add it to the zsh completion script?

@@ -93,6 +93,11 @@ _scrcpy() {
COMPREPLY=($(compgen -W 'verbose debug info warn error' -- "$cur"))
return
;;
-s|--serial)
# Use 'adb devices' to list serial numbers.
COMPREPLY=($(compgen -W "$(adb devices | awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that scrcpy may not work in recovery or sideload state, so maybe adb devices |awk '/device$/{print $1}' is sufficient.

since scrcpy don't work in sideload and recovery options, I've removed them.
@@ -95,7 +95,7 @@ _scrcpy() {
;;
-s|--serial)
# Use 'adb devices' to list serial numbers.
COMPREPLY=($(compgen -W "$(adb devices | awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) )
COMPREPLY=($(compgen -W "$(adb devices | awk '/device$/{print $1}')" -- ${cur} ) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if the ADB environment variable is set, this adb should be used instead.

"${ADB:-adb}" devices | awk …

rom1v pushed a commit that referenced this pull request Oct 7, 2022
Fixes #3522 <#3522>
PR #3523 <#3523>

Signed-off-by: Romain Vimont <rom@rom1v.com>
Add -s autocompletion for zsh
@animaone
Copy link
Contributor Author

animaone commented Oct 8, 2022

Ok. I've added a similar solution to the zsh completion. :)

rom1v pushed a commit that referenced this pull request Oct 12, 2022
Fixes #3522 <#3522>
PR #3523 <#3523>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Oct 12, 2022
Fixes #3522 <#3522>
PR #3523 <#3523>

Signed-off-by: Romain Vimont <rom@rom1v.com>
rom1v pushed a commit that referenced this pull request Oct 12, 2022
Fixes #3522 <#3522>
PR #3523 <#3523>

Signed-off-by: Romain Vimont <rom@rom1v.com>
@rom1v
Copy link
Collaborator

rom1v commented Oct 12, 2022

Thank you 👍

I rebased your commits onto dev, and made the following changes:

  • handle the case where the ADB environment variable is set
  • slightly adapt the awk command: awk '$2 == "device" {print $1}'
  • use the same awk command for zsh completion

I pushed to branch pr3523. Could you please check?
If that's ok, I'll merge into dev.

@animaone
Copy link
Contributor Author

animaone commented Oct 15, 2022

Checked. Many thanks 👍 :)

@rom1v
Copy link
Collaborator

rom1v commented Oct 15, 2022

Thanks 👍

Merged into dev. 🚀

@rom1v rom1v closed this Oct 15, 2022
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.

2 participants