Enter Input to sublime text - sublimetext2

I am using sublime text 2 as the editor for my programs and using this code
{ "cmd": ["g++", "$file", "-o", "$file_base_name"],
"selector": "source.c++", "working_dir": "$file_path",
"variants": [ { "name": "Run", "cmd": ["g++", "$file", "-o", "$file_base_name", "&&", "$file_path/$file_base_name"], "shell": true } ]
}
I am able to run the c++ programs but unable to use test inputs in it.
How do I do that...
P.S. I don't wanna take inputs from any file but give to the console itself.

Related

use a different .zshrc for vscode internal terminal

I'm using zsh from vscode integrated terminal
i also use hyper terminal, warp and iterm2 for other purposes but i like to use the integreated terminal while in vscode. i actually enjoy my heavy .zshrc config on external terminals, but i often get the popup "your shell environment is taking too long to load" from vscode. Tbh, i don't mind the popup itself, but i think that a lot of the features that are useful outside vscode are not needed inside.
How can i set a different .zshrc to load only to be used by the vscode integreated terminal ?
tried conditional loading from my .zshrc but don't like it
tried setting it in the vscode-settings.json
this self-answer confused me more
this i think points in the right direction but i am not sure how to use task.json
my env:
macOS 13.1 22C65 arm64
Apple M1 Max
vscode (1.74.11ad8d514439d5077d2b0b7ee64d2ce82a9308e5a for arm64)
zsh 5.9 (arm-apple-darwin22.1.0)
These are the settings to change in “settings.json”:
I created 3 profiles:
zsh-minimal with the vscode minimal config -> new ZDOTDIR
zsh-full with my usual heavy config -> probably not necessary since it is $HOME by default i think
bash, just in case i fu everything
set to null old profiles ( zsh and zsh(2)) to delete them from profiles selection dropdown menu, as per official documentation.
“terminal.integrated.defaultProfile.osx”: “zsh-minimal”,
“terminal.integrated.profiles.osx”: {
"zsh-minimal": {
"title": "zsh-minimal",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiMagenta",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/.homesick/repos/MYUSERNAME-dotfiles/home/vscode_zsh"
},
},
"zsh-full": {
"title": "zsh-full",
"path": "/opt/homebrew/bin//zsh",
"icon": "terminal",
"color": "terminal.ansiCyan",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
"env": {
"ZDOTDIR": "/Users/MYUSERNAME/"
},
},
"bash": {
"title": "bash",
"path": "/bin/bash",
"icon": "terminal",
"color": "terminal.ansiWhite",
"args": [
"-l",
"-i"
],
"cwd": "${workspaceFolder}",
},
"zsh": null,
"zsh (2)": null,
}

Sublime Text won't output Java println statements in main method

my Sublime Text javac build settings don't work for outputs like System.out.println statements in the main method.
I am using this sublime-build (javac):
{
"cmd": ["javac", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"working_dir": "${project_path:${file_path}}",
"variants": [
{
"name": "Run",
"cmd": ["java", "$file_name"],
"shell": true,
"env": {"CLASSPATH": "/path/to/jar/files:/path/to/more/jars"}
}
]
}
Changing "cmd" to
"cmd": ["javac \"$file_name\" && java \"$file_base_name\""]
won't work either. But it compiles correctly and has a correct output on my bash command line.
Any thoughts?
Thanks in advance!
Nevermind, I got it:
That's the magic line missing:
"cmd": ["sh", "-c", "javac $file_base_name.java && java $file_base_name"],

Sublime Text 2 REPL run iPython file with a user Plug-in

I am trying to run an iPython file in an interactive shell in Sublime Text 2. This is my first plugin I've written.
Here's what I have so far:
import sublime, sublime_plugin
class IpydevCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.run_command('repl_open',{"type": "subprocess",
"encoding": "utf8",
"cmd": ["ipython", "-i", "$file_basename"],
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "ipython",
})
self.window.run_command('move_to_group', { "group": 1 })
The issue here is that I don't get an interactive environment after. The view is all messed up. Any ideas how to fix this?
Thanks
Instead of running a notebook, you can directly call ipython using following configuration at the keymap bindings:-
[
{ "keys": ["f9"], "command": "repl_open",
"caption": "Python - IPython",
"id": "repl_python_ipython",
"mnemonic": "p",
"args": {
"type": "subprocess",
"encoding": "utf8",
"autocomplete_server": true,
"cmd": {
"osx": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"linux": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"],
"windows": ["python", "-u", "${packages}/SublimeREPL/config/Python/ipy_repl.py"]
},
"cwd": "$file_path",
"syntax": "Packages/Python/Python.tmLanguage",
"external_id": "python",
"extend_env": {
"PYTHONIOENCODING": "utf-8",
"SUBLIMEREPL_EDITOR": "$editor"
}
}
}
]
So, By clicking F9, it will open ipython on new shell

sublime custom build command, how to?

I have a program, which is using what they called wmake to build the code and it's very convenient. Suppose I have a folder and a C++ file: /path/to/file.C, all I have to do is go to /path/to folder and then type the wmake command and return and all is set.
When I am using sublimetext, I would like to open this file.C file and then ctrl+B to build it, but it doesn't work. Currently I customized a build system like:
{
"cmd": "wmake"
}
the error shows as
[Errno 2] No such file or directory
[cmd: wmake]
[dir: /path/to/file.C]
[path: /home/meee/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bin]
[Finished]
Anyone knows how to customize a build system in sublimetext2? I read the online mannual but still have no clue. Thanks
My aim
All I want to do is to get the same effect as I type in shell window a simple
wmake /path/to
Edit-1
I tried this, it's not working either, the same error. I dont understand why "no such file"?
{
"cmd": "wmake",
"selector" : "source.C",
"shell": false,
"working_dir" : "$file_path",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "wmake '${file_path}'"]
}
]
}
Edit-2
I tried using full path of wmake, and the error complains environment variable $WM_OPTIONS not set. So in shell, every time the ~/.bashrc is auto loaded, and to initialize all the environment variables, but this is not so in Sublime!!!!!!!!!!!!! What should I do???
{
"cmd": "/fullpath/to/wmake",
"selector" : "source.C",
"shell": false,
"working_dir" : "$file_path",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "/fullpath/to/wmake '${file_path}'"]
}
]
}
Your build command isn't complete. See my customized C build:
{
"cmd" : ["/usr/local/gfortran/bin/gcc", "$file_name", "-o", "${file_base_name}", "-lgsl","-lgslcblas", "-lm" , "-Wall"],
"selector" : "source.c",
"shell":false,
"working_dir" : "$file_path",
"variants":
[
{
"name": "Run",
"cmd": ["bash", "-c", "/usr/local/gfortran/bin/gcc '${file}' -lgsl -lgslcblas -lm -Wall -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
}
]
}

folder path in sublime text build system

My sublime project looks like this:
{
"folders":
[
{
"folder_exclude_patterns":
[
".bzr",
"build",
"webapps",
"work",
".settings"
],
"path": "/home/charles/project/Editor/trunk"
}
],
"settings":
{
"build_on_save": true,
"filename_filter": "\\.(java)$",
"tab_size": 4,
"translate_tabs_to_spaces": false
},
"build_systems":
[
{
"name": "compile",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
}
When I save a file the console says:
Buildfile: dev.xml does not exist!
Build failed
[Finished in 0.2s with exit code 1]
I know that I need to put something before dev.xml but I don't know what.
I found some possibilities here: http://sublimetext.info/docs/en/reference/build_systems.html#variables
But What I need is the folder path "/home/charles/project/Editor/trunk" in my case...
Any idea how I can achieve this?
You are missing "working_dir" in your "build_systems" setup. The example below will use the directory that holds the sublime project file as the build starting directory.
"build_systems":
[
{
"name": "compile",
"working_dir": "${project_path}",
"cmd": ["ant", "-f", "dev.xml", "compile"]
}
]
More information can be found at: http://www.sublimetext.com/docs/2/projects.html