Skip to content

Add -s auto-complete option - #3523

Closed
animaone wants to merge 3 commits into
Genymobile:masterfrom
animaone:patch-1
Closed

animaone wants to merge 3 commits into
Genymobile:masterfrom
animaone:patch-1

Conversation

@animaone

@animaone animaone commented Oct 7, 2022

Copy link
Copy Markdown
Contributor

Add -s auto-complete option.

Commented at the following issue: #3522

Add -s auto-complete option.

@rom1v rom1v left a comment

Copy link
Copy Markdown
Collaborator

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?

Comment thread app/data/bash-completion/scrcpy Outdated
;;
-s|--serial)
# Use 'adb devices' to list serial numbers.
COMPREPLY=($(compgen -W "$(adb devices | awk '/(device|recovery|sideload)$/{print $1}')" -- ${cur} ) )

Copy link
Copy Markdown
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.
-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
Copy Markdown
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

animaone commented Oct 8, 2022

Copy link
Copy Markdown
Contributor Author

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

rom1v commented Oct 12, 2022

Copy link
Copy Markdown
Collaborator

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

animaone commented Oct 15, 2022 •

Copy link
Copy Markdown
Contributor Author

Checked. Many thanks 👍 :)

@rom1v

rom1v commented Oct 15, 2022

Copy link
Copy Markdown
Collaborator

Thanks 👍

Merged into dev. 🚀

@rom1v rom1v closed this Oct 15, 2022
Linux4 pushed a commit to Linux4/scrcpy that referenced this pull request Sep 5, 2025
scrcpy v1.25

Changes since v1.24:
 - Adapt copy-paste internals for Android 13 (Genymobile#3497)
 - Add support for high-precision scrolling (Genymobile#3363, Genymobile#3369)
 - Add desktop entry files for Linux (Genymobile#295, Genymobile#296, Genymobile#748, Genymobile#1636, Genymobile#3351)
 - Add bash and zsh autocompletion for -s/--serial (Genymobile#3522, Genymobile#3523)
 - Use current adb port (if any) for --tcpip (Genymobile#3591, Genymobile#3592)
 - Add fallback to get display information on some devices (Genymobile#3416, Genymobile#3573)
 - Fix click behavior when --forward-all-clicks is set (Genymobile#3568, Genymobile#3579)
 - Fix support for non-ASCII characters in window title (Genymobile#2932, Genymobile#3547)
 - Fix getDisplayIds() crash on some versions of Android 13 beta (Genymobile#3446)
 - Upgrade platform-tools to 33.0.3 (adb) in Windows releases
 - Upgrade FFmpeg to 5.1.2 in Windows 64-bit releases
 - Upgrade SDL to 2.26.1 in Windows releases
 - Various technical fixes
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