Sublime build - dynamic file name - sublimetext2

I need to make a build file for BibTeX files.
I have the following:
{
"cmd": ["bibtex", "*.aux"],
"selector": "text.bibtex"
}
When I run bibtex *.aux from terminal, it works fine. However, sublime keeps telling me:
I couldn't open file name `*.aux'
[Finished in 0.1s with exit code 1]

The answer is: make a custom script!
eg: subl /home/user/buildBibtex.sh consisting of:
#!/bin/sh
bibtex *.aux
run chmod +x /home/user/buildBibtex.sh
and the build file will look like this:
{
"cmd": ["/home/user/buildBibtex.sh"],
"selector": "text.bibtex"
}

Related

Why does start file in gitbash open the command prompt and not the file?

When i am in my project folder and use the command start index.html it works perfectly and opens up the file in my browser, however, when I use start new\ index.html it opens up the command prompt. Why?
Check first if adding quotes would help, in a git bash session:
start "new\ index.html"
Since it is not working, I tested successfully, after reading "mingw make can't handle spaces in path?", and using cygpath:
start $(cygpath -w -s "new index.html")
With:
cygpath -w -s "new index.html"
NEWIND~1.HTM

Why is this Sublime Text Grunt Build failing in Windows 7?

Why is this Sublime Text Grunt Build failing in Windows 7?
{
"cmd": ["grunt.cmd", "--no-color"],
"path": "C:\\Users\\USER\\AppData\\Roaming\\npm;C:\\Program/ Files\\nodejs",
"working_dir": "${project_path}"
}
Console says:
'node' is not recognized as an internal or external command, operable program or batch file.
[Finished in 0.1s with exit code 1]
Try the following first:
{
"cmd": ["grunt.cmd", "--no-color"],
"path": "C:/Users/USER/AppData/Roaming/npm;C:/Program\ Files/nodejs",
"working_dir": "${project_path}"
}
If that doesn't work, try removing the \ character between Program and Files. You don't need the "selector" argument at all, as that is used to specify the scope for the build system. ["Gruntfile.js"] is not a valid scope.
As an alternative option, check out the Grunt plugin available via Package Control. I haven't used it myself, but it looks quite useful. It parses your Gruntfile.(js|coffee) file and adds the available tasks to the Command Palette, among other things. It directly reads your PATH variable, so as long as your node and npm directories are there, it should work quite well.

Sublime 3 HTML Build Linux

I'm trying to do a custom build for Sublime 3 so that it opens chromium and the .html document that I'm working on. I'm able to launch Chromium with this:
"shell_cmd": "/usr/bin/chromium-browser"
How do I also open the file I'm working on?
You should use the $file build system variable to refer to the full path of the current file:
"shell_cmd": "/usr/bin/chromium-browser $file"
On linux:
{
"cmd": ["google-chrome", "$file"]
}
Save your file as ViewInChrome.sublime-build (path is selected as ~/.config/sublime-text-3/Packages/User by default, if not select this path)

Sublime Text Build in an external window

Is there a way to create a build command in Sublime Text that opens a new external window (terminal/cmd.exe)? Everything I try gets captured to the built-in output window.
I tried:
{
"cmd": ["ruby", "$file"],
"target": "cmd.exe",
"file_regex": "rb$",
"selector": "source.rb"
}
But nothing happened
The following works for Windows (I've tested it on XP and 7):
{
"cmd": ["start", "cmd", "/k", "c:/ruby193/ruby.exe", "$file"],
"selector": "source.ruby",
"shell": true,
"working_dir": "$file_dir"
}
Save it as Packages/User/Ruby_cmd.sublime-build (you may need to alter the path to the Ruby executable depending on your system), select Tools -> Build System -> Ruby_cmd, and build with CtrlB.
start does what it says it does, start a new process independent of Sublime Text. cmd is cmd.exe, the Windows command-line interpreter. The /k flag keeps the window open (at a new command prompt) after your program has run, allowing you to examine its output, look at tracebacks, run additional commands, etc.
May be you will find this solution helpful:
https://github.com/rctay/sublime-text-2-buildview
(transfers build output in the separate sublime tab, you can then do with it whatever you want)

Building Gnuplot from Sublime2 OSX

I am struggling to execute gnuplot scripts from Sublime2.
Gnuplot is installed and I can execute it from Terminal (OSX).
My build configuration in Sublime 2 looks like this:
{
"cmd": ["gnuplot"]
}
when Building it get the following result:
[Errno 2] No such file or directory
[cmd: [u'gnuplot']]
[dir: /Users/macuser/Documents/Gnuplot]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
[Finished]
How to I set up the build instructions in sublime so the script will be send to gnuplot with the current path as a working directory?
Thanks
I'm using Sublime Text 3 on OS X 10.9, and I solve the problem with the following procedure:
Open terminal and navigate to the Installed Packages on Sublime Text:
$ cd ~/Library/Application Support/Sublime Text 3/Installed Packages
Copy the file Gnuplot.sublime-package and paste in Desktop.
$ cp Gnuplot.sublime-package ~/Desktop
Rename the file to Gnuplot.zip and extract the content to a folder, ex. Gnuplot.
$ cd ~/Desktop
$ mv Gnuplot.sublime-package Gnuplot.zip
$ unzip Gnuplot.zip -d Gnuplot
Navigate to the folder, Gnuplot, open the file gnuplot.sublime-build with any text editor, like vim or, even, sublime text. Don't close the terminal window.
$ subl gnuplot.sublime-build
Onterminal type:
$ which gnuplot
Copy the path and with the file gnuplot.sublime-build opened previously in step 4, append the following line path like this:
{
"cmd": ["gnuplot", "$file"],
"path": "$PATH:/usr/texbin:/usr/local/bin:/opt/local/bin:",
"working_dir": "${project_path:${folder}}",
"selector": "source.gnuplot"
}
Save the file, and open terminal again. Type the following commands:
$ cd ~/Desktop/Gnuplot/
$ zip Gnuplot.sublime-package *
$ mv Gnuplot.sublime-package ~/Library/Application Support/Sublime Text 3/Installed Packages\
Restart sublime text 3, and it will work fine. Sorry with my bad english. LOL
In your case, a minimum build system should look something like this:
{
"cmd": ["/full/path/to/gnuplot"],
"working_dir": "${project_path:${folder}}"
}
You can also set "working_dir" to any specific directory. Check this page out for further info on constructing a build file:
Build system reference