About why after installing vscode, entering the command code in cmd can quickly open the vscode client
In fact, I have always been entangled with the environment variable. It feels very mysterious, but every time I use it, I feel amazing and want to explore. The explanations on the Internet are somewhat abstract, and the real person is confused by various arguments.
However, after learning some bash knowledge, Linux knowledge, and installing a lot of environments, I finally happened to understand this mysterious environment variable in practice again and again.
Article directory
foreword
Let's first understand what is an environment variable
The core content is: when the system is asked to run a program without telling it the full path where the program is located, the system should not only look for the program under the current directory, but also go to the path specified in path to find it
. When cmd runs the gcc command, windows actually traverses my environment variables and runs the gcc.exe executable file under the F:\mingw64\bin path.
1. Look at the phenomenon
After understanding the content of the preface, it is easy to understand the reason for how vscode implements cmd startup.
First look at the phenomenon, I entered the code command in cmd:
vscode opened
2. The principle of quick opening of vscode in cmd
This is a content related to environment variables, so we first open the configuration interface of environment variables.
It can be seen in the PATH of the system environment variable, the following path (provided that vscode is installed, everyone’s path may be different)
and then we enter this path, we can see that the code command is already waiting for us here.
Let’s change the extension name of code.cmd to txt and open it, and look at the content. We
can find that it will not open if we enter the code at this time.
Let’s turn off the echo first (you can learn about batch processing about what echo is ), Then modify the name of the extension to cmd, and run it
. It can be seen that the reason for entering the code command to open vscode is because some of the above statements are executed.
Then I took a brief look at the code file above, well, it feels like a classic Linux script, and it should be used in Linux.
Summarize
Because of limited understanding, I will not explain too much.
The specific content of the sentence is not very clear for the time being, and the follow-up study will be completed in depth. Of course, everyone is welcome to discuss together in the comment area.
If you feel that you have learned something, you can also like and support it!