比PowerShell.exe更好的PowerShell主机?

sco*_*obi 8 powershell

我一直在尝试从我最喜欢的4NT切换到PowerShell.它缺少4NT在过去20年中添加的许多细节(我是一个老的4DOS用户).

例如,在4NT中,如果键入几个字母然后按向上/向下,则历史列表将按您键入的内容进行过滤.向上/向下翻页会弹出所有匹配项,您可以浏览它们.全部在控制台窗口空间,没有GUI.这是我想念的大节省时间.powershell.exe还有很多其他的东西丢失了.

有没有替代powershell.exe可能有这样的功能,真正利用控制台环境?我意识到有很多基于GUI的工具将PowerShell作为一个窗格嵌入,但我真的对cmd.exe/4nt.exe替换感兴趣,它仍然是一个100%的控制台应用程序(可能是一个选项对话框或随你).

Kei*_*ill 10

约书亚已经提到了F7.您还可以通过键入一些命令并按F8 - 重复F8循环匹配(参见about_history),在Powershell.exe中进行部分历史记录匹配.除了人们通常知道的还有一些行编辑功能.这些内容记录在about_line_editing帮助主题中.尽管如此,PowerShell控制台主机中的行编辑还是有所不足.FWIW我所知道的所有其他主机都是基于GUI的.

BTW我多年来一直是4NT用户(以及Korn shell用户).即使在4NT中发现了一些缺少的设施,我发现PowerShell是一个更强大的shell,作为开发人员,所有"语言"位都很容易适应和使用.我从来没有真正喜欢Korn的外壳if / ficase / esac陈述 - 只是用错误的方式磨砺了我对aethestics的感觉.:-)在PowerShell中你可以用你的历史做很酷的事情:

# Search history using regex
PS> get-history -count 999 | select-string '\b(fl|ft)\b'

# Look at your shell usage pattern by hour of day - Name column is hour of day
PS> ghy | group {$_.StartExecutionTime.Hour}

Count Name       Group
----- ----       -----
   30 21         {$allargs, echoargs -arg $allArgs, echoargs $a
    2 22         {ghy | group {$_.StartExecutionTime.Hour}, ls}

# Look at commands in terms of execution time (sorted descending)
PS> ghy | Select CommandLine,Id,`
      @{n='ExecutionTime';e={$_.EndExecutionTime - $_.StartExecutionTime}} | 
      Sort ExecutionTime -Desc 

CommandLine                                        Id ExecutionTime
-----------                                        -- -------------
ls C:\Windows\System32 ...                         94 00:00:06.0233445
ls C:\Windows\System32\...                         93 00:00:01.1360650
gps | fl                                           89 00:00:00.5780330
dir                                                80 00:00:00.0950054
ls                                                 83 00:00:00.0870050
ghy | Select CommandLin...                         92 00:00:00.0810046
dir                                                67 00:00:00.0750042
ghy | Select CommandLin...                         95 00:00:00.0580034
ghy | Select CommandLin...                         96 00:00:00.0570032
ghy | Select CommandLin...                         97 00:00:00.0540031
dir                                                76 00:00:00.0500029
get-history -count 999 ...                         88 00:00:00.0420024
Run Code Online (Sandbox Code Playgroud)

  • 对于粘贴,尝试Alt + Space,E,P - 俗气,但它的工作原理. (2认同)

Ryn*_*ant 5

也可以使用选项卡查看命令历史记录#.

使用的一个缺点F8是它区分大小写,它只匹配命令的开头.使用#<partial match><tab>不区分大小写,并且将匹配先前命令中任何位置的文本.

如果您具有以下命令历史记录:

# 1
$np = Start-Process notepad -PassThru
# 2
$np| get-process
# 3
$np| Stop-Process
Run Code Online (Sandbox Code Playgroud)

#pr重复键入然后选项卡将循环显示1,2和3.

#st重复键入然后选项卡将循环显示1和3.

仅使用#将匹配所有历史记录.

#也可以在输入命令的一部分后使用.如果您的历史是:

'notepad'
select *
Run Code Online (Sandbox Code Playgroud)

你可以打字Get-Process #n<tab>| #s<tab>来获取Get-Process 'notepad'| select *