From b398bab13bf1a651bd6b5e8ee3f9ecbf9b618376 Mon Sep 17 00:00:00 2001 From: David Todd Date: Fri, 19 Feb 2021 10:06:56 -0600 Subject: [PATCH] Add function to list usb devices in english, remove replay --- home/.functions | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/home/.functions b/home/.functions index 5b3bd6e..5538e32 100644 --- a/home/.functions +++ b/home/.functions @@ -78,14 +78,16 @@ ff() { #find file # Search for a file by its name and edit it # Usage: vf (optional) vf() { vim "$(ff "$@" | fzf)"; } -# Usage: replay to repeat. Blank for 1 -replay() { - from="${1:-2}" - to="${2:-1}" - if [ "$from" -ne "$to" ]; then - for i in `seq "$from" -1 "$(($to + 1))"`; do - printf "$(fc -ln -${i} -${i}) && " - done - fi - $(fc -ln -${to} -${to}) +#https://unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0 +function list_usb() { + for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do + ( + syspath="${sysdevpath%/dev}" + devname="$(udevadm info -q name -p $syspath)" + [[ "$devname" == "bus/"* ]] && exit + eval "$(udevadm info -q property --export -p $syspath)" + [[ -z "$ID_SERIAL" ]] && exit + echo "$ID_SERIAL" | tr '_' ' ' + ) + done }