WSL-2 `code` command installs vscode instead of using local windows install - wsl-2

I have a local vscode installed for windows.
Afterwards I setup wsl-2 and use it as my shell.
When I tried to open a file with code using the code filename command, it installed vscode anew instead of using the local windows install.
Installing VS Code Server for x64 (054a9295330880ed74ceaedda236253b4f39a335)
Is there a way to point wsl to use the windows install when triggering it via the code command?
I don't specifically mind using either or, but settings/extensions etc. for one are not used by the other.

By checking with Git Bash where the location of code is when triggering it (type -a code) and comparing it to the ubuntu wsl shell, I came to the conclusion, that it is actually the same install that is being triggered, . I will have to check why some extensions do not seem to "carry over" though.
The code that is being triggered is a script, that behaves differently when being triggered from within WSL.

How about an alias?
# Set alias
alias code2='/mnt/c/Users/Username/AppData/Local/Programs/Microsoft\ VS\ Code/bin/code'
# Open a file now
code2 file.txt

Related

Is it possible to run a command from Cygwin, into a Git Bash terminal, with arguments?

I haven't been able to find a similar question, but I can't imagine this is an issue that comes up too much.
At my workplace I've decided to switch over to a full Linux experience by using Cygwin, over what I was previously using, Git Bash.
The only slight drawback is that we have a script written in Ruby that deploys changes to our site. I can run this from my Git Bash terminal no problem, but not Cygwin as there doesn't seem to be a Ruby installation on here. I've learned about sending standard output to other terminal windows, but I've only been successful when both terminals have been the same shell.
What I'd like to do is the following:
1. Type a command into Cygwin that opens a Git Bash terminal and automatically runs ./deploy.sh on that Git Bash terminal upon opening.
2. If possible, also pass in an argument in the same command, that the script expects upon running. (In this case it's whether we want to deploy to our staging or production server).
Is this possible? So far I can get what looks to be a Git Bash terminal to open and prompt me for the server, but when I enter it, it does not work. I get an error with regards to a command within the script not being found. Thing is, running this same ./deploy.sh script in a Git Bash terminal that I open myself works perfectly as it always has. The Git Bash terminal that is being opened by Cygwin does not appear to have all of the capabilities of a Git Bash terminal I open 'the normal way'.
The command I am running so far from Cygwin is as follows:
/cygdrive/c/'Program Files'/Git/git-bash.exe "./deploy.sh"
I understand there is probably a way of getting this to work by installing Ruby via Cygwin but I'd like to mess around with my work environment as little as possible in case I somehow affect my ability to deploy my work... and besides, Git Bash definitely runs this script without an issue so I can't see why I would need a duplicate installation.
Many thanks!

How do I create a shortcut for a command line command in Raspbian Stretch?

I am attempting to install RetroPie as an app on Raspbian Stretch and I am done except for creating a desktop shortcut for it. The problem is that the only way to open RetroPie seems to be running a command in the command line. I can’t do it in terminal because it gives me an error saying that it can’t initialize the window. Is there a way to run a command line command as a shortcut or am I going to have to find another way of doing this?
P.S. Here is the tutorial that I followed to install RetroPie:
https://www.makeuseof.com/tag/install-retropie-app-raspberry-pi/
Probably your shell (on the raspberry) is GNU bash. So read the manual of GNU bash.
You probably want (once) to edit some Bash startup file (such as ~/.bashrc) to define functions and aliases there, and you could add executable shell scripts somewhere in your $PATH. I recommend having a $HOME/bin/ directory containing your scripts and executables, and have $HOME/bin/ early in your $PATH.
I can’t do it in terminal because it gives me an error saying that it can’t initialize the window.
Perhaps you need some display server (such as Xorg or Wayland) running (with a desktop environment or a window manager). You could run Xorg on your PC (on which you could install Linux) and connect to the raspberry using ssh -X then remote applications running on your Raspberry are displayed on your PC. IF your Raspberry is directly connected to a screen (via HDMI) you might run some Xorg server on it.
Is there a way to run a command line command as a shortcut
Yes, by making a shell alias or shell function or shell script. You need to understand how they work and change or create some appropriate file using some source code editor (I recommend GNU emacs, but the choice is yours and you might use any other editor such as vim, gedit, etc...): functions and aliases could be defined in your ~/.bashrc; shell scripts would usually have their own file with a shebang under your $HOME/bin/...

How to install Node Version Manager(NVM) without admin rights

I have no admin rights in my windows machine. Can I install NVM without admin rights? I tried using the environment variable path setup, but its not working in my case.
I have the same need and couldn't find one, so I created one base on another simple nvm:
https://www.npmjs.com/package/#jchip/nvm
Requires powershell 4+ and permission to execute scripts.
(You're talking about https://github.com/coreybutler/nvm-windows right?)
Whether you can install it without admin rights aside, the actual act of switching node versions with it requires them so you're going to have trouble.
Your best bet is to install different versions of node into different paths manually, and then configure your environment variables to point to the right one whenever you need to use it.
eg. prefix your cmd script with PATH=C:\node\v10;%PATH% to have any node or npm calls in that script use whatever node is sitting in v10
try this
create a bat file like below
#cd C:\Users\testuser\AppData\Roaming\nvm
#SET PATH=C:\Users\testuser\AppData\Roaming\nvm\v14.21.1;%PATH%
cd c:\users\testuser\Desktop\Project
#cmd.exe /K
Run bat file and type
code .
It's open with VSCode
go to the terminal and type node and you can see the node version that you set in the bat file.
enter image description here
You can apply any node version as above bat file
If you use Git Bash on Windows, you can add this to your bash.bashrc to switch node versions:
export PATH=/c/path/to/node/dir:$PATH
Then just restart your terminal to pick up the updated PATH.
It will prepend your path with your desired node version. It's the only way I've found to override the installed node version if you don't have admin rights on your machine.

PyInstaller on Linux (Ubuntu) -- open executable in console

Running PyInstaller v3.2 on Ubuntu 16.04, is it possible to get my bundled application to open a console for stdout? On Mac and Windows I can get this to work, as outlined in the options documentation. But nothing is mentioned for Linux. I've tried playing around with the -c flag, but that does not seem to have any effect. I also tried bundling it as a single file (-F) versus a directory, but neither seems to open a console for stdout...
Just for future reference, in Linux if you run a bundled app from the command line like a script, it will automatically use that same terminal as stdout ...

virtual terminals in ubuntu server do not recognize newly installed nvm

Ubuntu server (as all linuxes) has the ability to multitask using ctrl-F1 up to ctrl-F7. Each of these key combos puts you in another terminal. While in the main terminal (ctrl-F1) I installed nvm (node version manager) and also node.js. These work fine in the ctrl-F1 terminal. But when I go to another terminal, ubuntu thinks they are not installed. ECHO $PATH gives the same result in all virtual terminals. Default programs like nano, vim, etc can be started in all the different terminals. How can I 'fix' this issue so that I can run learnyounode in one terminal, nano in another terminal, and node in another terminal?
If you have shells running on those terminals which were initiated before you ran the installer, they will not have received the updated configuration. Log out and then back in, or figure out which configuration file(s) to source anew. Probably
. ~/.bashrc
but there could be pertinent changes in .bash_profile and/or .profile as well (and system config files, if you did a system-wide install).

Resources