0

I am using Git with Mingw64 under Windows 10, but I am new to Git/Linux/bash.

I would like to define a texniccenter command in the Mingw64 interpreter so that if I type

texniccenter my_file.tex

my_file.tex will open in the running instance of TexnicCenter if there is one, or in a new one if no instance is running. Based on an answer to Command to open file with git, I have created a file called texniccenter with the following content

#!/bin/sh
"C:\Program Files\TeXnicCenter\TeXnicCenter.exe" "$1" &

and I have saved it to "C:\Program Files\Git\usr\bin". This works fine, but starts a new instance of TexnicCenter every time. I have read that I have to use command-line option /ddecmd to prevent TexnicCenter from starting a new instance, but I am not sure where to put it in the above command. I have tried many combinations of quotes and slashes/backslashes to escape the slash in /ddecmd, but nothing has worked so far.

In case this matters, I am asking this question because I would like to configure Git to use TexnicCenter to show the content of a file from a specified commit. Based on an answer to https://superuser.com/questions/772269/how-can-i-pipe-console-output-directly-to-notepad, I would like to type

git show a_branch_name:my_file.tex | clip && texniccenter

but I have to define texniccenter first.

vin0646
  • 33
  • 3
  • You should put an option after "TeXnicCenter.exe": `"C:\Program Files\TeXnicCenter\TeXnicCenter.exe" /ddecmd "$1"`. – paq Dec 11 '20 at 11:33
  • Not sure if MinGW supports all redirection features, but you cat also try out a unix-way shell variant: `texniccenter.exe /ddecmd <( git show some_branch:some_file )`. It creates a temporary file with contents taken from git show command and passes path to this file to the texniccenter.exe command as the second argument. – paq Dec 11 '20 at 11:38
  • Thanks, but `"C:\Program Files\TeXnicCenter\TeXnicCenter.exe" /ddecmd "$1"` does not work because TeXnicCenter interprets /ddecmd as a sub-folder name and says `"C:\Program Files\Git\ddecmd" not found`. It looks like it gets confused with the `/` in the option. – vin0646 Dec 11 '20 at 12:13
  • I see, options `/ddecmd` expects an argument: http://texniccenter.sourceforge.net/commandline.html. Also, make sure your TeXnicCenter version supports a ddecmd option. – paq Dec 11 '20 at 12:17
  • It does support the `/ddecmd` option because if I type `"C:\Program Files\TeXnicCenter\TeXnicCenter.exe" /ddecmd "[goto('absolute_path_to_my_file.tex', '1')]"` (with the absolute path in the command -- not sure why a relative path does not work here) in Windows cmd, it opens myfile.tex in the running instance of TC. Not sure how to pass the `/ddecmd` option in a Linux-style bash file... – vin0646 Dec 14 '20 at 10:04
  • If you have succeeded in running command with absolute path, you have no problems anymore: `path="$( readlink -f "$1" )"` `"C:\Program Files\TeXnicCenter\TeXnicCenter.exe" /ddecmd "[goto('$path', '1')]"` – paq Dec 14 '20 at 10:44
  • `/` is not treated in any specific way in GNU/Linux, and your bash-file will just run a windows executable with windows-style options, it's OK, – paq Dec 14 '20 at 10:47

0 Answers0