Set-proxy-mac.sh:修订间差异

来自OSSmedia
(创建页面,内容为“#!/bin/bash # Create proxy.sh cat << 'EOF' | sudo tee /usr/local/bin/proxy.sh > /dev/null #!/bin/bash export ProIP="http://127.0.0.1:2080" export http_proxy="$ProIP" export https_proxy="$ProIP" # Execute the command passed as arguments "$@" EOF # Make proxy.sh executable sudo chmod +x /usr/local/bin/proxy.sh # Add Zsh completion for proxy.sh mkdir -p ~/.zsh/completion cat << 'EOF' > ~/.zsh/completion/_proxy.sh #compdef proxy.sh _proxy_sh() { local wor…”)
 
无编辑摘要
 
第22行: 第22行:


_proxy_sh() {
_proxy_sh() {
    local words
  local -a args
    words=("${(f)$(compgen -c)}")
  args=(
     _describe 'command' words
     '*:: :_normal'
  )
  _arguments -s -S $args
}
}



2025年1月6日 (一) 03:03的最新版本

  1. !/bin/bash
  1. Create proxy.sh

cat << 'EOF' | sudo tee /usr/local/bin/proxy.sh > /dev/null

  1. !/bin/bash

export ProIP="http://127.0.0.1:2080" export http_proxy="$ProIP" export https_proxy="$ProIP"

  1. Execute the command passed as arguments

"$@" EOF

  1. Make proxy.sh executable

sudo chmod +x /usr/local/bin/proxy.sh

  1. Add Zsh completion for proxy.sh

mkdir -p ~/.zsh/completion

cat << 'EOF' > ~/.zsh/completion/_proxy.sh

  1. compdef proxy.sh

_proxy_sh() {

 local -a args
 args=(
   '*:: :_normal'
 )
 _arguments -s -S $args

}

_proxy_sh "$@" EOF

  1. Ensure the completion directory is sourced in .zshrc

if ! grep -q "fpath+=~/.zsh/completion" ~/.zshrc; then

   echo "fpath+=(~/.zsh/completion)" >> ~/.zshrc
   echo "autoload -U compinit && compinit" >> ~/.zshrc

fi

echo "proxy.sh setup complete with Zsh completion."