shell 代理设置命令提取到 .bash_proxy.sh 文件中
This commit is contained in:
50
dot/.bash_proxy.sh
Normal file
50
dot/.bash_proxy.sh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
HTTP_PROXY="http://192.168.1.13:20172"
|
||||||
|
SOCKS_PROXY="socks5://192.168.1.13:20170"
|
||||||
|
|
||||||
|
set-shell-proxy() {
|
||||||
|
export http_proxy="$HTTP_PROXY"
|
||||||
|
export https_proxy="$HTTP_PROXY"
|
||||||
|
}
|
||||||
|
|
||||||
|
unset-shell-proxy() {
|
||||||
|
unset http_proxy
|
||||||
|
unset https_proxy
|
||||||
|
}
|
||||||
|
|
||||||
|
set-git-proxy() {
|
||||||
|
prefix_cmd=""
|
||||||
|
flag="--global"
|
||||||
|
if [[ "$1" == "-s" ]]; then
|
||||||
|
prefix_cmd="sudo"
|
||||||
|
flag="--system"
|
||||||
|
elif [[ "$1" == "-l" ]]; then
|
||||||
|
flag="--local"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$prefix_cmd git config $flag http.proxy $HTTP_PROXY
|
||||||
|
$prefix_cmd git config $flag http.sslVerify false
|
||||||
|
}
|
||||||
|
|
||||||
|
unset-git-proxy() {
|
||||||
|
prefix_cmd=""
|
||||||
|
flag="--global"
|
||||||
|
if [[ "$1" == "-s" ]]; then
|
||||||
|
prefix_cmd="sudo"
|
||||||
|
flag="--system"
|
||||||
|
elif [[ "$1" == "-l" ]]; then
|
||||||
|
flag="--local"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$prefix_cmd git config $flag --unset http.proxy
|
||||||
|
$prefix_cmd git config $flag --unset http.sslVerify
|
||||||
|
}
|
||||||
|
|
||||||
|
set-npm-proxy() {
|
||||||
|
npm config set proxy $HTTP_PROXY
|
||||||
|
npm config set https-proxy $HTTP_PROXY
|
||||||
|
}
|
||||||
|
|
||||||
|
unset-npm-proxy() {
|
||||||
|
npm config delete proxy
|
||||||
|
npm config delete https-proxy
|
||||||
|
}
|
||||||
54
dot/.bashrc
54
dot/.bashrc
@@ -30,54 +30,10 @@ alias la="ls -a"
|
|||||||
alias lh="ls -lh"
|
alias lh="ls -lh"
|
||||||
alias lha="ls -lha"
|
alias lha="ls -lha"
|
||||||
|
|
||||||
|
PROXY_SHELL_FILE="$(realpath ~/.bash_proxy.sh)"
|
||||||
set-proxy() {
|
if [[ -e $PROXY_SHELL_FILE ]] ; then
|
||||||
export http_proxy=http://127.0.0.1:8118
|
. $PROXY_SHELL_FILE
|
||||||
export https_proxy=http://127.0.0.1:8118
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
unset-proxy() {
|
|
||||||
unset http_proxy
|
|
||||||
unset https_proxy
|
|
||||||
}
|
|
||||||
|
|
||||||
set-git-proxy() {
|
|
||||||
prefix_cmd=""
|
|
||||||
flag="--global"
|
|
||||||
if [[ "$1" == "-s" ]]; then
|
|
||||||
prefix_cmd="sudo"
|
|
||||||
flag="--system"
|
|
||||||
elif [[ "$1" == "-l" ]]; then
|
|
||||||
flag="--local"
|
|
||||||
fi
|
|
||||||
|
|
||||||
$prefix_cmd git config $flag http.proxy http://127.0.0.1:8118
|
|
||||||
$prefix_cmd git config $flag http.sslVerify false
|
|
||||||
}
|
|
||||||
|
|
||||||
unset-git-proxy() {
|
|
||||||
prefix_cmd=""
|
|
||||||
flag="--global"
|
|
||||||
if [[ "$1" == "-s" ]]; then
|
|
||||||
prefix_cmd="sudo"
|
|
||||||
flag="--system"
|
|
||||||
elif [[ "$1" == "-l" ]]; then
|
|
||||||
flag="--local"
|
|
||||||
fi
|
|
||||||
|
|
||||||
$prefix_cmd git config $flag --unset http.proxy
|
|
||||||
$prefix_cmd git config $flag --unset http.sslVerify
|
|
||||||
}
|
|
||||||
|
|
||||||
set-npm-proxy() {
|
|
||||||
npm config set proxy http://127.0.0.1:8118
|
|
||||||
npm config set https-proxy http://127.0.0.1:8118
|
|
||||||
}
|
|
||||||
|
|
||||||
unset-npm-proxy() {
|
|
||||||
npm config delete proxy
|
|
||||||
npm config delete https-proxy
|
|
||||||
}
|
|
||||||
|
|
||||||
if [[ "${TERM}" != "tmux-256color" ]] && [[ -x $(type -p tmux) ]]; then
|
if [[ "${TERM}" != "tmux-256color" ]] && [[ -x $(type -p tmux) ]]; then
|
||||||
tmux
|
tmux
|
||||||
@@ -91,7 +47,7 @@ alias pip='function _pip() {
|
|||||||
};_pip'
|
};_pip'
|
||||||
|
|
||||||
# pnpm
|
# pnpm
|
||||||
export PNPM_HOME="/home/zedhugh/.local/share/pnpm"
|
export PNPM_HOME="$(realpath ~/.local/share/pnpm)"
|
||||||
export PATH="$PNPM_HOME:$PATH"
|
export PATH="$PNPM_HOME:$PATH"
|
||||||
# pnpm end
|
# pnpm end
|
||||||
# tabtab source for packages
|
# tabtab source for packages
|
||||||
|
|||||||
Reference in New Issue
Block a user