Created
July 11, 2018 01:13
-
-
Save vilhalmer/2b96ad656623603ebb86dbccd1a85b5a to your computer and use it in GitHub Desktop.
bt: Wrapper for `bluetoothctl` that allows shortest-prefix for device name and command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
device=$(bluetoothctl paired-devices | grep -iE "$1" | cut -d' ' -f2) | |
if [[ -n $2 ]]; then | |
command=$(bluetoothctl help | cut -d' ' -f1 | grep -iE "$2" | head -n1 | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g') | |
else | |
command="connect" | |
fi | |
echo "Command: bluetoothctl $command $device" | |
bluetoothctl "$command" "$device" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming device named "Device":
bt dev
connectsbt dev discon
disconnects