How to install Visual Studio Code's `code` command permanently? - macos

I just followed the top-voted answer here and successfully installed Visual Studio Code's code command in my terminal.
However, the code command fails to launch Visual Studio Code every time after I restart my MacBook Pro.
~ code
zsh: command not found: code
Is it possible to install code permanently so that I don't have to install it every time I turn on my MacBook Pro?
~ where code
/usr/local/bin/code
~ ls -l /usr/local/bin/code
lrwxr-xr-x 1 myName admin 167 Aug 5 13:41 /usr/local/bin/code -> /private/var/folders/bh/525lnbns1213cx2651s97my00000gp/T/AppTranslocation/EA379FC4-05D2-4739-BE49-1D8870E47B8A/d/Visual Studio Code.app/Contents/Resources/app/bin/code
I also find out that the folder EA379FC4-05D2-4739-BE49-1D8870E47B8A get deleted after I restart my laptop.
This is the reason that I cannot run code after the laptop is restarted.
Why is code installed in a temporary folder?
My MacBook Pro's version is macOS Sierra version 10.12.6

The reason that code get installed in a temporary folder is that I placed Visual Studio Code.app in Downloads folder.
After I moved it to Applications folder, launched it, and installed code command, the code is not installed in a temporary folder anymore.

you can this code in visual studio code command palette to register shell command.
Open the command palette.
shell command
and run this command to install 'code' command
install 'code' command in PATH
And then restart terminal

Related

(Visual Studio Installation) Error 0x8007001d : Cannot write to the specified device

I can’t install Visual Studio Build tools.
when i want to launch the installation, a window appears telling me: writing impossible on the specified device.
I checked the logs and saw that there was an Error 0x8007001d
Also, I ran the installation with the command lines, I was able to download the files but then, when I run the command :
vs_buildtools.exe --noweb
It opens visual studio installer and I get the same Error 0x8007001d
You should know that without passing the command lines : vs_buildtools --layout d:\localVSlayout --lang fr-FR, I can’t download the packages in Visual Studio Installer
Have a good day

How to open file in a specific application from the command line

I want to open a .md file in a repo in visual studio code from my command line. Does anyone know the command for this?
I am using the bash shell.
First, you need to have Visual Studio Code CLI. ( Try code --version in terminal to check if it's already installed or not ). You have to install it manually on mac OSX (see below). In windows and linux, the command line interface code should be readily available in the PATH.
To install it (in MAC)
Launch VS Code.
Open the Command Palette (⇧⌘P) and type ‘shell
command’ to find the Shell Command: Install ‘code’ command in PATH
command.
After that you can use:
code filename
to open the filename in Visual Studio.
For more information, click
code --help will give you more information.
For example, code -r filename will open the file in already opened Visual Studio window.

Visual Studio Code "Git not found"

I have Windows10 with the Ubuntu bash and Visual Studio Code.
Every time I start Visual Studio Code it prompts a warning saying:
Git not found. Install it or configure it using the 'git.path' setting
I got git actually installed through the bash terminal:
# which git
/usr/bin/git
How can I instruct Visual Studio Code to use that git installed in the bash terminal?
I have tried through the git.path setting but I am not sure how to set the path to something that is relative to the bash terminal.
If you're running Visual Studio Code on Windows, you also need to install Git for Windows. VsCode currently can't access git on the linux subsystems.

How do I flash zip Visual Studio Android Emulator using console/adb.exe?

How do I flash zip the Visual Studio Android Emulator using console (adb)? I would like to install the cyanogen mod on it to get google apps on.
I have tried dragging and dropping the zip file and it does not allow me. I also checked on this troubleshooting guide but it seems the path is pointing to the correct path of the Android SDK tools already.
I'm using Windows 8.1 with VS 2015 Pro and VS Android Emulator. Note that I was able to do the flashing on my laptop with Windows 10 / VS 2015 Community by just dragging and dropping the zip file so I'm not sure if Windows version has something to do with this.
I found the solution in this blog post.
Download the GApps packages specific for the Android version your emulator is running
Unzip the file
Open an adb command prompt (if you have the Xamarin Tools installed in Visual Studio 2015 open the menu Tools->Android->Android Adb Command Prompt) and navigate where you have unzipped your files.
Go to the system folder in the extracted archive
Execute this set of commands:
adb remount
adb shell chmod 777 /system
adb push . /system

Why does the code . shortcut not work on OSX?

I've tried adding the 'code .' shortcut to launch your current directory in Terminal in Visual Studio Code, but I was promptly returned the following error:
LSGetApplicationForInfo() failed with error -10814 while trying to
determine the application with bundle identifier com.microsoft.VSCode.
Visual Studio Code is installed on my machine successfully.
I'm using OSX Yosemite 10.10.3.
Does anybody know how to get this shortcut to work correctly?
Make sure you have Visual Studio Code 0.3.0 installed. We recently changed the bundle identifier!
This error is because Finder cannot locate Visual Studio Code. I can reproduce the same error on my machine by deleting Visual Studio Code.
Try re-installing VS Code to /Applications and restarting Terminal.
Press command + shift + p
Type: Install 'code' command in path
Choose the option

Resources