Skip to content

Instantly share code, notes, and snippets.

@DMantis
Created February 8, 2026 12:07
Show Gist options
  • Select an option

  • Save DMantis/a2debc4105b196063aa63688a21784e4 to your computer and use it in GitHub Desktop.

Select an option

Save DMantis/a2debc4105b196063aa63688a21784e4 to your computer and use it in GitHub Desktop.
Fish shell function for gopro hero 8 sync
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