Sublime text: Do not print path of build command

19

8

I have the following build script for my JavaScript files in Sublime Text 3.

{
  "shell_cmd": "node --harmony --use-strict --harmony_generators $file"
}

The problem is that when node returns an error, for some reason Sublime will spew out the path, which does not line-wrap, and pollutes the output.

C:\Users\JFD\Desktop\playground.js:2
console.log(b); // ReferenceError: a is not defined
        ^
ReferenceError: b is not defined
    at Object.<anonymous> (C:\Users\JFD\Desktop\playground.js:2:13)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:349:32)
    at Function.Module._load (module.js:305:12)
    at Function.Module.runMain (module.js:490:10)
    at startup (node.js:119:16)
    at node.js:827:3
[Finished in 0.1s with exit code 8]
[shell_cmd: node --harmony --use-strict --harmony_generators C:\Users\JFD\Desktop\playground.js]
[dir: C:\Users\JFD\Desktop]
[path: C:\Program Files (x86)\Microchip\xc8\v1.11\bin;C:\Program Files (x86)\CMake 2.8\bin;C:\MinGW\bin;C:\yagarto4.6.0\bin;C:\Python26\;C:\Python26\Scripts;C:\Program Files (x86)\Altium Designer S09 Viewer\System;C:\PROGRA~2\MpAM;C:\windows\system32;C:\Program Files\nodejs\;C:\Cadence\SPB_16.6\tools\bin;C:\Cadence\SPB_16.6\tools\libutil\bin;C:\Cadence\SPB_16.6\tools\fet\bin;C:\Cadence\SPB_16.6\tools\specctra\bin;C:\Cadence\SPB_16.6\tools\pcb\bin;C:\Cadence\SPB_16.6\openaccess\bin\win32\opt;C:\Cadence\SPB_16.6\tools\capture;C:\Users\JFD\AppData\Roaming\npm\;c:\altera\12.1\modelsim_ase\win32aloem;c:\altera\12.1sp1\modelsim_ase\win32aloem;c:\altera\12.1sp1\modelsim_ae\win32aloem]

How can I ask Sublime to not output the path?

Randomblue

Posted 2013-07-09T15:22:09.257

Reputation: 2 547

Instead of disabling the path output, you can disable word wrap in the build output window. Make sure the build window is active, then do View -> Word Wrap to disable it. Though not a perfect solution, it's much simpler than modifying Sublime Text's internals. – anishpatel – 2017-05-14T21:09:18.667

I think this is just part of the standard error/debugging output. I don't know of any way to disable it through options or build flags, though... – MattDMo – 2013-07-09T16:03:41.950

Answers

12

A bit of a hack, but the following worked for me. Turns out you can override code in some of the default packages, including the code responsible for the path output:

  1. Go to C:\Program Files\Sublime Text 3\Packages
  2. Extract Default.sublime-package (it's actually a zip file) and get the file exec.py (don't leave the extracted folder hanging around in the directory)
  3. Create the directory Default under C:\Users\USERNAME\AppData\Roaming\Sublime Text 3\Packages, and place exec.py into it
  4. Open exec.py, and comment out (place # at the beginning of the line) the following line, at line 245 for me

    self.append_string(proc, self.debug_text)

  5. Restart Sublime Text

William Saunders

Posted 2013-07-09T15:22:09.257

Reputation: 542

This did the job for me :) – Stephn_R – 2015-06-02T13:58:46.083

6

Install PackageResourceViewer package

Open PackageResourceViewer:Open Resource using CommandPalette[Ctrl+Shift+P]

Then Select Default -->exec.py Then Select Sublime Input -->input.py [For Sublime Input]

Comment out (place # at the beginning of the line) the following line, at line 365[ST3 B3126] (383 for Sublime Input) for me

self.append_string(proc, self.debug_text)

This is not only hiding the path but the dir and cmd also .

To hide only the path comment the following block

if "PATH" in merged_env:
  self.debug_text += "[path: " + str(merged_env["PATH"]) + "]"
else:
  self.debug_text += "[path: " + str(os.environ["PATH"]) + "]"

Update

To remove cmd,finished statement,dir,path "quiet":true in build file

Source

SmartManoj

Posted 2013-07-09T15:22:09.257

Reputation: 208

Nice! I wish there were a setting to toggle this. like "error_info": ["cmd", "dir", "path"] – Nolan Conaway – 2018-02-28T18:33:01.447

@NolanConaway There is – SmartManoj – 2018-03-01T16:37:07.323

can you point me to it? I have been unable to find anything in the documentation. – Nolan Conaway – 2018-03-01T17:02:45.773

@NolanConaway quiet key

– SmartManoj – 2018-03-02T13:16:58.800

@ SmartManoj Ah, yes, i know about that option. However, that also prevents the time elapsed, etc, from bring printed. I really only want to remove the path! – Nolan Conaway – 2018-03-02T14:55:17.187

Better way has been answered here: https://stackoverflow.com/questions/38869573/sublime-text-3-stop-printing-shell-cmd-dir-and-path-when-error-is-raised

– Kardi Teknomo – 2019-09-23T12:48:09.010

@KardiTeknomo see update & comments – SmartManoj – 2019-09-23T15:08:09.257