首页 > 其他分享 >本人的pwsh配置

本人的pwsh配置

时间:2023-02-26 15:33:54浏览次数:32  
标签:Set Addr 配置 Value proxy Net null 本人 pwsh

oh-my-posh init pwsh --config 'C:\Users\Shanghao\AppData\Local\Programs\oh-my-posh\themes\onehalf.minimal.omp.json' | Invoke-Expression 
# Set-Proxy command

Function setproxy() {
    Param(
        $Addr ="127.0.0.1:23524",
        [switch]$ApplyToSystem
    )
    
    $env:HTTP_PROXY = $Addr;
    $env:HTTPS_PROXY = $Addr; 
    $env:http_proxy = $Addr;
    $env:https_proxy = $Addr;
  
    if ($addr -eq $null) {
        [Net.WebRequest]::DefaultWebProxy = New-Object Net.WebProxy;
        if ($ApplyToSystem) { SetSystemProxy $null; }
        Write-Output "Successful unset all proxy variable";
    }
    else {
        [Net.WebRequest]::DefaultWebProxy = New-Object Net.WebProxy $Addr;
        if ($ApplyToSystem) {
            $matchedResult = ValidHttpProxyFormat $Addr;
            # Matched result: [URL Without Protocol][Input String]
            if (-not ($matchedResult -eq $null)) {
                SetSystemProxy $matchedResult.1;
            }
        }
        Write-Output "Successful set proxy as $Addr";
    }
}

Function SetSystemProxy($Addr = $null) {
    Write-Output $Addr
    $proxyReg = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings";

    if ($Addr -eq $null) {
        Set-ItemProperty -Path $proxyReg -Name ProxyEnable -Value 0;
        return;
    }
    Set-ItemProperty -Path $proxyReg -Name ProxyServer -Value $Addr;
    Set-ItemProperty -Path $proxyReg -Name ProxyEnable -Value 1;
}

Function ValidHttpProxyFormat ($Addr) {
    $regex = "(?:https?:\/\/)(\w+(?:.\w+)*(?::\d+)?)";
    $result = $Addr -match $regex;
    if ($result -eq $false) {
        throw [System.ArgumentException]"The input $Addr is not a valid HTTP proxy URI.";
    }

    return $Matches;
}
Function resetproxy (){
	[Net.WebRequest]::DefaultWebProxy = New-Object Net.WebProxy;
        if ($ApplyToSystem) { SetSystemProxy $null; }
        Write-Output "Successful unset all proxy variable";
        return;	
}

Set-Alias -Name set-proxy -Value setproxy

function bbdownaf() {
    param([string] $pars)
    bbdown --encoding-priority "av1,hevc,avc" $pars
}

Set-Alias -Name bdown -Value bbdownaf

  

标签:Set,Addr,配置,Value,proxy,Net,null,本人,pwsh
From: https://www.cnblogs.com/rapidgrow/p/17156783.html

相关文章

  • rocketmq集群配置
    rocketmq2m-2s-sync部署1、下载jdk-8u361-linux-x64.tar.gzrocketmq-all-5.1.0-bin-release.zip#/etc/profile环境变量:exportJAVA_HOME=/usr/local/jdk1.8.0_361e......
  • Mysql中关于查询日志的配置详解
    查询日志MySQL中的查询日志保存在文本文件中,能够记录MySQL中的所有数据操作。开启查询日志MySQL默认情况下没有开启查询日志,如果需要开启查询日志,则需要在​​my.cnf​​​......
  • stm32f407探索者开发板(十七)——串口寄存器库函数配置方法
    文章目录​​一、STM32串口常用寄存器和库函数​​​​1.1常用的串口寄存器​​​​1.2串口相关的库函数​​​​1.3状态寄存器(USART_SR)​​​​1.4数据寄存器(USART_D......
  • VUEX getters 配置项
      获取bigSum<template><divid="app"><h1>当前总数为:{{$store.state.nbr}}</h1><h2>放大十倍总数为:{{$store.getters.bigSum}}</h2><select......
  • 配置PHP7环境
    1.准备好安装包wampserver和PhpStorm2.先点击wampserver3.1.9_x64.exe    点击install 进度条满了   选择你想用的浏览器和文本  完成后......
  • maven plugin配置说明
    例子如下:1、maven-clean-plugin插件执行mvnclean或mvnclean:clean来调用这个插件清理项目。注意下面日志:DeletingD:\selfProjects\common-project-spring-boot\c......
  • 【Mybatis】【配置文件解析】【二】Mybatis源码解析-别名、环境变量、插件、ObjectFac
    1 前言在上一节我们分析了properties和settings,这节我们分析下别名、环境变量、插件以及ObjectFactory的解析。2 源码分析2.1 解析typeAliasestypeAliases标签......
  • 全局配置-tabBar
           ......
  • 全局配置
                  ......
  • SpringBoot32 - 自动配置工作流程
    自动配置工作流程​ 自动配置是springboot技术非常好用的核心因素,这里需要先复习一下有关spring技术中bean加载相关的知识。bean的8种加载方式方式一:配置文件+<bean/>......