Command-Line Question.. I recently used start atom filename.txt to open a file in atom from my command-line - command-line

However I want to open other programs in the command-line, for example I tried sublime 3 and I got an error.
My question is where do you find what is the correct spelling for the programs we desire to work within the command-line?

The correct spelling for Sublime text is subl. I just googled "sublime text open from command-line".
Not all programs have command-line equivalents. For example I know Visual Studio Code installs the code command. But for a simpler editor like TextEdit you would need to use open.

Related

PowerShell script in one long line - auto-format?

I was given a PowerShell script, that when opened in a text editor, is one very long line of code. Is there any kind of auto-format tool for PowerShell syntax? I use Notepad++ and read a thread here (https://superuser.com/questions/58884/auto-format-document-with-notepad)and here (PowerShell Code Tidy or Reformat?) about certain plugins that can help with indentation and other code cleanup, but nothing that I've seen that can take one long line and tidy it.
Thanks.
I'd suggest using Visual Studio Code with the PowerShell extension. From there, you can utilize the Format Document tool (default keybind: SHIFT+ALT+F). This will look at your settings file and uses PSScriptAnalyzer to perform the formatting rules.
With the newest update (June2018), Visual Studio Code supports fully portable downloads by downloading the .zip option and creating the /data/tmp/ directory in the root where code.exe lives.
Visual Studio Code
PowerShell extension releases
Microsoft recommendations

Can somebody help me make Visual Studio Code with Julia ?

I am studying economics so I have not much experience in programming. I really would like to make Julia work on Visual Studio Code but I've been unsuccessful.
So I downloaded the Julia extension but I don't know how to define the settings. Do I need to create a launch.json file or any other file to make it work?
I think that somebody asked a similar question previously at "How to setup Julia in VS code?"
but the answer didn't really help me.
Thank you all for your help.
First you need to install Julia on your Mac by downloading the julia dmg file from here. This puts an application in the Applications folder.
There are several ways to set things up so julia will run from command line. I used the following:
ln -fs "/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia" /usr/local/bin/julia
This should work if the name of your application, that you just installed, is julia-0.6.app
After running the above command, you should be able to type Julia on the command line and have it to start.
You can now create a Julia script and place it in the directory you're running from. I created a file named julia_test001.jl It contained the following:
for i in 1:5
print(i, ", ")
end
This is a very short Julia script I wrote for testing.
Now start VScode and install the Julia language support extension. After that has loaded, open the file Julia_test001.jl. Once this file is opened, click the triangle in the upper right corner or open the command palette and select the option: run code. The julia_test001.jl should run and print the result 1,2,3,4,5.

Editing WSL config files\code etc with Visual Studio Code, in Windows

I am really enjoying WSL and using it for a lot of stuff these days, including my Ansible workstation, also writing a lot more code in it...
Question: I can see where the WSL file system is:
https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-nt-subsystem-and-vice
All of the docs tell you very clearly to stay away from the Linux file system and not to access it from the Windows instance it is running under. Fine. But! I hate to ask redundant question, but I would dearly, dearly love to be able to use full blown graphical VS Code in Windows in my text editor for WSL. Am i missing a trick somewhere for a way to do this without breaking anything?
Apologies for the non question. Hopefully it is allowed.
In vscode...
You can press the green icon bottom-left
This will open the command palette
Choose "New WSL Window"
Open a folder, you will be able to navigate from ~ to choose location in command palette
Once folder is choosen, you're set to go, vscode will display file tree from opened folder and you can do your thing :)

External editor for IPython notebook

I am using IPython notebook and I want to edit programs in an external editor.
How do I get the %edit file_name.py to open an editor such as Notepad++.
Running %edit? will give you the help for the %edit magic function.
You need to set c.TerminalInteractiveShell.editor, which is in your ipython_config.py. I'm not quite sure where this is located in Windows; on OS X and Linux, it is in ~/.ipython. You'll want to set the variable to be the full path of the editor you want.
Alternatively, you can create an environment variable EDITOR in Windows itself, and set that equal to the full path of the editor you want. iPython should use that.
I'm using Windows 7 and 8 (and 10TP) and Python 3.4.2.
I started with ipython locate to tell me where ipython thought config files suggested elsewhere should be. When I saw it was different I read around and came up with the following:
On my system, the ipython locate gave me c:\users\osmith\.ipython, not the _ipython you'll see mentioned in the YouTube videos done with Windows XP,
Look in the directory ipython locate specifies for a profile directory; if you aren't actively doing anything with ipython profiles, it should be .ipython\profile_default, if you are using profiles, then I leave it to you to s/profile_default/${YOUR_PROFILE_NAME}/g
Check the profile_default directory for a ipython_config.py file, if it's not there, tell IPython to initialize itself: ipython profile create
Open the config file in a text editor,
If you are the kind of person who hasn't messed around with their console overly much and installs things in standard places, you can skip straight to this step by typing: ipython profile create followed by start notepad .ipython\profile_default\ipython_config.py.
Search for the string c.TerminalInteractiveShell.editor,
The comment above this indicates you can also use the EDITOR environment variable, but hard coding file paths never hurt anyone so lets do eet:
Copy the line and remove the leading hash and spaces from the copy.
Replace the text between the apostrophes ('notepad') with the path of our desired editor, e.g.
c.TerminalInteractiveShell.editor = 'c:/program files (x86)/noddyeditor/noddy.exe'
There is a catch here, though; some modern editors get a bit fancy and automatically and, when invoked like this, detach from the console. Notepad++ and Sublime Text, for example. Sublime accepts a "--wait" option, which works some of the time; this tells the command invocation to hang around until you close the file, for some definition of until and some other definition of close.
However, the following setting will work most of the time for sublime text:
c.TerminalInteractiveShell.editor = '"c:/program files/sublime text 3/subl.exe" --wait'
(assuming c:\program files\ is where your sublime text 3 directory is)
Try the 'Pycharm' editor
This works for me.

How to configure Textmate (Mac version) to run Stata commands?

I'm a Mac user trying to configure Textmate to run Stata commands.
I downloaded and installed the Stata bundle from this website (http://bylr.net/3/2010/10/stata-bundle-for-textmate/)
Here's what I see in the Textmate Bundle Editor:
Here's where I get stuck.
I don't see any command for running Stata codes in the menu list. Did I download the right bundle? How do I run Stata commands in Textmate? I'm a beginner in Textmate. Am I to run something in the Terminal?
You won't be able to execute Stata code from within TextMate as you do with R, for example. Workarounds:
Run Stata code from the Terminal instead (and I guess that you could program TextMate to tell Terminal to tell Stata to run some code, but that's insane), as explain in Richard's answer.
Use the Tim Beatty bundle to send code to Stata and execute from there. There's what I think is a better bundle by Phil Schumm over at SourceForge.
From Stata's console you can run a do file with do my_do_file or from terminal.app you can run Stata in batch mode with stata -b do my_do_file &.
I don't see TextMate on the Stata text editor FAQ, but the FAQ may provide the hints you need to make the TextMate bundle more robust.