# Encoding: UTF-8

[{beforeRunningCommand: "nop",
  command: 
   "export PATCH_GET=0\nexport __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100\n\nif [[ -z $TM_FILEPATH ]]\n  then exit_discard\n  else pbpaste | patch \"$TM_FILEPATH\" -p0\nfi\n\n# Reload patched file\nrescan_project\n",
  fallbackInput: "none",
  input: "selection",
  keyEquivalent: "^@D",
  name: "Apply Patch From Clipboard to Current Document",
  output: "showAsTooltip",
  uuid: "46842464-574C-477F-9DFB-BB38EA3C85BE"},
 {beforeRunningCommand: "nop",
  command: 
   "# patch may be the most brainfucked standard Unix tool ever. Make sure it doesn't try to access the network (it tends to ignore the -g option, I find) -- if you have Perforce installed, this can be a huge performance hit -- and it touches the network even for files that aren't controlled by Perforce. All files on the system get the lovely 'is this file locked'? treatment. Software tools, huh?\n\nexport PATCH_GET=0\n\npath=$(osascript<<END\ntell application \"TextMate\"\n\tset theFile to choose folder with prompt \"Where should I look for files to be patched?\"\n\tset the result to POSIX path of theFile\nend tell\nEND)\n\nif [[ -z $path ]]; then\n\texit_discard\nelse\n\tpatch -d \"$path\" -p0\nfi\n",
  input: "document",
  keyEquivalent: "^@D",
  name: "Apply Patch to Files…",
  output: "showAsTooltip",
  uuid: "54D1CEF2-10AB-407B-AAB2-6AEA06B297B1"},
 {beforeRunningCommand: "nop",
  command: 
   "# set defaultCStringEncoding to UTF-8\nif diff --strip-trailing-cr --label \"${TM_FILENAME:-untitled}\" --label \"(clipboard)\" -u - <(__CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100 pbpaste); then\n  echo \"There are no differences.\"\nelse\n  exit_create_new_document\nfi\n",
  input: "selection",
  keyEquivalent: "^@D",
  name: "Document / Selection With Clipboard",
  output: "showAsTooltip",
  uuid: "674E54F5-065E-4224-9626-673903B7C0E0"},
 {beforeRunningCommand: "nop",
  command: 
   "file=$(osascript <<\"APPLESCRIPT\"\ntell app \"TextMate\"\n  try\n    set theFile to choose file\n    set the result to POSIX path of theFile\n  on error\n    set the result to \"\"\n  end try\nend tell\nAPPLESCRIPT)\n\nif [[ \"$file\" == \"\" ]]; then exit_discard; fi\n\nif diff --strip-trailing-cr --label \"$file\" --label \"${TM_FILENAME:-untitled}\" -u \"$file\" -; then\n  exit_show_tool_tip \"There are no differences.\"\nfi\n",
  input: "document",
  keyEquivalent: "^@D",
  name: "Document With Arbitrary File…",
  output: "openAsNewDocument",
  uuid: "4050A252-C604-4D0C-8545-E50B22E2715B"},
 {beforeRunningCommand: "nop",
  command: 
   "if [[ ! -e \"$TM_FILEPATH\" ]]; then\n  exit_show_tool_tip \"There is no file on disk\"\nfi\n\nif diff --strip-trailing-cr --label \"$TM_FILENAME (saved version)\" --label \"(current document)\" -u <(cat \"$TM_FILEPATH\" | tr -d '\\r') -; then\n  exit_show_tool_tip \"There are no differences.\"\nfi\n",
  input: "document",
  keyEquivalent: "^@D",
  name: "Document With Saved Copy",
  output: "openAsNewDocument",
  uuid: "0979659D-126E-467F-AC07-599979A42D67"},
 {beforeRunningCommand: "nop",
  command: 
   "require_cmd opendiff \"Opendiff comes with Apple's developer tools.\"\n\n# set utf-8 as the default encoding (used by opendiff)\nexport __CF_USER_TEXT_ENCODING=$UID:0x8000100:0x8000100\n\neval arr=(\"$TM_SELECTED_FILES\")\nif [[ ${#arr[@]} == 2 ]];\n   then opendiff \"${arr[0]}\" \"${arr[1]}\"; rescan_project\n   else echo -e \"You need to select exactly two\\nfiles in the project drawer.\"\nfi\n",
  input: "none",
  keyEquivalent: "^@D",
  name: "Merge Selected Files…",
  output: "showAsTooltip",
  uuid: "239E196A-7106-4DC9-8FAE-0A9CA7540AFA"},
 {beforeRunningCommand: "nop",
  command: 
   "eval arr=(\"$TM_SELECTED_FILES\")\nif [[ ${#arr[@]} != 2 ]]; then\n   exit_show_tool_tip $'You need to select exactly two\\nfiles in the project drawer.'\nfi\n\nif eval diff -u \"$TM_SELECTED_FILES\"; then\n  exit_show_tool_tip \"There are no differences.\"\nfi\n",
  input: "none",
  keyEquivalent: "^@D",
  name: "Selected Files in Project Drawer",
  output: "openAsNewDocument",
  uuid: "D04AFBD3-8110-11D9-8E5B-0011242E4184"},
 {beforeRunningCommand: "nop",
  command: 
   "eval arr=(\"$TM_SELECTED_FILES\")\nif [[ ${#arr[@]} != 2 ]]; then\n   echo -e \"You need to select exactly two files in the project drawer.\"\n   exit_show_tool_tip\nfi\n\nperl \"$TM_BUNDLE_SUPPORT/Diff.pl\"\n",
  input: "none",
  keyEquivalent: "^@D",
  name: "Selected Files in Project Drawer (HTML)",
  output: "showAsHTML",
  uuid: "6A811265-81DC-11D9-9AA2-000D9332809C"},
 {beforeRunningCommand: "nop",
  command: 
   "egrep -v '^(\\+\\+\\+|---) '|\\\n  tee >(add=$(grep ^+|wc -l);  echo 1>&2 \"Lines Added   $add\") \\\n     |{ rem=$(grep ^-|wc -l); wait; echo \"Lines Removed $rem\"; }\n",
  input: "document",
  keyEquivalent: "^N",
  name: "Statistics (Lines Added/Removed)",
  output: "showAsTooltip",
  scope: "source.diff",
  uuid: "B9091553-4317-415E-B381-4609BD453E01"}]
