Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am creating a script to produce some .tex files with a lot of lines (a kind of automatic sample).

The script finishes with texstudio /home/$USER/foo.tex where foo.tex is the file created before.

My question is: is it possible to open the file with texstudio with the cursor at line N, that is, I would like to run the script to open the file and start typing right now, exactly at the right line.

Thanks for a while. Below is the script.


file=/home/$USER/fastex-temp.tex
exec 3>&1 # save file descriptor to stdout
exec > "$file" # redirect output to file
printf '\\documentclass[11pt,a4paper]{amsart}\n'
printf '\\usepackage{amsfonts,amsthm,amsmath}\n'
printf '\\usepackage[latin1]{inputenc}\n'
printf '\\usepackage[T1]{fontenc}\n'
printf ' ' >&3 # output to normal stdout instead of file
printf '\\begin{document}\n'
printf ' ' >&3
printf '\\end{document}\n'
exec >&3  # restore stdout
exec 3>&- # close / discard temporary fd

texstudio "$file"
share|improve this question
    
The usual convention for editors is $EDITOR +42 foo.tex to open foo.tex at line 42. I don't know if TeXstudio follows it. –  Gilles Sep 4 '12 at 22:18
    
@Gilles, thanks for your help. I will update my script. I confess that I don't know some commands, but it looks like much more organized than mine. Just one question: printf ' ' >&3 will produce an empty line? This is what I wish. –  Sigur Sep 4 '12 at 22:44
    
I don't understand your comment. Did you reply to the wrong post? printf ' ' prints a space. Your script would be more readable with a here document (search on this site for examples). –  Gilles Sep 4 '12 at 23:01
    
@Gilles, I wrote based on your comment # output to normal stdout instead of file. So, this line will print an empty space on a single line of the file or not? –  Sigur Sep 4 '12 at 23:06
    
That wasn't me, that was @jw013. jw013: you shouldn't edit code in questions like this. Your answer would have been a good place to put an improved script. –  Gilles Sep 4 '12 at 23:15

1 Answer 1

up vote 4 down vote accepted

Have you tried

texstudio --line "$lineno" "$file"

?

This is documented in the TeXstudio manual.

share|improve this answer
    
Thanks so much. It works! I didn't know about this nice manual. Thanks! –  Sigur Sep 4 '12 at 14:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.