use a different .zshrc for vscode internal terminal - json

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,
}

Related

Visual Studio Code - Launching GDB in specific directory

I just have a quick question:
EDIT: This is run under Ubuntu 20.04 WSL2 using Visual Studio Code.
So I am debugging a kernel for gdb and the symbol files require that GDB is launched in the project directory, but the problem is GDB keep launching in the location of the program:
-exec pwd
Working directory /home/user/project-directory/obj/kern
I need GDB to stay in the project-directory:/home/user/project-directory
In the VSCode launch.json file, I made a workaround by adding a custom launch setup as shown below:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Kernel",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/obj/kern/kernel",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"printCalls": true,
"showDevDebugOutput": true,
"setupCommands": [
{
"description": "Change back to the workspace folder",
"text": "cd ${workspaceRoot}",
"ignoreFailures": true
},
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
// "preLaunchTask": "Launch Qemu (no graphic)",
"miDebuggerPath": "/usr/bin/gdb",
"miDebuggerArgs": "",
"targetArchitecture": "x86_64",
"customLaunchSetupCommands": [
{
"text": "target remote localhost:1234",
"description": "Connect to QEMU remote debugger"
},
{
"text": "symbol-file obj/kern/kernel",
"description": "Get kernel symbols"
},
// {
// "text": "set architecture i8086",
// "description": "Sets the current architecture"
// }
],
"avoidWindowsConsoleRedirection": true
}
]
}
The ${workspaceFolder} and ${workspaceRoot} are located in the project's directory, but without the setup to change back into the workspace folder, it won't work. Any tips would be appreciated!

PhpStorm: what are php-cs-fixer files and how to ignore them

I keep getting "Multiple definitions exist for class..." warnings in PhpStorm, and upon inspection, I see these a bunch of these huge php-cs-fixer files (100K+ lines) with the comment "This file is part of PHP CS Fixer.".
I found that there are multiple copies of several other files named phploc, composer, php-scoper, etc., under vendor/library_name/tools/ in various libraries for some reason. They are all huge compiled files that PhpStorm detects.
I tried ignoring these files in PhpStorm one by one, and once re-indexing finishes, these files disappear, leading me to believe they're IDE-generated files. However, it makes no sense the IDE would generate them and in turn include them hinting code.
composer.json
{
"name": "magento/project-community-edition",
"description": "eCommerce Platform for Growth (Community Edition)",
"type": "project",
"license": [
"OSL-3.0",
"AFL-3.0"
],
"config": {
"preferred-install": "dist",
"sort-packages": true
},
"require": {
"magento/composer-root-update-plugin": "~1.0",
"magento/product-community-edition": "2.4.1"
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.16.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "*",
"magento/magento2-functional-testing-framework": "^3.0",
"pdepend/pdepend": "~2.7.1",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "^2.8.0",
"phpstan/phpstan": ">=0.12.3 <=0.12.23",
"phpunit/phpunit": "^9",
"sebastian/phpcpd": "~5.0.0",
"squizlabs/php_codesniffer": "~3.5.4"
},
"conflict": {
"gene/bluefoot": "*"
},
"autoload": {
"psr-4": {
"Magento\\Framework\\": "lib/internal/Magento/Framework/",
"Magento\\Setup\\": "setup/src/Magento/Setup/",
"Magento\\": "app/code/Magento/",
"Zend\\Mvc\\Controller\\": "setup/src/Zend/Mvc/Controller/"
},
"psr-0": {
"": [
"app/code/",
"generated/code/"
]
},
"files": [
"app/etc/NonComposerComponentRegistration.php",
"app/helper.php"
],
"exclude-from-classmap": [
"**/dev/**",
"**/update/**",
"**/Test/**"
]
},
"autoload-dev": {
"psr-4": {
"Magento\\Sniffs\\": "dev/tests/static/framework/Magento/Sniffs/",
"Magento\\Tools\\": "dev/tools/Magento/Tools/",
"Magento\\Tools\\Sanity\\": "dev/build/publication/sanity/Magento/Tools/Sanity/",
"Magento\\TestFramework\\Inspection\\": "dev/tests/static/framework/Magento/TestFramework/Inspection/",
"Magento\\TestFramework\\Utility\\": "dev/tests/static/framework/Magento/TestFramework/Utility/",
"Magento\\PhpStan\\": "dev/tests/static/framework/Magento/PhpStan/"
}
},
"version": "2.4.0",
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "https://repo.magento.com/"
}
],
"extra": {
"magento-force": "override"
}
}
PhpStorm ignored files (adding php-cs-fixer and phploc here somehow removed all/multiple copies from the vendor directories):
These files are in your vendor directory as you must have install your dependencies from sources, not distributions.
Let's use sebastian/code-unit as an example to see how it works:
the file obviously is in the repository: https://github.com/sebastianbergmann/code-unit/tree/1.0.8/tools
but excluded from being exported to distribution (the archive file you are actually downloading from GitHub when installing package): https://github.com/sebastianbergmann/code-unit/blob/1.0.8/.gitattributes#L6 - you can see that it's not present in file you download from https://github.com/sebastianbergmann/code-unit/releases/tag/1.0.8
So, you must have install your dependencies using composer install --prefer-source (or composer update --prefer-source as it's the other command with that option) and you want to use --prefer-dist or actually not using any of these flags as the latter is the default. You can find more information about it in official documentation: https://getcomposer.org/doc/03-cli.md#install-i
Remove your vendor directory and install dependencies once more without --prefer-source flag.
AFAIR there was also an issue when you did not have curl extension installed, then simply add this extension.

How to fix "/bin/bash: [command] command not found" after setting up tasks.json and c_cpp_properties.json for C++ on Windows 10 VS Code?

I have configured my task.json and c_cpp_properties.json so that I may compile my main.cpp program. In order to proceed, I must press
Ctrl + Shift + B
As soon as I do a terminal pops up and alters me of an error:
Executing task in folder C++: C:\MinGW\bin\g++.exe -g main.cpp -o c:\Users\Me\Desktop\C++\.vscode\tasks.exe <
/bin/bash: C:MinGWbing++.exe: command not found
The terminal process terminated with exit code: 127
Terminal will be reused by tasks, press any key to close it.
I don't why this is happening since I've already checked that MinGW is installed in my computer with the correct PATH. To ensure that I do I typed the following in the terminal:
g++ --version
g++ (MinGW.org GCC-8.2.0-3) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
I also checked the path according to this figure
The only closest problem related to mine is in this Github link. I've also already tried changing the file directory shown in the code below using this thread but I still encounter this error.
Here are my JSON files which are inside my .vscode file:
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"main.cpp",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.17134.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:\\MinGW\\lib\\gcc\\mingw32\\8.2.0\\include\\c++"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
I should expect to see a ".exe" after compiling but I can't due to the error.
After spending two days messing around with this I've finally able to correct setup C++ on VS Code and resolved the error.
According to the png image from above, I've included "C:\MinGW\bin" within the user variable "Path" under the dialogue box "User variables for Me". After a simple restart on my computer, I was able to build my project (Shift + Ctrl + B) with no problems.

How to specify metadata for GCE in packer?

I'm trying to create a GCE image from packer template.
Here is the part that I use for that purpose.
"builders": [
...
{
"type": "googlecompute",
"account_file": "foo",
"project_id": "bar",
"source_image": "centos-6-v20160711",
"zone": "us-central1-a",
"instance_name": "packer-building-image-centos6-baz",
"machine_type": "n1-standard-1",
"image_name": "centos6-some-box-name",
"ssh_username": "my_username",
"metadata": {
"startup-script-log-dest": "/opt/script.log",
"startup-script": "/opt/startup.sh",
"some_other_custom_metadata_key": "some_value"
},
"ssh_pty": true
}
],
...
I have also created the required files. Here is that part
"provisioners": [
...
{
"type": "file",
"source": "{{user `files_path`}}/startup.sh",
"destination": "/opt/startup.sh"
},
...
{
"type": "shell",
"execute_command": "sudo sh '{{.Path}}'",
"inline": [
...
"chmod ugo+x /opt/startup.sh"
]
}
...
Everything works for me without "metadata" field. I can create image/instance with provided parameters. but when I try to create an instance from the image, I can't find the provided metadata and respectively I can't run my startup script, set logging file and other custom metadata.
Here is the source that I use https://www.packer.io/docs/builders/googlecompute.html#metadata.
Any suggestion will be helpful.
Thanks in advance
The metadata tag startup-script should contain the actuall script not a path. Provisioners run after the startup script has been executed (at least started).
Instead use startup_script_file in Packer and supply a path to a startup script.

VirtualBox crashes after starting gdb in Visual Studio Code

I'm a new apprentice at my company, so I'm new to Stackoverflow and coding in general, please bear with me.
I wanted to get away from the text editors (gedit and geany) I used before and started looking for an IDE. I chose to use Visual Studio Code, and started setting it up. I had to set up a compiler and a debugger. The compiler worked, but the debugger is making trouble.
I am running Debian 64 bit in a virtual machine, the host system is windows 10 64 bit. This is my launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"program": "/usr/bin/gdb",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
},
{
"name": "C++ Attach",
"type": "cppdbg",
"request": "attach",
"program": "/usr/bin/gdb",
"processId": "${command.pickProcess}",
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}
As you can see, I set the program to gdb. Now if i try to debug my code with "C++ Launch" the terminal window for the gdb debugger will open, and the VSCode window looks like it is in debug mode.
Shortly before my Virtual machine crashes
Then my Virtual Machine just crashes, without any error message. My virtual machine client says canceled. I looked into every logfile that seemed at least a little relevant. I checked the virtual machine log. I google this problem in various ways. I checked if it crashes even if I close gdb before the crash (it does). And still I haven't found a way to prevent this crash from happening.
I asked most of my co-workers and they don't know an answer either.
This is my first post/question, if I made any mistakes (format, formulation, etc.) please tell me, so the next time I want to ask something it will be better.
Thanks in advance.