Skip to content

Instantly share code, notes, and snippets.

@yangyang5214
Created November 10, 2023 06:39
Show Gist options
  • Save yangyang5214/f92eb0364c654c99764778d5be711731 to your computer and use it in GitHub Desktop.
Save yangyang5214/f92eb0364c654c99764778d5be711731 to your computer and use it in GitHub Desktop.
support cp file:///Users/xxx/xxxx/xxx file

支持快捷复制 file:///Users/xxx/Pictures/Photos%20Library.photoslibrary/private/com.apple.Photos/ExternalEditSessions/28774CA9-3961-4284-B01E-10EBA01C43B6/IMG_9750.png

  • vim .zshrc
cpd() {
  if [ -z "$1" ] || [ -z "$2" ]; then
    echo "Usage: cpd <source_url> <destination>"
    return 1
  fi

  local source_url="$1"
  local destination="$2"
  local decoded_source
  decoded_source=$(python -c "import urllib.parse; print(urllib.parse.unquote('$source_url')[7:] if '$source_url'.startswith('''file://''') else '$source_url')")
  cp $decoded_source $destination

}
  • source .zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment