I don't know why konsole -- bash -c "command"
command is now working for kde
konsole
So, if you use kde
then install gnome-terminal
first
If you want to run an external terminal then add this to settings.json
vscode
"code-runner.runInTerminal": true,
"code-runner.preserveFocus": false,
"code-runner.executorMap": {
"c": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && gnome-terminal -- bash -c 'dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && gcc $File -lm;./a.out;echo Hit Enter to EXIT;read lines;rm *.out' && exit",
"cpp": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && gnome-terminal -- bash -c 'dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && g++ $File -lm;./a.out;echo Hit Enter to EXIT;read lines;rm *.out' && exit",
"java": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && echo $fileNameWithoutExt > /tmp/javaRun && gnome-terminal -- bash -c 'dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && javac $File;binary=\"$(cat /tmp/javaRun)\";java $binary;echo Hit Enter to EXIT;read lines;rm *.class' && exit",
"python": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && gnome-terminal -- bash -c 'cd;source /home/$USER/anaconda3/bin/activate; conda activate MyPy38;dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && python -u $File;echo Hit Enter to EXIT;read lines' && exit",
},
"terminal.integrated.inheritEnv": false
If you don't want to remove the binary or exe or class
file then remove rm *.out
or rm *.out
or similar commands from it.
For Anaconda
Python source /home/$USER/anaconda3/bin/activate;
is for activate base anaconda env and then active my env name MyPy38
at conda activate MyPy38;
. If you run python from the default python3
and pip
libreary then replace the command with
"python": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && gnome-terminal -- bash -c 'cd;dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && python3 -u $File;echo Hit Enter to EXIT;read lines' && exit",
or, You can use project base python envs "Like suppose python interpreter directory is /From/Base/To/Python/Binary/
directory " so, It will be
"python": "cd $dir && echo $PWD > /tmp/vsDir && echo $fileName > /tmp/vsFile && gnome-terminal -- bash -c 'cd;dir=\"$(cat /tmp/vsDir)\" && cd $dir;File=\"$(cat /tmp/vsFile)\" && /From/Base/To/Python/Binary//python -u $File;echo Hit Enter to EXIT;read lines' && exit",