Skip to content

Instantly share code, notes, and snippets.

@alireza-ahmadi
Created August 7, 2016 15:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alireza-ahmadi/fbd63063ebc916140d42f61681b81215 to your computer and use it in GitHub Desktop.
Save alireza-ahmadi/fbd63063ebc916140d42f61681b81215 to your computer and use it in GitHub Desktop.
# ------------------------------------------------------------------------------
# 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 <a.ahmadi94@gmail.com>
#
# ------------------------------------------------------------------------------
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