Add function to list usb devices in english, remove replay

This commit is contained in:
David Todd 2021-02-19 10:06:56 -06:00
parent bbc3c5f0a6
commit b398bab13b

View File

@ -78,14 +78,16 @@ ff() { #find file
# Search for a file by its name and edit it # Search for a file by its name and edit it
# Usage: vf <filename> (optional) <max depth> # Usage: vf <filename> (optional) <max depth>
vf() { vim "$(ff "$@" | fzf)"; } vf() { vim "$(ff "$@" | fzf)"; }
# Usage: replay <number of commands> to repeat. Blank for 1 #https://unix.stackexchange.com/questions/144029/command-to-determine-ports-of-a-device-like-dev-ttyusb0
replay() { function list_usb() {
from="${1:-2}" for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do
to="${2:-1}" (
if [ "$from" -ne "$to" ]; then syspath="${sysdevpath%/dev}"
for i in `seq "$from" -1 "$(($to + 1))"`; do devname="$(udevadm info -q name -p $syspath)"
printf "$(fc -ln -${i} -${i}) && " [[ "$devname" == "bus/"* ]] && exit
done eval "$(udevadm info -q property --export -p $syspath)"
fi [[ -z "$ID_SERIAL" ]] && exit
$(fc -ln -${to} -${to}) echo "$ID_SERIAL" | tr '_' ' '
)
done
} }