So, I made this shell script that can be called from TexStudio, The scripts calls git to add and commit files with the current date, and then push them to GitHub. I want to improve it's functionality so that I can add a comment and choose which branch I want to commit to. (I based my scripts on this and this comment.)

So far I have made the current macro:

dialog = new UniversalInputDialog()
    dialog.setWindowTitle("Git commit and push")
    dialog.add("add comment", "Comment", "comment")
    dialog.add("master", "Branch", "branch")
if (dialog.exec() != null) {
    comment = dialog.get("comment")
    branch = dialog.get("branch")
    workDir = "/home/user/directory/path/"
    system("sh gitcommitpush.sh " + workDir + "\"" + comment+ " \"" + branch + "\"", workingDirectory="/home/user/directory/path/")

and a shell script, gitcommitpush.sh, I added to /usr/local/bin:



#First, I set the path to master directory
cd "$3" 

# Then I add all files in the local repository and stages them for commit:
git add .

# Then I want to check if a comment has been added. If only the generic comment "add comment" is unchanged, I want the script to simply commit with the current date as comment. Otherwise, I commits the changes with current date and the comment passed on from the TexStudio macro.

if [ $comment == "add comment" ]
git commit -a -m `date "+%d._%B_%Y_%H:%M:%S_%Z"`
git commit -a -m `date "+%d._%B_%Y_%H:%M:%S_%Z_$comment"`

# Last I want to push the changes in your local repository up to the specified branch in the remote repository:

git push origin $branch

When I try to execute the macro, TexStudio returns the following error message:

The specified stdout redirection is not supported: "> "add comment "master"". Please see the manual for details.

Process started: sh gitcommitpush.sh <path to file

/usr/bin/sh: 0: Can't open gitcommitpush.sh

Process exited with error(s)

I am unsure why it doesn't work, and could use some help getting the syntax right. Any kind soul here that can help me?

Also, I want to make the macro/script work for all files and directories, so I am trying to find a way to get the macro script to retrieve the path to the main directory, and pass it on to the shell script. Anyone?

  • 1
    I don't think that this is on-topic here. Feb 18, 2020 at 14:08
  • It's related to TexStudio. That is a relevant topic isn't it? My apologies if not. However, I would point out that this and this post, with topics related to mine and which I based my work on is posted here. Feb 18, 2020 at 14:26
  • Why the comma in + "\"",? I think the argument of system should be a single string.
    – Sigur
    Feb 18, 2020 at 14:31
  • 1
    How to add such a script to a texstudio menu is perhaps a bit relevant (but I have doubts), how to write the script itself not - you are asking about a bash script which should handle git. There is nothing tex related here. Feb 18, 2020 at 14:32
  • 1
    Also, dont use <> in workDir.
    – Sigur
    Feb 18, 2020 at 14:44


You must log in to answer this question.

Browse other questions tagged .