2

Conemu, Msys2 工具整合,提升windows下控制台工作效率

 1 year ago
source link: https://www.cnblogs.com/piepie/p/8474263.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Conemu, Msys2 工具整合,提升windows下控制台工作效率

与windows cmd相比较git-bash这类的console工具好用很多,但是git-bash的命令和功能相对简单,功能扩展起来不方便,git-bash本身也是基于msys的。

昨天发现使用Msys2 和 Conemu 这两个工具,组合起来功能更加强大。 Conemu支持tab页面,以及分屏。

具体步骤:

1、msys2 安装, 这个比较简单, 从http://www.msys2.org/  下载最新的安装包

msys2 可以通过 pacman 命令安装工具,这个功能比较爽。

一般还需要设置pacman的源,改成国内中科大的。

修改 msys64\etc\pacman.d 目录下有三个文件。 
mirrorlist.msys 

Server = http://mirrors.ustc.edu.cn/msys2/msys/$arch/
Server = http://repo.msys2.org/msys/$arch
Server = http://downloads.sourceforge.net/project/msys2/REPOS/MSYS2/$arch
Server = http://www2.futureware.at/~nickoe/msys2-mirror/msys/$arch/

mirrorlist.mingw64 

Server = http://mirrors.ustc.edu.cn/msys2/mingw/x86_64/
Server = http://repo.msys2.org/mingw/x86_64
Server = http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/x86_64
Server = http://www2.futureware.at/~nickoe/msys2-mirror/x86_64/
Server = http://mirror.bit.edu.cn/msys2/REPOS/

mirrorlist.mingw32

Server = http://mirrors.ustc.edu.cn/msys2/mingw/i686/
Server = http://repo.msys2.org/mingw/i686
Server = http://downloads.sourceforge.net/project/msys2/REPOS/MINGW/i686
Server = http://www2.futureware.at/~nickoe/msys2-mirror/i686/

启动 msys2 终端并使用 pacman -Syu 更新

> pacman -Syu
> pacman -Su

可以通过pacman 暗转 git 等工具, 这样我们的终端就与git-bash由类似的功能了。

修改 C:\msys64\msys2.ini 中的  MSYS2_PATH_TYPE=inherit  ,可以让打开的控制台继承windows的PATH环境变量。

2、 添加到右键菜单中

安装git-bash后,使用右键菜单是可以方便的打开bash窗口并到该目录下,这个功能十分方便。

通过修改注册表也能实现该功能。

[ HKEY_CLASSES_ROOT\Directory\background\shell ] 添加项 msys2, 再在msys2下添加command项

command项的值为  c:\msys64\msys2_shell.bat -here  

615787-20180226171940955-1487598615.png

 

这样就可以使用  右键菜单来启动 bash窗口了。

3、 安装 Conemu , 从https://conemu.github.io/ 下载安装包进行安装。

Conemu直接解压就能使用了,默认情况下 Conemu能够找到msys2的安装位置(一般在C:\msys64)

可以通过工具栏上的绿色加号启动不同类型的终端,选择 Bash:msys2-64,就可以启动msys2的终端。

615787-20180226173131806-977109124.png

不过启动后的终端视乎有个bug,backspace键不能删除字符串,为了解决这个问题,整了一下午,这么好的工具要是因为这么个原因不能用,就太可惜了。最终通过修改Comenu中的配置成功解决此问题。

615787-20180226173939255-1484799620.png

打开Conemu的setting页, 在Task中 选择{Bash:Msys2-64} ,修改命令为

set  MSYS2_PATH_TYPE=inherit &  set CHERE_INVOKING=1  & set "PATH=C:\msys64\usr\bin;%PATH%" & %ConEmuBaseDirShort%\conemu-msys2-64.exe  -t xterm  -new_console:p C:\msys64\usr\bin\bash.exe --login -i -new_console:C:"C:\msys64\msys2.ico"

其中 set  MSYS2_PATH_TYPE=inherit  可以让启动的窗口继承windows PATH

       \conemu-msys2-64.exe  -t xterm     增加了 -t xterm 参数, 解决了backspace不能使用的问题。

4、将Conemu 添加到右键菜单中,其中command 命令为: D:\dev\ConEmu\ConEmu.exe -Here   需要加上 -Here参数

615787-20180226175015932-797713744.png

通过整合Conemu,msys2这两个工具,可以替代git-bash等工具。

以下是Conemu的分屏截图

615787-20180226175752730-222103035.png

 

615787-20180226175826173-1928144871.png

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK