How can I respond to my program in the Output tab of Visual Studio Code?
I am using the Code Runner extension. Here is a picture of what I want (lower part, near "Ausgabe"):
The Output panel doesn't support input. That's one of the reasons why they switched from Output panel to Terminal in version 2 of the Tasks API.
It seems the Code Runner extension supports running in the Terminal as well:
"code-runner.runInTerminal": true
In Visual Studio Code (for Mac OS) version 1.49.0, you can input data through the Output panel after you make the following change in settings:
Click the gear icon in the bottom left corner and select Settings:
Enter "run in terminal" in the search bar:
Check the box next to "Whether to run code in Integrated Terminal".
Attention: Remember to uncheck the box if you want to display the code results on the Output tab again.
Yup! you cannot write in the output terminal.
But if you don't want to run that in integrated terminal you can just modify your code-runner.executorMap to run that code in a new terminal, which closes after your execution gets finished.
"code-runner.executorMap":{
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && gnome-terminal -- bash -c \"./$fileNameWithoutExt\"",
"cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && gnome-terminal -- bash -c \"./$fileNameWithoutExt\"",
}
this is for C & C++ and similarly you can write it for other languages as well.
here i have added the gnome-terminal -- bash -c \"./$fileNameWithoutExt\" part
for details of this command, Click here! .
Related
New Windows Terminal (Windows Terminal (Preview) Version: 0.2.1831.0) have settings in JSON file. How can I setup powershell running with Anaconda?
Anaconda running in powershell with:
%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'C:\Users\akali\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'C:\Users\akali\Anaconda3' "
Windows Terminal use profiles in JSON like this:
"profiles": [{
"colorScheme": "Solarized Light",
"commandline": "powershell.exe"
}]
How can I use running with Args with double quote in JSON that allow me run something like -Command "& 'C:\'"?
I realize I'm late of some years but I had a similar problem and stranded up here looking for an answer. So, I'm hoping that this is useful for people like me in the future.
After some time tinkering I generated an Anaconda profile:
copy paste an existing profile
generate guid here
open C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)
right click on Anaconda Powershell Prompt (Miniconda3) and go to Properties
copy the entire content of the target field and paste it on the field commandline (make sure the field is commandline and not source)
escape all the \ characters (\ --> \\)
Change the name field
You should have something like this
{
"guid": "{generated guid}",
"hidden": false,
"name": "Anaconda",
"commandline": "powershell.exe -ExecutionPolicy ByPass -NoExit -Command & 'C:\\ProgramData\\Miniconda3\\shell\\condabin\\conda-hook.ps1' ; conda activate 'C:\\ProgramData\\Miniconda3'"
},
As a nice sidenote, you can also create a profile to directly launch an Ipython session or a jupyter notebook.
As you may have noticed, lo launch anaconda in the commandline field we are just launching powershell.exe, and then telling the powershell instance to execute a -Command, which is the subsequent string.
Were you to add a ; ipython to the command, you would launch an ipython session.
Copy-paste the settings for cmd from above.
Go to "C:\Users\Username\AppData\Roaming\Microsoft\Windows\Start
Menu\Programs\Anaconda3 (64-bit)"
Right-click on "Anaconda Prompt (Anaconda3)"
Copy the content from the target field and paste it on the field commandline
Mine is %windir%\System32\cmd.exe "/K" C:\bin\Anaconda3\Scripts\activate.bat C:\bin\Anaconda3
Replace \ with \
Thanks to the above answer by Marco Necci, this is a more clear version with cmd and anaconda
"commandline" : "%windir%\\System32\\cmd.exe /K C:\\bin\\Anaconda3\\Scripts\\activate.bat C:\\bin\\Anaconda3"
Building upon Navaneeth M et al, I contribute a command line which includes the default Anaconda location using USERPROFILE environment variable, specifying non-default Anaconda env (fastai), starting directory and color scheme.
"commandline": "%windir%\\System32\\cmd.exe /K %USERPROFILE%\\Anaconda3\\Scripts\\activate.bat fastai",
"colorscheme": "Solarized Light",
"startingDirectory": "c:\\sw",
Pro Tip: Use keybindings to add a hotkey which opens a new tab in the specified project directory. For example, use ctrl-b to open a new Anaconda tab in just the right place.
"keybindings": [
{
"keys": [ "ctrl+b" ],
"command": {
"action": "newTab",
"profile": "Anaconda",
"startingDirectory": "c:\\sw\\myproject\\myprojectdirectory"
}
}
]
Right click properties of conda powershell shortcut (in desktop or start menu). There you get the path to the command that effectively starts conda using powershell.
Now, just follow the recipe of Marco Necci outlined above, just caring to put double backslashes instead of single ones.
Searching further modifications, in this site i've found that i could generate the new needed guid with powershell itself: [guid]::NewGuid().
And in the repo of new terminal, i've discovered it's possible to customize the icon too. My icon was in a different path, that i came across looking in anaconda shortcut in windows menu (i used anaconda navigator's icon - right click it > more > open; somewhere ending with 'Start Menu\Programs\Anaconda3 (64-bit)': right click once more in the shortcut > properties; change icon - there is the path to the icon).
Again, be wary to use double backslashes instead of single ones.
Sound as lazy as it is I was wondering if it's possible to open a file with sublime using (command line) and in the same command define the expected syntax.
Lets say on a mac we have the subl command installed, so running $ subl .bash_something will open the .bash_something then we have to chose the "shel script(bash)" syntax from the list. what would be really nice (for laze me) is to include the syntax to the command as an argument. i.e.
$ subl -x bash .bash_something
or something like that. this obviously doesn't work but I was wondering if there is similar solution or if its possible to include one
Unfortunately, there is no way that I can find to dynamically set the syntax from the command line. subl has the --command option, which allows you to run a Sublime command while loading the file, directory, or project indicated. However, the command to change the syntax of a view - set_file_type - takes an argument of the form ("syntax": "Packages/PackageName/SyntaxName.sublime-syntax") (or SyntaxName.tmLanguage). As far as I've been able to tell, you simply can't pass arguments to commands run via the command line. I've opened an issue to request an enhancement.
Now, this doesn't mean that all is lost. If you have just a few filetypes that are unknown to Sublime, open them, then select View -> Syntax -> Open all with current extension as... and select the syntax you want. If for some reason this isn't sufficient, or would like finer-grained control over exactly which filenames (not just which extensions) get opened as what, check out the ApplySyntax plugin. It allows you to use regexes to open exactly which file patterns you define as what syntax.
Commands can take arguments in Sublime 3 now. I was able to achieve this functionality with a bash function.
You can pass arguments to the --command option with inline JSON and escaped quotes. This command will change the syntax to Bash for the current active file in Sublime:
subl --command "set_setting {\"setting\": \"syntax\", \"value\": \"Packages/ShellScript/Shell-Unix-Generic.sublime-syntax\"}"
I created a simple bash function and sourced it in my .bash_profile to wrap these two commands together to activate/open a file then change the synax:
function subl_bash() {
subl "$1" && subl --command "set_setting {\"setting\": \"syntax\", \"value\": \"Packages/ShellScript/Shell-Unix-Generic.sublime-syntax\"}"
}
How to fix this error. When i use command “yo meanjs”, but not show as in video. It’s:
undefined
You’re using the official MEAN.JS generator.
What mean,js version would you like to generate? i choose 0.4.0
In which filder would you like the project to be generated? mean
Cloning the MEAN repo…
Then it appear error:
Command failed: C:\Windows\system32\cmd.exe /s /c “rm ./mean/package.json”
‘rm’ is not recognized as an internal and external command, operable program or batch file.
you should install git on windown 7 and select folder you want . click -> right mouse -> Git Bash
After type command : "yo meanjs" and everything will good
The tpt2213's answer works, but it can't select menu items of "yo meanjs" with arrow keys.
You need to have cmd.exe with PATH setting, which includes the git command and Unix commands like the rm.
If you install git on window 7 in the folder, "C:\Program Files\Git", set PATH before you run "yo meanjs".
set PATH=C:\Program Files\Git\usr\bin;C:\Program Files\Git\bin;%PATH%
yo meanjs
I am new to tmux and I am trying to edit my tmux.conf file to have the left side of the status bar reflect:
[SessionName] [CurrentPane] [CurrentWorkingDirectory]
I am able to display the SessionName and CurrentPane. However I can't get to display the CurrentWorkingDirectory.
I've tried several #(shell command) options:
#(tmux select-pane -t :.#P; pwd) :
But this prints some other $PWD variable which does NOT reflect
the current directory of the bash session in the current pane.
#(tmux select-pane -t :.#P; tmux send-keys pwd Enter)
Firstly, although it did print the CurrentWorkingDirectory if I'm
in a terminal. It prints this in the terminal and NOT in the status
bar like how I want it. Secondly, It entered "pwd Enter" every 15
seconds whether or not I was in a terminal, which was a hassle to
reverse if your not as quick (like I am).
I've tried these options but to no avail, is it possible to do what I want? and how?
There is a variable for that, which doesn't seem to be in the manpage but is mentioned in the development version. For me, it works in the 1.8 release of tmux.
set -g status-left "#{pane_current_path}"
Note that it also works when you put it in the window-status. Each window status will mention respective working directories.
setw -g window-status-format "#{pane_current_path}".
I'm not sure how to do this in bash, but in zsh, there's a hook that gets run before every command. In your .zshrc:
precmd () {
tmux set -qg status-left "#S #P $(pwd)"
}
This will run that tmux command everytime you run a command. Hope this helps. Since bash doesn't have a precmd, I'm not sure how to do this.
Unfortunately, the proposed solution does not work for version 1.7 - "official version" for OpenSuse 12.3, but I managed to find a solution:
In /etc/tmux.conf:
setw -g window-status-current-format "#T(#I:#W#F)"
setw -g window-status-format "#T(#I:#W#F)"
Here #T - tells to display current pane title, which can be set with some escape sequence. For doing this at each shell command, put
somewhere in .bashrc:
[[ -n "$TMUX" ]] && PROMPT_COMMAND='echo -n -e "\e]2;${PWD/${HOME}/~}\e\\"'
This works for me on OpenSuse 12.3, tmux 1.7, bash 4.2.53.
would like have BAT file that runs set-keys.EXE, launches default.html, and then when user closes html, run set-keys-back.EXE. (they are all in the same directory together). This might be run from a CD, so I might not have ability to write a flag file and then wait to see if it is deleted in order to continue. Have already tried START /WAIT but have seen that WAIT won't actually wait for GUI 32-bit applications. Have considered one batch file calling another one, still no luck. Would prefer not to have PAUSE and user have to come back to CMD just to hit a key - seems clunky. When they close out of HTML, I execute top.window.close(). would be nice if I could put some other code after that, but I think once the window is closed it's closed - no more processing. have not been able to get WShell execute to run. HTML status bar just says error on page - no info. Would love to hear your thoughts...
Update 2: I just figured out that you can launch IE directly without having to use the start command:
#echo off
rem You can use %SCRIPTDIR% to refer to the file to load, if you like
rem Note that %SCRIPTDIR% will contain a trailing slash!
set SCRIPTDIR=%~dp0
echo Testing this script...
C:\PROGRA~1\INTERN~1\iexplore.exe %SCRIPTDIR%foo.html
echo Continuing the script...
This example works for me (Windows XP 32-bit), and waits for me to close the browser window to continue.
Update: Here's an updated code block that launches Internet Explorer. Note that I use the short path to the iexplore.exe executable, and I specify the full path to the file to load:
#echo off
echo Testing this script...
start /wait /min cmd /C "C:\PROGRA~1\INTERN~1\iexplore.exe C:\foo.html"
echo Continuing the script...
Initial Answer: You mentioned trying the start /wait command, but how did you explicitly write it? The following batch script example works for me in Windows 7 x64:
#echo off
echo Testing this script...
start /wait /min cmd /C "%windir%\system32\notepad.exe foo.html"
echo Continuing the script...
In this example, the script does not continue execution until the user closes the Notepad application. The only downside here is that an extra command window pops up, but by using the /min parameter, we can start it minimized.