Starting Beyond Compare from the Command Line

让人想犯罪 __ 提交于 2020-01-05 02:15:13

问题


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 shell 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!


回答1:


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')"




回答2:


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.




回答3:


@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.



来源:https://stackoverflow.com/questions/2781561/starting-beyond-compare-from-the-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!