具有类似rc的文件的PowerShell配置
发布时间:2020-12-14 04:07:57 所属栏目:Windows 来源:网络整理
导读:我应该编写什么脚本以及在哪里定义: ll =“ls -l”的别名 alias / function cd =“original cd; ll” 所以,我的问题是如何将Windows 7上的Power Shell的rc文件放在哪里以及如何将ll别名为ls -l和cd为cd;二? 在键入$profile时,在power shell指向的位置创建
|
我应该编写什么脚本以及在哪里定义:
> ll =“ls -l”的别名 所以,我的问题是如何将Windows 7上的Power Shell的rc文件放在哪里以及如何将ll别名为ls -l和cd为cd;二?
在键入$profile时,在power shell指向的位置创建一个文件,如果不存在则按Enter键. (欲了解更多信息,请查看
here.)
另外我在我的系统中的powershell.exe旁边找到了很多很好的例子,有一个示例文件夹,其中有一个名为profile.ps1的文件,代码如下: set-alias cat get-content
set-alias cd set-location
set-alias clear clear-host
set-alias cp copy-item
set-alias h get-history
set-alias history get-history
set-alias kill stop-process
set-alias lp out-printer
set-alias ls get-childitem
set-alias mount new-mshdrive
set-alias mv move-item
set-alias popd pop-location
set-alias ps get-process
set-alias pushd push-location
set-alias pwd get-location
set-alias r invoke-history
set-alias rm remove-item
set-alias rmdir remove-item
set-alias echo write-output
set-alias cls clear-host
set-alias chdir set-location
set-alias copy copy-item
set-alias del remove-item
set-alias dir get-childitem
set-alias erase remove-item
set-alias move move-item
set-alias rd remove-item
set-alias ren rename-item
set-alias set set-variable
set-alias type get-content
function help
{
get-help $args[0] | out-host -paging
}
function man
{
get-help $args[0] | out-host -paging
}
function mkdir
{
new-item -type directory -path $args
}
function md
{
new-item -type directory -path $args
}
function prompt
{
"PS " + $(get-location) + "> "
}
& {
for ($i = 0; $i -lt 26; $i++)
{
$funcname = ([System.Char]($i+65)) + ':'
$str = "function global:$funcname { set-location $funcname } "
invoke-expression $str
}
}
还要考虑到以下问题.执行位于$profile中的文件时,您可能会遇到以下错误:
解: PS C:WindowsSystem32> Get-ExecutionPolicy Restricted PS C:WindowsSystem32> 要更改执行策略以允许PowerShell从本地文件执行脚本,请运行以下命令: PS C:WindowsSystem32> Set-Executionpolicy RemoteSigned -Scope CurrentUser (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- windows-7 – 为什么Windows 7上的FIND会出现“拒
- 如何在Windows中的python中将输出定向到txt文件
- windows – 有没有办法在SVN repo中设置文件.在结
- ms-access – PDF缩略图和Microsoft Access中的预
- windows – 即使AD域控制器关闭,为什么我还能登录
- windows-8 – 如何将文件拖到Windows 8上以管理员
- DLL – 升级到1.1.0后无法加载文件或程序集“Mic
- windows C++如何根据文本字符串计算其绘制需占用
- windows – goapp serve:无法找到dev_appserver
- 什么被认为是Windows服务器的“SSH”?
热点阅读
