zoukankan      html  css  js  c++  java
  • ScriptBackup--powerShell-alias

     1 # alias
     2 param([string]$Command, $AliasKeys)
     3 
     4 
     5 # 使用 DarkRed 背景色 White 前景色 不换行显示
     6 function DisplayErrorMsg($Msg) {
     7     $Msg | Write-Host -NoNewLine -ForegroundColor White -BackgroundColor DarkRed
     8 }
     9 
    10 
    11 # 简单的说明
    12 function DisplayHelp() {
    13     ( 'Usage:',
    14       'set aliases:',
    15       '    scriptName set <AliasKeys>',
    16       'list all usable aliasKeys:',
    17       '    scriptName list',
    18       "`n") | Write-Host
    19 }
    20 
    21 
    22 # 显示可设置的别名列表
    23 function DisplayList() {
    24     ('curl', 'python3') | Write-Host
    25 }
    26 
    27 
    28 # 设置别名
    29 function SetAliases() {
    30     switch($AliasKeys) {
    31         'curl' { set-alias curl E:/program.d/curl-7.67.0-win64-mingw/bin/curl.exe;
    32                  'curl setted';
    33         }
    34         'python3' { set-alias python3 E:/program.d/python-3.8/python.exe;
    35                     set-alias pip3 E:/program.d/python-3.8/Scripts/pip3.exe;
    36                     set-alias http E:/program.d/python-3.8/Scripts/http.exe;
    37                     set-alias https E:/program.d/python-3.8/Scripts/https.exe;
    38                     set-alias idle E:/program.d/python-3.8/Lib/idlelib/idle.pyw;
    39                     'python3 pip3 http https idle setted'
    40         }
    41         default { DisplayErrorMsg ('Unknown alias key "', $_, '"', "`n") }
    42     }
    43 }
    44 
    45 
    46 # run
    47 switch($Command) {
    48     'set' { . SetAliases ; break; }
    49     'list' { DisplayList }
    50     '--help' { DisplayHelp }
    51     default { DisplayErrorMsg ('Unknown command "', $_, '"',
    52                                "`nfor help call scriptName --help`n`n"
    53                               ) 
    54     }
    55 }

    --------- THE END ---------

  • 相关阅读:
    期权波动率模型及交易策略分析
    k阶原点距和k阶中心距各是说明什么数字特征
    在Linux中监视IO性能
    NUMA微架构
    Web网站的几个QPS
    Elasticsearch与Solr 选型
    相关连接(后续更新)
    linux_基本命令使用(后续更新)
    centos7.5安装kafka(支持外部连接)
    centos7.5单机安装安装zookeeper
  • 原文地址:https://www.cnblogs.com/shadow-abyss/p/13050203.html
Copyright © 2011-2022 走看看