Set-proxy-mac.sh

来自OSSmedia
Brucekomike讨论 | 贡献2025年1月6日 (一) 02:47的版本 (创建页面,内容为“#!/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…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
  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 words
   words=("${(f)$(compgen -c)}")
   _describe 'command' words

}

_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."