[url=http://xiazai.jb51.net/201306/other/IOS_windows_fj_jb51.rar]/201306/other/IOS_windows_fj_jb51.rar[/url]
内容(注意shell/bat文件中部分空格回车是敏感的,有问题请直接下载一份)
mac下批量混合格式diff转成unix格式diff diff2unix
#diff2unix
#Ruoqian, Chen<piao.polar@gmail.com>
#2013.2.7
#----------
#trans diff patch with windows LE (CRLF) to Unix LE(LF)
#-----------
#usage
#diff2unix trans curent dir
#diff2unix path trans dir or file
#when trans dir, will trans all files and child dir in it.
#----------
if [ $# == 0 ]
then
path=`pwd`
else
path=$1
fi
if [ -f $path ]
then
file=${path##*/}
ext=${file##*.}
if [[ "$file" != mac* ]] && [ $ext = "diff" ]
then
new_file="mac_"$file
echo $path "->" $new_file
awk '/^\+\+\+|^---|^@@|^diff|^Binary|^File/ { sub(/\r$/,"") }; {print}' < $path > $new_file
fi
else
for file in `ls $path`
do
diff2unix $path"/"$file
done
fi
windows下批量混合格式diff转成windows/dos格式diff diff2win.bat
::diff2win
::Ruoqian,Chen<piao.polar@gmail.com>
::----------
::Trans file with unix LE(LF) or mix LE(LF/CRLF) to window LE(CRLF)
::----------
::2013.2.16
::usage
::diff2win trans curent dir
::diff2win path trans dir or file
::----------
@echo off
setlocal enabledelayedexpansion
set WorkPath=%cd%
if [%1] neq [] set WorkPath=%1&& (dir /ad %1 >nul 2>nul ) && goto TRANS_DIR || goto TRANS_FILE
:TRANS_DIR
for /f "delims=" %%i in ('dir !WorkPath! /a-d /b ^| findstr .diff$ ^| findstr -v ^win_') do (
echo !WorkPath!/%%i -^> win_%%i
gawk -v BINMODE="rw" "/^\+\+\+|^---|^@@|^diff|^Binary|^File/ { sub(/$/,\"\r\") }; {print}" < !WorkPath!/%%i > win_%%i
)
goto :eof
:TRANS_FILE
for /f "delims=" %%i in ('dir %WorkPath% /b') do (
echo %WorkPath% -^> win_%%i
gawk -v BINMODE="rw" "/^\+\+\+|^---|^@@|^diff|^Binary|^File/ { sub(/$/,\"\r\") }; {print}" < %WorkPath% > win_%%i
)
::gawk -v BINMODE="rw" "/^\+\+\+|^---|^@@|^diff|^Binary|^File/ { sub(/$/,\"\r\") }; {print}" < in > out
::----------
::2013.2.8
::usage
::diff2win < file_in > file_out
::e.g.
::diff2win < unix.diff > win.diff
::----------
::@echo off
::gawk 1
::http://www.gnu.org/software/gawk/manual/html_node/PC-Using.html
::Under MS-Windows, OS/2 and MS-DOS, gawk (and many other text programs) silently translate end-of-line "\r\n" to "\n" on input and "\n" to "\r\n" on output.
windonws下直接打各种格式diff winpatch.bat
::winpatch
::Ruoqian, Chen<piao.polar@gmail.com>
::2013.2.16
::
::call gnu patch to patch a diff file with windows LE (CRLF) or Unix LE(LF) or mix LE
::----------
::usage
::the same to patch use patch --help to read it
::e.g. winpatch -p1 < ../mac.diff
::or winpatch -p1 -R < ../mac.diff
::----------
@echo off
gawk -v BINMODE="rw" "/^\+\+\+|^---|^@@|^diff|^Binary|^File/ { sub(/$/,\"\r\") }; {print}" > dosCRLF.diff
patch %1 %2 %3 %4 %5 %6 %7 %8 %9 < dosCRLF.diff
2013.3.4.更新
1. 关于Versions
commit的时候尤其要注意不要遗漏了文件的增删。点击Changed,会看到目录下的修改,其中新增文件显示为圆问号,删除文件显示为虚方问号,右键点击Add或Delete,使之图标变化为正确的增删图标即可。
2. 关于Sublimt Text2
a) 解决中文乱码的插件
资源和说明见:https://github.com/seanliang/ConvertToUTF8/blob/master/README.zh_CN.md
b) 修改快捷键为windows样式
Preferences->Key Bindings - User 将windows版本的拷过来
或直接可以从这里自取 https://gist.github.com/piaopolar/5081327
c) 修改将文件拖放到窗口内不打开新窗口
Preferences->Setting - Default
"open_files_in_new_window" : false
d) 自动换行
Preferences->Setting - Default
"word_wrap" : "true"
3. iospatch 和 winpatch 的中间文件目录放在当前路径不大好,往往会导致反到工作目录中去了。
在文件名前面加\(windows)或/(Unix),放到根目录即可,或直接往系统临时文件目录或自己预期的目录即可规避此问题。