Sublime 3 HTML Build Linux - html

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)

Related

How to open a project in PhpStorm from command line on Windows

How to open a project in PhpStorm from command line on Windows?
I tired this:
How to open a directory in PHPStorm or IntelliJ (or any JetBrains IDE) from the command line? but can't find Tools -> Create command line launcher on Windows.
I am using latest PhpStorm.
To open the current directory just run:
phpstorm64 .
If you are using git bash on Windows run:
cmd "/C phpstorm64 ."
Make sure that C:\Program Files\JetBrains\PhpStorm 2018.3.3\bin is in your environment variable PATH (it is by default after the installation)
Edit 2021:
Install Jetbrains Toolbox
Go to settings
Enable "Shell Scripts" and follow the instructions
Now you can use "phpstorm ." to open the current directory.
On macOS ( I assume on windows too) there is option to "Create Command-line Launcher". Just click that and you are good to go next time you open a terminal.
You can even specify how you would like to start "pstorm" / "phpstorm" / "ps" etc.. up to you.
Command-line launcher is currently only available fo UNIX; there is a feature request for providing it on Windows, IDEA-114307, please feel free to vote for it.
If you like to start PhpStorm from command prompt, open cmd console, cd to %PS_install_dir%/bin and run either phpstorm64.exe or phpstorm.bat, passing a path to project folder to it, like it's described in https://www.jetbrains.com/help/phpstorm/opening-files-from-command-line.html. If you like to start it from any directory, add %PS_install_dir%/bin to your system %PATH%
I know this is too late, but it will help others if they need it:
if you want to open phpStorm in the current directory via cmd/Powershell, just use this command:
phpstorm64.exe .
Or if you want to open it in another directory, just use:
phpstorm64.exe YOUR_DIRECTORY_PATH
as simple as that!
go to your project using terminal
Cd myproject
and write
phpstorm64.exe
then hit enter
I see this is a little old but I wanted to supply my answer as I was grappling with this yesterday. My solution was to use cygwin.
Track down the phpstorm bin folder called something like C:\Users\UserName\AppData\Local\JetBrains\Toolbox\apps\PhpStorm\ch-0\201.7223.96\bin and add it to your windows system Path environment variable.
Next fire up a cygwin terminal and navigate into your project directory. I'm not a bash expert so I struggled to sort out the code as an alias but if you run:
crntproj=$(cygpath -w $PWD)
phpstorm.bat $crntproj
You need cygpath because simply running phpstorm.bat $PWD doesn't work as PHPStorm tries to open a folder called $PWD. I tried a bunch of variations trying to get it to open and none seemed to work.
It will fire up phpstorm with the current folder as the project path. And you now have a terminal feed from your project too.

SublimeREPL + Octave

I am using Octave for some Machine Learning work and I have noticed in my package library in Sublime that there is SublimeREPL: Octave as an option.
However when I select it, I get the following error message:
FileNotFoundError(2, "No such file or directory: octave")
Is there a way to use sublime to code with Octave?
Many thanks
First, you need to find out where your octave executable lives, and note the full path to it. On Linux or OS X, open your favorite terminal emulator and type which octave, and if it's in your $PATH variable it will print the full path to it (for example, /opt/local/bin/octave or something like that). If it's not in your path, or if you're on Windows, you'll have to search around a bit until you find octave or octave.exe, if you're on Windows.
Once you have the path, open Sublime and select Preferences -> Browse Packages..., which will open your Packages folder (surprisingly). Navigate to Packages/SublimeREPL/config/Octave and open the Main.sublime-menu file in Sublime - don't worry, it's just plain JSON. Go down to line 18 (or thereabouts) - it should say "cmd": ["octave", "-i"],. Change "octave" to "/full/path/to/octave", obviously replacing /full/path/to/ with the actual full path you noted earlier.
Save the file, and you should be all set. Tools -> SublimeREPL -> Octave should now open up an interactive session, just like running octave -i on the command line would do. You can use all of the usual SublimeREPL shortcuts to send code to the running REPL, or just use if for testing functions, code snippets, etc.
Have fun!
I am using Sublime Text 3 on OS X
Octave programs are running perfectly. So you can try the below mentioned steps
Open Sublime
Goto Tools --> Build System --> New Build System...
Paste this code
{
"cmd": ["/usr/local/octave/3.8.0/bin/octave-3.8.0", "$file"],
"selector": "source.m"
}
Save it as Octave.sublime-build
Now use Octave as your build system
Use ⌘ + B to run your code.
Enjoy!

Sublime text version of Notepad++ 's "open current dir cmd"

I installed Sublime text 2 on my windows system . I'm trying to create a shortcut that would open the command line on the current file directory like i can using notepad++ . Also , on a similar note , how do i use/create shortcuts for "Open containing folder" in a way notepad++ allows me.
I think what you're looking for is the Terminal plugin by wbond, the author of Package Control. You can right-click and select Open Terminal Here... or use the CtrlShiftT keybinding to open a terminal at any file's directory, or use CtrlAltShiftT to open it at the directory containing the current project file.

HTML Build system in Sublime Text 2

I'm struggling to successfully build a HTML build system in Sublime Text 2. I am running Windows 7.
This is the code for my build system:
{
"cmd": ["open", "-a", "Google Chrome", "$file"]
}
This is the error I recieve when I try and build a html file:
[WinError 2] The system cannot find the file specified
[cmd: ['open', '-a', 'Google Chrome', 'C:\\Users\\Soham\\Desktop\\hello.html']]
[dir: C:\Users\Soham\Desktop]
[path: C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem]
[Finished]
I have no idea why this error is ocurring and have searched the web for an explanation.
Any help will be much appreciated!
Thanks in advance!
The open command is only available on OSX systems. You have two options - you can use Sublime's built-in "Open in Browser" functionality by right-clicking in any open HTML file and selecting Open in Browser, or you can modify your build system to just point to the correct location of chrome.exe:
"cmd": [ "C:\\Users\\YourUserName\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe", "$file"]
replacing YourUserName with the correct value, and ensuring that this actually is the location of chrome.exe on your system.
If you are using Chrome with Windows 7, you could run successfully the following:
{
"cmd": ["C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "$file"]
}

Open an .html file with default browser using Bash on Mac

So, this is what I need :
Let's say I have an index.html file.
How do I tell the terminal to open it using the default browser?
(Using AppleScript, BASH,...?)
from the directory containing index.html, try...
open ./index.html
the open command opens a file (or directory, or URL). open is included with MacOSx. specifics and options can be found using
man open
note: default application is determined via LaunchServices.
You can use the open command with the -a flag to open a file or location in Chrome (or any target application):
open -a "Google Chrome" index.html
This also works with URLs, i.e. open -a "Google Chrome" http://www.apple.com.
---> I found this answer # stack exchange, thanks to user "robmathers"
Actually, this is not quite as straightforward as it looks. As suggested by the other answers, OS X provides the open utility to launch applications matching a file type from the shell. However, in the case of a HTML file, that is the application registered with Launch Services for the file type public.html, which can, but need not be, your default browser (I think it is on a pristine install) – or whatever editor registers as able to edit HTML (not an uncommon occurrence on a dev system). And while the default browser is registered for the URL protocol http no matter what, there is no way to access that protocol handler to open a file with open.
To compound the issue, although the handlers are stored in the com.apple.LaunchServices.plist preferences accessible via the defaults command, the structure of the information (a dictionary with two same level entries, one denoting the protocol, one the handler) makes it non-trivial to parse with defaults.
The good news is somebody already solved that problem: HAMsoft Engineering offers the DefaultApplication shell utility. Download it and save it somewhere where it is accessible to the shell (typically /usr/local/bin, although that is not in the default path for shells on some OS X versions – check the contents of /etc/paths to be sure). That available, the following command will open a HTML file in the default browser, whatever editor / viewer might be registered otherwise:
open -a "$(/usr/local/bin/DefaultApplication -url 'http:')" "/path/to/your/document.html"
To open the filename.html in the default browser use :
open filename.html
open is a very good command as well as a feature of Mac OS that makes me fall in love with it more deeper.
It automatically chooses the appropriate default app to open the file.
And in case you want to open a file in your desired app rather then default :
open -a /Applications/Google\ Chrome.app filename.html
The backslash \ after Google is used to escape the space character.
Alternatively you can write :
open -a "/Applications/Google Chrome.app" filename.html
Hope this helps you ( I know I am very late ) and others !!!.
You can also get the default browser with Perl: open http://example.com -a "$(VERSIONER_PERL_PREFER_32_BIT=true perl -MMac::InternetConfig -le 'print +(GetICHelper "http")[1]')".
i managed to open the html file with chrome by placing the file after the browser command. so,
google-chrome-stable ./index.html
although im not sure what the call would be to the default browser, if you knew it you could put it as an alias in your .bashrc and from then on, use whatever you called your alias, plus the file.
goo ./index.html
just my experience, first response
In terminal you can run open index.html
this works on linux, should also work on mac
#!/bin/sh
# open a html file in default browser, not text editor,
# when text editor is set as default app for html files
url=file:///path/to/file.html
protocol=http
app=$(xdg-mime query default x-scheme-handler/$protocol)
# example: chromium-browser.desktop
[ -z "$app" ] && {
echo "error: xdg-mime could not find default app for protocol $protocol"
exit 1
}
app=$(basename $app .desktop)
gtk-launch $app "$url"
ideally i could just say
xdg-open http+file:///path/to/file.html
but this is not working