Created
February 8, 2026 12:07
-
-
Save DMantis/a2debc4105b196063aa63688a21784e4 to your computer and use it in GitHub Desktop.
Fish shell function for gopro hero 8 sync
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
| function goprosync | |
| set -l dest ~/Pictures/GOPRO | |
| mkdir -p $dest | |
| pushd $dest; or return 1 | |
| # Get GoPro's USB port (e.g., "usb:005,006") | |
| set -l port (gphoto2 --auto-detect | grep -i gopro | awk '{print $NF}') | |
| if test -z "$port" | |
| echo "β GoPro not detected" | |
| popd | |
| return 1 | |
| end | |
| # Convert "usb:005,006" β "/dev/bus/usb/005/006" | |
| set -l usbdev /dev/bus/usb/(echo $port | sed 's/usb://;s/,/\//') | |
| # Kill only the process holding this specific device | |
| set -l pid (lsof $usbdev 2>/dev/null | awk 'NR>1 {print $2}') | |
| if test -n "$pid" | |
| echo "π Releasing device (killing PID $pid)..." | |
| kill $pid | |
| sleep 1 | |
| end | |
| echo "π₯ Downloading from GoPro..." | |
| gphoto2 --get-all-files --skip-existing --filename "%Y%m%d_%H%M%S_%f.%C" | |
| if test $status -eq 0 | |
| echo "ποΈ Deleting files from camera..." | |
| gphoto2 --delete-all-files --recurse | |
| echo "π§Ή Removing THM/LRV thumbnail files..." | |
| find . -iname "*.THM" -delete | |
| find . -iname "*.LRV" -delete | |
| echo "β Done!" | |
| else | |
| echo "β Download failed or interrupted. Camera files kept." | |
| popd | |
| return 1 | |
| end | |
| popd | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment