强大的Cmder

why

  1. 漂亮,包装并美化了各个shell
  2. 带task功能,能记忆,能执行脚本
  3. 配合win10的bash,能实现类似xshell的功能

注意点

需要注意的一点,Cmder来源于另外一个项目ConEmu,因此很多的设置介绍都在这个项目下面。比如说task设置的语法

Task设置介绍

简介

在settings->Startup下面。添加一个task后,可以设置名称,名称按group分类。

比如我设置两个任务,bash::pi,bash::test。

在显示task时,这两个会放在一个task group里面(名字为bash),这个group里面有两个任务,一个叫pi,一个叫test。

Task parameters

这里一般就是设置icon

  1. /icon 可以设置icon
  2. /dir 设置启动目录

Commands

  1. 第一个参数为要启动的app,后面为要带的参数,比如
PowerShell -ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''" -new_console:d:"%USERPROFILE%"

app为powershell,参数为-ExecutionPolicy Bypass -NoLogo -NoProfile -NoExit -Command "Invoke-Expression '. ''%ConEmuDir%\..\profile.ps1'''"

  1. -new_console - cur_console为cmder的指令(实际是ConEmu的),用来指定窗口的特征。可以指定目录,layout,等等详细参考ConEmu的介绍。
-new_console[:switches]
   or
-cur_console[:switches]
   a - RunAs shell verb (as Admin on Vista+, user/pwd in Win2k and WinXP)
   b - create background tab
   c[0] - force enable [silent] ‘Press Enter or Esc to close console’
   C:"<iconfile>" - specify icon used in tab
   d:"<dir>" - specify working directory
   f - force starting console active, useful when starting several consoles simultaneously
   h<height> - i.e., h0 - turn buffer off, h9999 - switch to 9999 lines
   i - don't inject ConEmuHk into starting process
   I - (GuiMacro only) forces inheriting of root process contents, like ‘Duplicate root’ feature
   m:/mnt - defines ‘/mnt’ prefix for Unix-path conversion
   n - disable ‘Press Enter or Esc to close console’
   o - don't enable ‘Long console output’ when starting command from Far Manager
   p[N] - pty modes, N - bitmask: 1 - XTermKeys, 2 - BrPaste, 4 - AppCursorKeys; default is 5 (1+4)
   P:"<palettename>" - set fixed palette for tab
   r - run as restricted user
   R - force start hooks server in the parent process
   s[<SplitTab>T][<Percents>](H|V) - run new console in a split
   t:"<tabname>" - rename new created tab
   u - ConEmu choose user dialog
   u:"<user>:<pwd>" - specify user/pwd in args
   w - Enable ‘Overwrite’ mode in command prompt by default
   W:"<tabwallpaper>" - use specified wallpaper for the tab
   z - Don't use ‘Default terminal‘ feature for this command

最常用的就是生成新窗口,比如

在当前窗口下面生成一个新的cmd窗口

cmd -new_console:sV

在当前窗口右边生成一个新的cmd窗口

cmd -new_console:sH

如何设置bash启动ssh

使用xshell时,最方便的是记忆ssh地址,一键ssh。这里使用cmder加bash完成。

基本设置

bash -new_console:i /mnt/e/pi/pi.sh

这条指令之后,即可执行pi.sh,这个sh里面只是简单的配置ssh。

指定layout

bash -new_console:sVi /mnt/e/pi/pi.sh

指定工作目录(无用)

bash -new_console:sVi:d /mnt/e/pi/pi.sh E:/pi

目前上述方法还有bug。如果采用上述方式ssh,会导致cmder无法记忆之前的命令,也就无法用上下方向键翻历史记录。

替代方案

bash -new_console:sHh999d:E:\pi
  • sH : 指定新窗口在右边
  • h999 : buffer大小999,即可以记忆这么多条指令
  • d:E:\pi : 指定工作目录在E:\pi下面。这里需要注意d:E:\pi是连着的,不能有空格

这样就是开启了bash,并设置工作目录到想要的目录下面,然后ssh的话直接调用脚本即可。

posted @ 2017-10-08 11:08  Weyne  阅读(1015)  评论(0编辑  收藏  举报