ä¿åããåã®diffï¼å·®åï¼ãã¨ã
ååã¾ã§ã«ã
-
-
- Dropboxã®ãã¼ã¸ã§ã³å±¥æ´ã¨ã®diffï¼dropbox_diff.shï¼
- AppleScriptããªããããã¹ãçã®ãã¤ããªãã¡ã¤ã«ã¨ã®diffï¼convert_diff.shï¼
-
ã¨ãdiffãå°ããã¤æ¡å¼µãã¦ããã
ä»åããã«ã
-
-
- ä¿åããåã®æ¸é¡ã¨ã®diffï¼document_diff.shï¼
-
ãã¨ã£ã¦ã¿ããã
é常ãdiffããã¨ãã¯ãã¡ã¤ã«ã«ä¿åããã¦ããã¢ãå士ã対象ã«ããã®ã ãã©ãã¡ãã£ã¨å·¥å¤«ããã¨ãã¯ãªãããã¼ãï¼command-Cã§ã³ãã¼ããå 容ï¼ã¨ã®diffãã¨ããã
$ pbpaste|diff file1.txt -
- pbpasteã¯ã¯ãªãããã¼ãã®å 容ãåºåããOSXç¬èªã®ã³ãã³ãã
- ããããã¤ãã§ç¹ãã§ãdiffã®ç¬¬2å¼æ°ã«æå®ãã¦ããã
- diffã³ãã³ãæ«å°¾ã® - ã¯ããã¤ãã§æµãã¦ããããã¹ããã¼ã¿ã¨ã¿ãªãããã
- file1ããã¯ãªãããã¼ãã¸ã®å¤åã®diffåºå
- ã¡ãªã¿ã«ã- ã第1å¼æ°ã®ä½ç½®ã«å¤æ´ããã¨ãå·®åã®è¨ç®ãéã«ãªãã
- ã¯ãªãããã¼ãããfile1ã¸ã®å¤åã®diffåºå
$ pbpaste|diff - file1.txt
ãã£ã¦ãGUIã¨ãã£ã¿ã§file1.txtç·¨éä¸ã«å
¨ä½ãã³ãã¼ãã¦ãã¿ã¼ããã«ã§ä¸è¨ã³ãã³ããå
¥åããã°ã
-
-
- ä¿ååã®ç·¨éä¸ã®ç¶æ ã¨ã
- ä¿åæ¸ã®ãã¡ã¤ã«å 容ã®ã
-
diffãã¨ããã®ã ï¼
GUIæä½ã追å ãã
- ãã¡ãã¡ãã¹ã¦ãé¸æãã¦ãã³ãã¼ããã®ã¯é¢åãããã
- AppleScriptãªãcommand-Aãcommand-Cã®æä½ãã§ããã
- ã¨ããã§ãOSXã«ã¯osascriptã³ãã³ããç¨æããã¦ããã
- osascriptã¯ãæå®ãããAppleScriptãå®è¡ããã³ãã³ãã
- ãªãã°ãosascriptãå©ç¨ãã¦ãAppleScriptã§ãã¾ãå ã¿è¾¼ãã§ãããã°ããã使ããããã³ãã³ãã«ä»ä¸ããã¯ãï¼
#!/bin/bash open "$1" sleep .5 osascript -e ' tell application "System Events" keystroke "a" using command down -- command-a keystroke "c" using command down -- command-c delay .5 end tell' pbpaste|diff -u "$1" - osascript -e ' tell application "System Events" keystroke tab using command down -- command-tab end tell'
convert_diff.shãå©ç¨ãã
- ããã«ãdiffã³ãã³ãã®é¨åãååä½ã£ãconvert_diff.shã«ç½®ãæããã°ããã¤ããªãã¡ã¤ã«ã«ã対å¿ã§ããã¯ãï¼
- ããããååä½ã£ãconvert_diff.shã¯ãã¡ãã£ã¨ãã£ã¤ãã³ã¼ãçãªã¨ããããã£ã¦ããã®ã¾ã¾ã§ã¯diffã³ãã³ãã®ç½®ãæãã«ã¯èããããªãã
- ã§ããã ãå¤ãã®ç¶æ³ã§diffã³ãã³ãã®ä»£ããã«ä½¿ããããã«æ¹è¯ãã¦ã¿ãã
#!/bin/bash convert() { case $1 in *.scpt ) echo -n "osadecompile" ;; *.rtf ) echo -n "textutil -convert txt -stdout" ;; *.jpg ) echo -n "exiftool" ;; * ) echo -n "cat";; esac } OPTION=("$@") PATH1=${OPTION[$(($# - 2))]} PATH2=${OPTION[$(($# - 1))]} unset OPTION[$(($# - 1))] unset OPTION[$(($# - 2))] # ä¸æ¹ããã£ã¬ã¯ããªã ã£ãããä»æ¹ã®ãã¡ã¤ã«åãè£ã if [ -d "$PATH1" ] && [ -f "$PATH2" ]; then PATH1="$PATH1/`basename "$PATH2"`" elif [ -f "$PATH1" ] && [ -d "$PATH2" ]; then PATH2="$PATH2/`basename "$PATH1"`" fi # 両æ¹ã¨ããã£ã¬ã¯ããªã ã£ãããå¤æããã«diffãå®è¡ãã if [ -d "$PATH1" ] && [ -d "$PATH2" ]; then echo "\`diff" "$@""|colordiff'" diff "$@"|(`which colordiff`||`which cat`) else echo "\`diff ${OPTION[@]} <(`convert "$PATH1"` \"$PATH1\") <(`convert "$PATH2"` \"$PATH2\")|colordiff'" diff "${OPTION[@]}" <(`convert "$PATH1"` "$PATH1") <(`convert "$PATH2"` "$PATH2")|(`which colordiff`||`which cat`) fi
- document_diff.shã«çµã¿è¾¼ãã§ã¿ãã
#!/bin/bash open "$1" sleep .5 osascript -e ' tell application "System Events" keystroke "a" using command down -- command-a keystroke "c" using command down -- command-c delay .5 end tell' pbpaste|~/convert_diff.sh -u "$1" - osascript -e ' tell application "System Events" keystroke tab using command down -- command-tab end tell'
Lion以éã§ã®åé¡
- 以ä¸ã®ã·ã§ã«ã¹ã¯ãªããã¯ãSnow Leopardç°å¢ã§ã¯ä½ã®åé¡ããªãããã¾ãåããã
- Lion以éã§ãã£ã¦ãããªã¼ãã»ã¼ãã¨ãã¼ã¸ã§ã³ã«å¯¾å¿ãã¦ããªãã¢ããªã±ã¼ã·ã§ã³ã§ã¯åé¡ãªãåãã
- ããããLIon以éã®ãªã¼ãã»ã¼ãã¨ãã¼ã¸ã§ã³ã«å¯¾å¿ãã¦ããAppleScriptã¨ãã£ã¿ãããã¹ãã¨ãã£ããã§ã¯ã
ç·¨ééä¸ã®å·®åããã¾ã表示ãããªã...ã
- ãªã¼ãã»ã¼ãã¨ãã¼ã¸ã§ã³ã«å¯¾å¿ã®ç°å¢ã§ã¯ãç·¨éã¦ã£ã³ãã¦ã¸ã®å ¥åã¨åæã«ãä¿åãã¡ã¤ã«ã«ãå¤æ´ãå ãããã¦ãã¾ãããä»æ§ã®ããã ã
- ãã®çµæãããã¹ããã¡ã¤ã«ã¯ç·¨éããç¬éã«ãã¡ã¤ã«ã«ä¿åããã¦ãã¾ãã
- ãã¨ããã·ã¹ãã ç°å¢è¨å® >> ä¸è¬ >>ãæ¸é¡ãéããã¨ãã«å¤æ´å 容ãä¿æãããã©ããã確èªãããã§ãã¯å ¥ãã«ããç¶æ ã§ããç·¨éããç¬éã«ãã¡ã¤ã«ã«ä¿åããã¦ããã®ã ã
- ã¾ããAppleScriptããªããããã¹ãããç·¨éä¸ã¯ãã¡ã¤ã«ã«ä½ããã®å¤æ´ãå ããããã
- ãã®ãããosascriptã³ãã³ããtextutilã³ãã³ãã§å¤æãããã¨ãã¦ããã¨ã©ã¼ãçºçãã¦ããã¹ãã«å¤æã§ããªããªã£ã¦ãã¾ã£ã...ã
Mountain Lionç°å¢ã®AppleScriptã¨ãã£ã¿ã§diff-docã使ããªãã®ã¯ãã¡ãã£ã¨æ®å¿µã
ã¨ã¤ãªã¢ã¹è¨å®
- ã·ã§ã«ã¹ã¯ãªãããç ®è©°ã¾ã£ã¦ããã¨ã常ç¨ããããªãã
- ãã®éãdocument_diff.shã¨ãå ¥åãã¦ããã¨ç²ããã
- ã¨ã¤ãªã¢ã¹è¨å®ãã¦ãããã¨ã«ããã
$ alias diff-document ~/documen_diff.sh $ alias diff-convert ~/convert_diff.sh $ alias diff-dropbox ~/dropbox_diff.sh
- diffã³ãã³ãã®ãªãã·ã§ã³ã³çãªæå³åããè¾¼ãã¦ã-ã§æ¥ç¶ãã¦ã¿ãã®ã ãã©ãããã«çç¥ãã¦ãè¯ããããããªãã
$ alias diff-doc ~/documen_diff.sh $ alias diff-conv ~/convert_diff.sh $ alias diff-drop ~/dropbox_diff.sh