在windows下搭建编程环境git+vscode安装配置教程

时间:2020-09-24 20:56:43   收藏:0   阅读:64

Linux终端式bash,win10的终端是powershell或命令提示符,两种终端的语言相差较大,尤其是一些斜杠/和反斜杠\,单引号‘和双引号"的区别很难记忆。因此,git bash是一款用Linux的bash语言控制windows的解决方案(bash for windows),对于windows的脚本编写,vscode是一个非常强大的工具,比visual studio,pycharm适用的语言更多,和sublime相比,能够运行各种脚本。但是缺点是内存和磁盘占用更大。因此,对于没有win+linux双系统,windows上没有Linux子系统的用户来说,git+vscode是一个非常友好的bash for windows的编程环境组合。

git安装配置过程

1.下载。下载地址有两个https://gitforwindows.org/或者https://git-scm.com/download/win都可。

2.安装路径选择,选择要安装的位置,默认为/bin/bash,那么每次shell脚本开头的声明为#!/bin/bash。如果我的bash安装在D:\tools\git\Git\bin\bash的话,那么每个shell脚本开头的声明需要改写为#!/d/tools/git/Git/bin/bash

技术图片

3.安装选项。勾选Windows Explorer integration, Git LFS, Associate .git* configuration files with the default text editor, Associate .sh files to be run with Bash

 

 技术图片

4.在开始菜单中创建git,点击next

技术图片

5.选择vim作为git默认的编辑器,点击next

技术图片

6.调整环境变量,我选择的是use Git from Git bash only,使用git自带的命令行工具。如果选择git from the command line and also from 3rd-party software则代表选择windows命令行,点击next

技术图片

7.选择http transport backend,我选择Use the OpenSSL library,点击next

技术图片

8.配置换行符设置,我选择checkout windows-style, commit Unix-style line endings自动转换文件中的换行符,点击next

技术图片

9.配置终端仿真器,我选择MinYY默认的MSYS2终端,点击next

技术图片

10.选择默认的git pull行为,我选择默认,点击next

技术图片

 

 11.选择凭据存储credential helper,我选择git credential manager,点击next

技术图片

 

 12.配置外部选项,勾选enable file system caching和enable symbolic links和enable experimental support for pseudo consoles,点击install。

技术图片

 

 安装完成,打开如下图所示,跳转到releaseNote.html中file:///D:/tools/git/Git/ReleaseNotes.html

技术图片

 

 git的可用模块共三个,一种是git GUI如下图,一种git bash模拟Linux终端,一种git cmd模拟windows终端。

技术图片

 

 

vscode安装配置过程

脚本式编程我推荐vscode,还可以将各种终端植入vscode中,将代码在vscode中直接运行。植入方法见攻略。

首先下载地址https://vscode.en.softonic.com/https://code.visualstudio.com/都可。

双击安装,同意协议,选择安装路径,添加到开始菜单的程序中,勾选添加到PATH,点击安装即可。

vscode的配置过程包括安装拓展extension和植入终端。

我安装的拓展包括:简体中文Chinese (Simplified) Language Pack for Visual Studio Code,fortran程序颜色标注

植入的终端是git bash:点击file-preferences-settings,然后搜索“terminal.intergrated.shell.windows”,点击下面的edit in setting.json,在其中输入git的路径即可

{
    "terminal.integrated.shell.windows": "D:\\tools\\git\\Git\\bin\\bash.exe"
}
#注意:为了避免将\识别为转义字符,我们将使用双反斜杠\\来书写bash.exe的路径。

技术图片

 

 

然后点击快捷键ctrl+~即可出现已经植入的git bash作为terminal了。在terminal右侧的选项中还可以选择默认的shell(select default shell),其中可以选择Command Prompt,Windows PowerShell,还可以选择WSL shell。

技术图片

 

 

配置完成

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!