工欲善其事,必先利其器...
platformio-ide-terminal,在之前的Atom配置中已经详细介绍了,此插件默认使用的是Windows自带的PowerShell。platformio-ide-terminal基本两个命令就够用了Set-Alias $name $command——设置aliasdel alias:$name ——删除相应的aliasfunction $FUNC_NAME ($A1,$A2,...$AN[="default value of $AN"]){codes, one command per line}-来指定参数,如git commit -m "..."中的-m即是指定内部参数$m的值为后面的字符串。在函数体内用$A1的形式调用参数。sum 12 34中的12 34就可以在sum的函数体中使用$args[0]和$args[1]调用。Set-Alias和Function永久生效$home/Documents/WindowsPowerShell/。其中$home是你的用户文件夹.../users/XXX/$home/Documents/WindowsPowerShell/下建一个名为Modules的文件夹,然后在这个文件夹中放入你自己的module。module是你自己定义的函数、变量、配置等的集合,就如同python中的import的包,你的module中包含了你需要的各种东西。当然目前也不需要用到很多,暂时认为一个module是一个内有各种function的文件夹即可。$home/Documents/WindowsPowerShell/Modules/mymodule/下建文件,命名为mymodule.psm1(mymodule是你的module名字,自行替换),在这个文件中写上你所有实现的函数。比如function gpush($b="master",$m="auto_push"){
git checkout $b
git add .
git status
git commit -m $m
git push origin $b
}Import-Module mymodule,就可以将mymodule加入到当前会话的配置,这个时候使用gpush就可以一口气push了~ 但是关闭后重新打开,就又不行了。$home/Documents/WindowsPowerShell/下新建文件profile.ps1,写入Import-Module mymodule
Import-Module Microsoft.PowerShell.Management
Get-Module重新打开PowerShell,Get-Module让PowerShell一打开就显示出加载好的Modules,自定义命令玩起来~mymodule.psm1然后重启PowerShell即可。Set-ExecutionPolicy RemoteSigned -Scope CurrentUser来改变当前用户的权限。Copyright © 2015-2016 zhyack. All Rights Reserved.
如对文章有任何疑问,请移步问题聚集区一览~