当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 周五乐趣:主题我起来!

作者:精品下载站 日期:2024-12-14 07:40:41 浏览:12 分类:玩电脑

周五乐趣:主题我起来!


[玩转系统] 周五乐趣:主题我起来!

如果我没记错的话,在 PowerShell 2.0 中,如果您想自定义外观,则需要将这样的命令添加到 ISE 配置文件脚本中。

# Set font name and size
$psISE.Options.FontName = 'Courier New'
$psISE.Options.FontSize = 16

# Set colors for command pane
$psISE.Options.ConsolePaneBackgroundColor    = '#FF000000'
$psISE.Options.ConsolePaneTextBackgroundColor    = '#FF000000'

# Set colors for script pane
$psise.options.ScriptPaneBackgroundColor    ='#FF000000'

事实上,当时我看到了托马斯·李的一个很酷的剧本。他的脚本是另一个人发布的有关在 PowerShell ISE 中创建看起来像 VIM 的编辑器的 PowerShell 版本。使用它一段时间后,我做了一些更改来处理一些不同的文件类型和情况。这是我的脚本版本。

#modified for powerShell 3.0

<#
.SYNOPSIS
    This script sets an ISE Theme to similar to the old VIM editor.
.DESCRIPTION
    This script sets the key values in $PsIse.Options to values consistent
    with the VIM editor, beloved by many, particularly on the Powershell
    product team. This script is based on Davis Mohundro's blog post ( http://bit.ly/iib5IM),
    updated for RTM of PowerShell V2.0. See also 
.NOTES
    File Name  : Set-ISEThemeVIM.ps1
    Author     : Thomas Lee - [email 
    Requires   : PowerShell Version 2.0 (ISE only)
.LINK
    This script posted to:
        http://www.pshscripts.blogspot.com
 .EXAMPLE
    This script when run resets colours on key panes, including
    colourising tokens in the script pane. Try it and see it...
#>

# PowerShell ISE version of the VIM blackboard theme at 
# http://www.vim.org/scripts/script.php?script_id=2280

# Set font name and size
$psISE.Options.FontName = 'Courier New'
$psISE.Options.FontSize = 16

# Set colours for command pane
$psISE.Options.ConsolePaneBackgroundColor    = '#FF000000'
$psISE.Options.ConsolePaneTextBackgroundColor    = '#FF000000'

# Set colours for script pane
$psise.options.ScriptPaneBackgroundColor    ='#FF000000'

# Set colours for tokens in Script Pane
$psISE.Options.TokenColors['Command'] = '#FFFFFF60'
$psISE.Options.TokenColors['Unknown'] = '#FFFFFFFF'
$psISE.Options.TokenColors['Member'] = '#FFFFFFFF'
$psISE.Options.TokenColors['Position'] = '#FFFFFFFF'
$psISE.Options.TokenColors['GroupEnd'] = '#FFFFFFFF'
$psISE.Options.TokenColors['GroupStart'] = '#FFFFFFFF'
$psISE.Options.TokenColors['LineContinuation'] = '#FFFFFFFF'
$psISE.Options.TokenColors['NewLine'] = '#FFFFFFFF'
$psISE.Options.TokenColors['StatementSeparator'] = '#FFFFFFFF'
$psISE.Options.TokenColors['Comment'] = '#FFAEAEAE'
$psISE.Options.TokenColors['String'] = '#FF00D42D'
$psISE.Options.TokenColors['Keyword'] = '#FFFFDE00'
$psISE.Options.TokenColors['Attribute'] = '#FF84A7C1'
$psISE.Options.TokenColors['Type'] = '#FF84A7C1'
$psISE.Options.TokenColors['Variable'] = '#FF00D42D'
$psISE.Options.TokenColors['CommandParameter'] = '#FFFFDE00'
$psISE.Options.TokenColors['CommandArgument'] = '#FFFFFFFF'
$psISE.Options.TokenColors['Number'] = '#FF98FE1E'

<#
Set the script foreground color to white so text files
display properly.
Set Verbose ForegroundColor to Yellow
Set Debug Foreground color to light purple

-JDH
#>
$psise.options.ScriptPaneForegroundColor= 'White'
$psise.Options.VerboseForegroundColor = '#FFFFFF00'
$psise.Options.DebugForegroundColor ='#FFE500E5'

$psise.Options.XmlTokenColors['Comment'] = '#FF00FF00'   
$psise.Options.XmlTokenColors['CommentDelimiter'] = '#FF00FF00'                                                                 
$psise.Options.XmlTokenColors['ElementName']= '#FFFFFF00'                      
$psise.Options.XmlTokenColors['MarkupExtension']= '#FFFF8C00'
$psise.Options.XmlTokenColors['Attribute']= '#FFFF0000'
$psise.Options.XmlTokenColors['Quote']= '#FFE5E500'                            
$psise.Options.XmlTokenColors['QuotedString']= '#FFFFFFFF'
$psise.Options.XmlTokenColors['Tag']= '#FF00FFFF'                                 
$psise.Options.XmlTokenColors['Text']= '#FFFFFFFF'                          
$psise.Options.XmlTokenColors['CharacterData']= '#FFD4D4D4'

如果在 ISE 中运行该脚本,它将变成这样:

[玩转系统] 周五乐趣:主题我起来!

如果您仍在运行 PowerShell 2.0,则需要使用此脚本。实际上,您也可以在 v3 和 v4 中使用它。或者,在这些版本中您也可以导入主题。主题是一个 ps1xml 文件,其中包含所有必要的外观定义。我继续将 VIM 主题导出到文件中。使用 .ps1xml 扩展名保存此文件,例如 VIM_Theme.ps1xml。然后打开 PowerShell ISE 并转到“工具”-“选项”。在“颜色和字体”选项卡上单击“管理主题”。单击“导入”并获取 ps1xml 文件。这会将其导入 ISE。您可能必须从列表中选择主题,然后单击“确定”以应用它。

您只需执行一次此操作。从现在开始,每次启动 ISE 时,您都会看到这个主题。如果您想摆脱它,“颜色和字体”选项卡上有一个“恢复默认值”按钮。您还可以创建和导出自己的主题。但如果这样做,请务必使用不同的文件类型(包括 .txt 和 .xml)进行测试。还要测试不同的流,例如详细和警告。如果您确实想出了一个很酷的主题,我希望您能与 PowerShell 社区分享。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯