1
0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2026-02-13 05:59:46 +08:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Abhinav
f36c6db0ea
feat(shell-proxy): allow excluding endpoints with NO_PROXY (#11924) 2023-10-02 20:58:42 +02:00
jack
7400d469b6
fix(ruby): add missing -run in rserver alias (#11913) 2023-10-02 20:41:18 +02:00
bretello
df80a2da54
feat(vi-mode): copy to clipboard when using vi-change* and vi-yank* widgets (#11861) 2023-10-02 20:41:01 +02:00
HeroCC
fea4584ceb
fix(tmux): don't autostart inside background intelliJ (#11927) 2023-10-02 20:34:57 +02:00
Thomas Faugier
278bcfc93b
feat(asdf): load zsh completions instead of bash ones
Closes #11143
Closes #8779

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
2023-10-02 20:27:52 +02:00
8 changed files with 60 additions and 26 deletions

View File

@ -2,26 +2,29 @@
ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}" ASDF_DIR="${ASDF_DIR:-$HOME/.asdf}"
ASDF_COMPLETIONS="$ASDF_DIR/completions" 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" ]]; then
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && [[ -f "/opt/asdf-vm/asdf.sh" ]]; then # If not found, check for archlinux/AUR package (/opt/asdf-vm/)
ASDF_DIR="/opt/asdf-vm" if [[ -f "/opt/asdf-vm/asdf.sh" ]]; then
ASDF_COMPLETIONS="$ASDF_DIR" ASDF_DIR="/opt/asdf-vm"
fi ASDF_COMPLETIONS="$ASDF_DIR"
# If not found, check for Homebrew package
# If not found, check for Homebrew package elif (( $+commands[brew] )); then
if [[ ! -f "$ASDF_DIR/asdf.sh" || ! -f "$ASDF_COMPLETIONS/asdf.bash" ]] && (( $+commands[brew] )); then _ASDF_PREFIX="$(brew --prefix asdf)"
brew_prefix="$(brew --prefix asdf)" ASDF_DIR="${_ASDF_PREFIX}/libexec"
ASDF_DIR="${brew_prefix}/libexec" ASDF_COMPLETIONS="${_ASDF_PREFIX}/share/zsh/site-functions"
ASDF_COMPLETIONS="${brew_prefix}/etc/bash_completion.d" unset _ASDF_PREFIX
unset brew_prefix else
return
fi
fi fi
# Load command # Load command
if [[ -f "$ASDF_DIR/asdf.sh" ]]; then if [[ -f "$ASDF_DIR/asdf.sh" ]]; then
. "$ASDF_DIR/asdf.sh" source "$ASDF_DIR/asdf.sh"
# Load completions # Load completions
if [[ -f "$ASDF_COMPLETIONS/asdf.bash" ]]; then if [[ -f "$ASDF_COMPLETIONS/_asdf" ]]; then
. "$ASDF_COMPLETIONS/asdf.bash" fpath+=("$ASDF_COMPLETIONS")
autoload -Uz _asdf
compdef _asdf asdf # compdef is already loaded before loading plugins
fi fi
fi fi

View File

@ -23,4 +23,4 @@ alias gel="gem lock"
alias geo="gem open" alias geo="gem open"
alias geoe="gem open -e" alias geoe="gem open -e"
alias rrun="ruby -e" alias rrun="ruby -e"
alias rserver="ruby -e httpd . -p 8080" # requires webrick alias rserver="ruby -run -e httpd . -p 8080" # requires webrick

View File

@ -23,6 +23,7 @@ Set `SHELLPROXY_URL` environment variable to the URL of the proxy server:
```sh ```sh
SHELLPROXY_URL="http://127.0.0.1:8123" SHELLPROXY_URL="http://127.0.0.1:8123"
SHELLPROXY_NO_PROXY="localhost,127.0.0.1"
proxy enable proxy enable
``` ```
@ -36,11 +37,15 @@ Example:
```sh ```sh
#!/bin/bash #!/bin/bash
# HTTP Proxy
if [[ "$(uname)" = Darwin ]]; then if [[ "$(uname)" = Darwin ]]; then
echo "http://127.0.0.1:6152" # Surge Mac echo "http://127.0.0.1:6152" # Surge Mac
else else
echo "http://127.0.0.1:8123" # polipo echo "http://127.0.0.1:8123" # polipo
fi fi
# No Proxy
echo "localhost,127.0.0.1"
``` ```
### Method 3 ### Method 3

View File

@ -6,6 +6,7 @@ from subprocess import check_output, list2cmdline
cwd = os.path.dirname(__file__) cwd = os.path.dirname(__file__)
ssh_agent = os.path.join(cwd, "ssh-agent.py") ssh_agent = os.path.join(cwd, "ssh-agent.py")
proxy_env = "SHELLPROXY_URL" proxy_env = "SHELLPROXY_URL"
no_proxy_env = "SHELLPROXY_NO_PROXY"
proxy_config = os.environ.get("SHELLPROXY_CONFIG") or os.path.expandvars("$HOME/.config/proxy") proxy_config = os.environ.get("SHELLPROXY_CONFIG") or os.path.expandvars("$HOME/.config/proxy")
usage="""shell-proxy: no proxy configuration found. 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(): def get_http_proxy():
default_proxy = os.environ.get(proxy_env) default_proxy = os.environ.get(proxy_env)
if default_proxy: no_proxy = os.environ.get(no_proxy_env)
return default_proxy if default_proxy and no_proxy:
return default_proxy, no_proxy
if os.path.isfile(proxy_config): 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) print(usage, file=sys.stderr)
sys.exit(1) 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 = {"%s_PROXY" % _: url for _ in ("HTTP", "HTTPS", "FTP", "RSYNC", "ALL")}
proxies.update({name.lower(): value for (name, value) in proxies.items()}) proxies.update({name.lower(): value for (name, value) in proxies.items()})
proxies["GIT_SSH"] = ssh_agent proxies["GIT_SSH"] = ssh_agent
if no_proxy:
proxies.update({"NO_PROXY": no_proxy, "no_proxy": no_proxy})
return proxies return proxies
@ -35,7 +48,7 @@ def merge(mapping: dict):
class CommandSet: class CommandSet:
proxies = make_proxies(get_http_proxy()) proxies = make_proxies(*get_http_proxy())
aliases = { aliases = {
_: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent) _: "env __SSH_PROGRAM_NAME__=%s %s" % (_, ssh_agent)
for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id") for _ in ("ssh", "sftp", "scp", "slogin", "ssh-copy-id")

View File

@ -27,7 +27,7 @@ eval '
# capture the output of the proxy script and bail out if it fails # capture the output of the proxy script and bail out if it fails
local output 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 $? return $?
# evaluate the output generated by the proxy script # evaluate the output generated by the proxy script

View File

@ -109,7 +109,7 @@ compdef _tmux _zsh_tmux_plugin_run
alias tmux=_zsh_tmux_plugin_run alias tmux=_zsh_tmux_plugin_run
# Autostart if not already in tmux and enabled. # 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. # Actually don't autostart if we already did and multiple autostarts are disabled.
if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then if [[ "$ZSH_TMUX_AUTOSTART_ONCE" == "false" || "$ZSH_TMUX_AUTOSTARTED" != "true" ]]; then
export ZSH_TMUX_AUTOSTARTED=true export ZSH_TMUX_AUTOSTARTED=true

View File

@ -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 - `c{motion}` : Delete {motion} text and start insert
- `cc` : Delete line and start insert - `cc` : Delete line and start insert
- `C` : Delete to the end of the 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{char}` : Replace the character under the cursor with {char}
- `R` : Enter replace mode: Each character replaces existing one - `R` : Enter replace mode: Each character replaces existing one
- `x` : Delete `count` characters under and after the cursor - `x` : Delete `count` characters under and after the cursor
- `X` : Delete `count` characters before 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 ## Known issues
### Low `$KEYTIMEOUT` ### Low `$KEYTIMEOUT`

View File

@ -147,8 +147,15 @@ function wrap_clipboard_widgets() {
done 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 copy \
wrap_clipboard_widgets paste vi-put-{before,after} 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 unfunction wrap_clipboard_widgets
# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default # if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default