mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-13 05:59:46 +08:00
Compare commits
5 Commits
27402e2603
...
f36c6db0ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f36c6db0ea | ||
|
|
7400d469b6 | ||
|
|
df80a2da54 | ||
|
|
fea4584ceb | ||
|
|
278bcfc93b |
@ -2,26 +2,29 @@
|
||||
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR/completions"
|
||||
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
fi
|
||||
|
||||
# If not found, check for Homebrew package
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then
|
||||
brew_prefix="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${brew_prefix}/libexec"
|
||||
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d"
|
||||
unset brew_prefix
|
||||
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
# If not found, check for archlinux/AUR package (/opt/asdf-vm/)
|
||||
if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
|
||||
ASDF_DIR="/opt/asdf-vm"
|
||||
ASDF_COMPLETIONS="$ASDF_DIR"
|
||||
# If not found, check for Homebrew package
|
||||
elif (( $+commands[brew] )); then
|
||||
_ASDF_PREFIX="$(brew --prefix asdf)"
|
||||
ASDF_DIR="${_ASDF_PREFIX}/libexec"
|
||||
ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
|
||||
unset _ASDF_PREFIX
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load command
|
||||
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
|
||||
. "$ASDF_DIR/asdf.sh"
|
||||
|
||||
source "$ASDF_DIR/asdf.sh"
|
||||
# Load completions
|
||||
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then
|
||||
. "$ASDF_COMPLETIONS/asdf.bash"
|
||||
if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
|
||||
fpath+=("$ASDF_COMPLETIONS")
|
||||
autoload -Uz _asdf
|
||||
compdef _asdf asdf # compdef is already loaded before loading plugins
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -23,4 +23,4 @@ alias gel="gem lock"
|
||||
alias geo="gem open"
|
||||
alias geoe="gem open -e"
|
||||
alias rrun="ruby -e"
|
||||
alias rserver="ruby -e httpd . -p 8080" # requires webrick
|
||||
alias rserver="ruby -run -e httpd . -p 8080" # requires webrick
|
||||
|
||||
@ -23,6 +23,7 @@ Set `SHELLPROXY_URL` environment variable to the URL of the proxy server:
|
||||
|
||||
```sh
|
||||
SHELLPROXY_URL="http://127.0.0.1:8123"
|
||||
SHELLPROXY_NO_PROXY="localhost,127.0.0.1"
|
||||
proxy enable
|
||||
```
|
||||
|
||||
@ -36,11 +37,15 @@ Example:
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
# HTTP Proxy
|
||||
if [[ "$(uname)" = Darwin ]]; then
|
||||
echo "http://127.0.0.1:6152" # Surge Mac
|
||||
else
|
||||
echo "http://127.0.0.1:8123" # polipo
|
||||
fi
|
||||
|
||||
# No Proxy
|
||||
echo "localhost,127.0.0.1"
|
||||
```
|
||||
|
||||
### Method 3
|
||||
|
||||
@ -6,6 +6,7 @@ from subprocess import check_output, list2cmdline
|
||||
cwd = os.path.dirname(__file__)
|
||||
ssh_agent = os.path.join(cwd, "ssh-agent.py")
|
||||
proxy_env = "SHELLPROXY_URL"
|
||||
no_proxy_env = "SHELLPROXY_NO_PROXY"
|
||||
proxy_config = os.environ.get("SHELLPROXY_CONFIG") or os.path.expandvars("$HOME/.config/proxy")
|
||||
|
||||
usage="""shell-proxy: no proxy configuration found.
|
||||
@ -15,18 +16,30 @@ See the plugin README for more information.""".format(env=proxy_env, config=prox
|
||||
|
||||
def get_http_proxy():
|
||||
default_proxy = os.environ.get(proxy_env)
|
||||
if default_proxy:
|
||||
return default_proxy
|
||||
no_proxy = os.environ.get(no_proxy_env)
|
||||
if default_proxy and no_proxy:
|
||||
return default_proxy, no_proxy
|
||||
|
||||
if os.path.isfile(proxy_config):
|
||||
return check_output(proxy_config).decode("utf-8").strip()
|
||||
proxy_configdata = [line.strip() for line in check_output(proxy_config).decode("utf-8").splitlines()]
|
||||
if len(proxy_configdata) >= 1:
|
||||
if not default_proxy:
|
||||
default_proxy = proxy_configdata[0]
|
||||
if len(proxy_configdata) == 2 and not no_proxy:
|
||||
no_proxy = proxy_configdata[1]
|
||||
|
||||
if default_proxy:
|
||||
return default_proxy, no_proxy
|
||||
print(usage, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_proxies(url: str):
|
||||
def make_proxies(url: str, no_proxy: str):
|
||||
proxies = {"%s_PROXY" % _: url for _ in ("HTTP", "HTTPS", "FTP", "RSYNC", "ALL")}
|
||||
proxies.update({name.lower(): value for (name, value) in proxies.items()})
|
||||
proxies["GIT_SSH"] = ssh_agent
|
||||
if no_proxy:
|
||||
proxies.update({"NO_PROXY": no_proxy, "no_proxy": no_proxy})
|
||||
return proxies
|
||||
|
||||
|
||||
@ -35,7 +48,7 @@ def merge(mapping: dict):
|
||||
|
||||
|
||||
class CommandSet:
|
||||
proxies = make_proxies(get_http_proxy())
|
||||
proxies = make_proxies(*get_http_proxy())
|
||||
aliases = {
|
||||
_: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
|
||||
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")
|
||||
|
||||
@ -27,7 +27,7 @@ eval '
|
||||
|
||||
# capture the output of the proxy script and bail out if it fails
|
||||
local output
|
||||
output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" ||
|
||||
output="$(SHELLPROXY_URL="$SHELLPROXY_URL" SHELLPROXY_NO_PROXY="$SHELLPROXY_NO_PROXY" SHELLPROXY_CONFIG="$SHELLPROXY_CONFIG" "$proxy" "$1")" ||
|
||||
return $?
|
||||
|
||||
# evaluate the output generated by the proxy script
|
||||
|
||||
@ -109,7 +109,7 @@ compdef _tmux _zsh_tmux_plugin_run
|
||||
alias tmux=_zsh_tmux_plugin_run
|
||||
|
||||
# Autostart if not already in tmux and enabled.
|
||||
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" ]]; then
|
||||
if [[ -z "$TMUX" && "$ZSH_TMUX_AUTOSTART" == "true" && -z "$INSIDE_EMACS" && -z "$EMACS" && -z "$VIM" && -z "$INTELLIJ_ENVIRONMENT_READER" ]]; then
|
||||
# Actually don't autostart if we already did and multiple autostarts are disabled.
|
||||
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
|
||||
export ZSH_TMUX_AUTOSTARTED=true
|
||||
|
||||
@ -144,11 +144,17 @@ NOTE: this used to be bound to `v`. That is now the default (`visual-mode`).
|
||||
- `c{motion}` : Delete {motion} text and start insert
|
||||
- `cc` : Delete line and start insert
|
||||
- `C` : Delete to the end of the line and start insert
|
||||
- `P` : Insert the contents of the clipboard before the cursor
|
||||
- `p` : Insert the contents of the clipboard after the cursor
|
||||
- `r{char}` : Replace the character under the cursor with {char}
|
||||
- `R` : Enter replace mode: Each character replaces existing one
|
||||
- `x` : Delete `count` characters under and after the cursor
|
||||
- `X` : Delete `count` characters before the cursor
|
||||
|
||||
NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank commands
|
||||
(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
|
||||
(`P`, `p`).
|
||||
|
||||
## Known issues
|
||||
|
||||
### Low `$KEYTIMEOUT`
|
||||
|
||||
@ -147,8 +147,15 @@ function wrap_clipboard_widgets() {
|
||||
done
|
||||
}
|
||||
|
||||
wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete vi-delete-char
|
||||
wrap_clipboard_widgets paste vi-put-{before,after}
|
||||
wrap_clipboard_widgets copy \
|
||||
vi-yank vi-yank-eol vi-yank-whole-line \
|
||||
vi-change vi-change-eol vi-change-whole-line \
|
||||
vi-kill-line vi-kill-eol vi-backward-kill-word \
|
||||
vi-delete vi-delete-char vi-backward-delete-char
|
||||
|
||||
wrap_clipboard_widgets paste \
|
||||
vi-put-{before,after}
|
||||
|
||||
unfunction wrap_clipboard_widgets
|
||||
|
||||
# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default
|
||||
|
||||
Loading…
Reference in New Issue
Block a user