Created
August 7, 2016 15:04
-
-
Save alireza-ahmadi/fbd63063ebc916140d42f61681b81215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------------ | |
# Description | |
# ----------- | |
# | |
# Insert `ALL_PROXY=socks5://server:port` before the command by pressing | |
# ESC and p. Heavily inspired by oh-my-zsh's sudo plugin. | |
# | |
# ------------------------------------------------------------------------------ | |
# Authors | |
# ------- | |
# | |
# * Alireza Ahamdi <[email protected]> | |
# | |
# ------------------------------------------------------------------------------ | |
pproxy-command-line() { | |
PROXY="ALL_PROXY=${PROXY_ADDR:-socks5://127.0.0.1:1080}" | |
[[ -z $BUFFER ]] && zle up-history | |
if [[ $BUFFER == $PROXY\ * ]]; then | |
LBUFFER="${LBUFFER#${PROXY} }" | |
else | |
LBUFFER="$PROXY $LBUFFER" | |
fi | |
} | |
zle -N pproxy-command-line | |
# Defined shortcut keys: [Esc] [p] | |
bindkey "\ep" pproxy-command-line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment