mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2024-11-27 10:49:55 +08:00
[split] Move proxy plugin to oh-my-fish/plugin-proxy
https://github.com/oh-my-fish/plugin-proxy
This commit is contained in:
parent
0eac6bb077
commit
75396dbacf
|
@ -1,54 +0,0 @@
|
||||||
proxy plugin
|
|
||||||
============
|
|
||||||
|
|
||||||
The proxy plugin provides a couple helper functions to those of us who are
|
|
||||||
stuck behind HTTP/HTTPS/FTP proxies that require authentication. The variables
|
|
||||||
it exports are used by many command-line and GUI applications on Linux, as well
|
|
||||||
as [MacPorts][1] and [Homebrew][2] on OS X.
|
|
||||||
|
|
||||||
Both uppercase and lowercase versions of the proxy environment variables are
|
|
||||||
set, some applications are case sensitive. If you'd like to learn more about
|
|
||||||
the use of these variables, this [Arch Wiki Article][3] is a good place to
|
|
||||||
start.
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
In all cases you will need to add 'proxy' to your fish_plugins list in
|
|
||||||
config.fish
|
|
||||||
|
|
||||||
### No authentication
|
|
||||||
|
|
||||||
If you just want to have the proxy plugin configure all the environment
|
|
||||||
variables, you may set proxy_host:
|
|
||||||
|
|
||||||
set proxy_host myproxy.example.com:8000
|
|
||||||
|
|
||||||
The proxy plugin will prepend `http://` for you. Here's the result:
|
|
||||||
|
|
||||||
~> set -x |grep proxy
|
|
||||||
ALL_PROXY http://myproxy.example.com:8000
|
|
||||||
FTP_PROXY http://myproxy.example.com:8000
|
|
||||||
HTTPS_PROXY http://myproxy.example.com:8000
|
|
||||||
HTTP_PROXY http://myproxy.example.com:8000
|
|
||||||
all_proxy http://myproxy.example.com:8000
|
|
||||||
ftp_proxy http://myproxy.example.com:8000
|
|
||||||
http_proxy http://myproxy.example.com:8000
|
|
||||||
https_proxy http://myproxy.example.com:8000
|
|
||||||
|
|
||||||
### With authentication
|
|
||||||
|
|
||||||
Set your proxy host and username:
|
|
||||||
|
|
||||||
set proxy_host myproxy.example.com:8000
|
|
||||||
set proxy_user mylogin
|
|
||||||
|
|
||||||
When you need to make use of the proxy, just run `proxy`. It will prompt you
|
|
||||||
for a password and setup your environment.
|
|
||||||
|
|
||||||
If you didn't setup a proxy_user variable, you will be prompted for a username.
|
|
||||||
|
|
||||||
If you wish to clear your proxy variables, run `noproxy`.
|
|
||||||
|
|
||||||
[1]: http://www.macports.org/
|
|
||||||
[2]: http://brew.sh/
|
|
||||||
[3]: https://wiki.archlinux.org/index.php/proxy_settings
|
|
|
@ -1,15 +0,0 @@
|
||||||
function _proxy_set -a proxy \
|
|
||||||
-d "Set all proxy vars to specified value"
|
|
||||||
|
|
||||||
set -l envars http_proxy HTTP_PROXY \
|
|
||||||
https_proxy HTTPS_PROXY \
|
|
||||||
ftp_proxy FTP_PROXY \
|
|
||||||
all_proxy ALL_PROXY
|
|
||||||
for envar in $envars
|
|
||||||
if test $proxy = '-e'
|
|
||||||
set -e $envar
|
|
||||||
else
|
|
||||||
set -gx $envar $proxy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
function noproxy -d "Clear all proxy environment variables"
|
|
||||||
_proxy_set -e
|
|
||||||
end
|
|
|
@ -1,25 +0,0 @@
|
||||||
function proxy -d "Setup proxy environment variables"
|
|
||||||
if not set -q proxy_host
|
|
||||||
echo "Error: You must set proxy_host to your proxy hostname:port in config.fish"
|
|
||||||
echo "You may also set proxy_user to your username"
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
# Get user & password
|
|
||||||
set -l user $proxy_user
|
|
||||||
if not set -q proxy_user
|
|
||||||
read -p "echo -n 'Proxy User: '" user
|
|
||||||
end
|
|
||||||
# Hacky way to read password in fish
|
|
||||||
echo -n 'Proxy Password: '
|
|
||||||
stty -echo
|
|
||||||
head -n 1 | read -l pass
|
|
||||||
stty echo
|
|
||||||
echo
|
|
||||||
# URL encode password
|
|
||||||
set -l chars (echo $pass | sed -E -e 's/./\n\\0/g;/^$/d;s/\n//')
|
|
||||||
printf '%%%02x' "'"$chars"'" | read -l encpass
|
|
||||||
|
|
||||||
_proxy_set "http://$user:$encpass@$proxy_host"
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
# Initial proxy setup (no username/password)
|
|
||||||
if set -q proxy_host
|
|
||||||
_proxy_set "http://$proxy_host"
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user