Starting Beyond Compare from the Command Line
I have Beyond Compare 3 installed at;
"C:\Program Files\Beyond Compare 3\BCompare.exe"
and Cygwin;
"C:\Cygwin\bin\bash.exe"
What I would like is to be able to use a command such as;
diff <file1> <file2>
into the Cygwin shell and to have the s开发者_C百科hell fork a process opening the two files in beyond compare.
I looked at the Beyond Compare Support Page but I'm afraid It was too brief for me. I tried copying the text verbatim (apart from path to executable) to no avail;
Instead of using a batch file, create a file named "bc.sh" with the following line:
"$(cygpath 'C:\Progra~1\Beyond~1\bcomp.exe')" `cygpath -w "$6"` `cygpath -w "$7"` /title1="$3" /title2="$5" /readonly
Was I supposed to replace cygpath? I get a 'Command not found' error when I enter the name of the script on the command line.
gavina@whwgavina1 /cygdrive
$ "C:\Documents and Settings\gavina\Desktop\bc.sh"
bash: C:\Documents and Settings\gavina\Desktop\bc.sh: command not found
Does anyone have Beyond Compare working as I have described? Is this even possible in a Windows environment?
Thanks in advance!
Inside of Cygwin the filesystem is more like unix. The cygpath component is there because the root of the drive appears in a different place in the path. "C:\" doesn't mean anything to Cygwin, it considers '/' to be the root and your drives have to start from there, hence the cygpath expansion. Also, try using the 8.3 form like from the referenced page:
"$(cygpath 'C:\Progra~1\Beyond~1\bcomp.exe')"
Add this function to your ~/.bashrc
file.
bc() {
"/cygdrive/c/Program Files/Beyond Compare 3/BCompare.exe" $1 $2 -fv "Text Compare"
}
Then you can just write bc file1.txt file2.txt
on the command line and get a nice text comparison using Beyond Compare.
@Romain Hippeau Thanks, I was being a bit of a moron.
To run a shell script in Cygwin you have to make it executable.
chmod 755 bc.sh
Then to run the script use;
./bc.sh
Where the script is in the current directory.
精彩评论