mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Merge branch 'ohmyzsh:master' into conda
This commit is contained in:
commit
6017577311
6 changed files with 69 additions and 12 deletions
50
lib/vcs_info.zsh
Normal file
50
lib/vcs_info.zsh
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
# Impacted versions go from v5.0.3 to v5.8 (v5.8.1 is the first patched version)
|
||||
autoload -Uz is-at-least
|
||||
if is-at-least 5.8.1 || ! is-at-least 5.0.3; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Quote necessary $hook_com[<field>] items just before they are used
|
||||
# in the line "VCS_INFO_hook 'post-backend'" of the VCS_INFO_formats
|
||||
# function, where <field> is:
|
||||
#
|
||||
# base: the full path of the repository's root directory.
|
||||
# base-name: the name of the repository's root directory.
|
||||
# branch: the name of the currently checked out branch.
|
||||
# misc: a string that may contain anything the vcs_info backend wants.
|
||||
# revision: an identifier of the currently checked out revision.
|
||||
# subdir: the path of the current directory relative to the
|
||||
# repository's root directory.
|
||||
#
|
||||
# This patch %-quotes these fields previous to their use in vcs_info hooks and
|
||||
# the zformat call and, eventually, when they get expanded in the prompt.
|
||||
# It's important to quote these here, and not later after hooks have modified the
|
||||
# fields, because then we could be quoting % characters from valid prompt sequences,
|
||||
# like %F{color}, %B, etc.
|
||||
#
|
||||
# 32 │ hook_com[subdir]="$(VCS_INFO_reposub ${hook_com[base]})"
|
||||
# 33 │ hook_com[subdir_orig]="${hook_com[subdir]}"
|
||||
# 34 │
|
||||
# 35 + │ for tmp in base base-name branch misc revision subdir; do
|
||||
# 36 + │ hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"
|
||||
# 37 + │ done
|
||||
# 38 + │
|
||||
# 39 │ VCS_INFO_hook 'post-backend'
|
||||
#
|
||||
# This is especially important so that no command substitution is performed
|
||||
# due to malicious input as a consequence of CVE-2021-45444, which affects
|
||||
# zsh versions from 5.0.3 to 5.8.
|
||||
#
|
||||
autoload -Uz +X regexp-replace VCS_INFO_formats
|
||||
|
||||
# We use $tmp here because it's already a local variable in VCS_INFO_formats
|
||||
typeset PATCH='for tmp (base base-name branch misc revision subdir) hook_com[$tmp]="${hook_com[$tmp]//\%/%%}"'
|
||||
# Unique string to avoid reapplying the patch if this code gets called twice
|
||||
typeset PATCH_ID=vcs_info-patch-9b9840f2-91e5-4471-af84-9e9a0dc68c1b
|
||||
# Only patch the VCS_INFO_formats function if not already patched
|
||||
if [[ "$functions[VCS_INFO_formats]" != *$PATCH_ID* ]]; then
|
||||
regexp-replace 'functions[VCS_INFO_formats]' \
|
||||
"VCS_INFO_hook 'post-backend'" \
|
||||
': ${PATCH_ID}; ${PATCH}; ${MATCH}'
|
||||
fi
|
||||
unset PATCH PATCH_ID
|
||||
|
|
@ -7,7 +7,3 @@ To use it, add `fd` to the plugins array in your zshrc file:
|
|||
```zsh
|
||||
plugins=(... fd)
|
||||
```
|
||||
|
||||
Completion is taken from the fd release [`8.2.1`](https://github.com/sharkdp/fd/releases/tag/v8.2.1).
|
||||
|
||||
Updated on April 1st, 2021.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#compdef fd fdfind
|
||||
#compdef fd
|
||||
|
||||
##
|
||||
# zsh completion function for fd
|
||||
|
|
@ -57,6 +57,7 @@ _fd() {
|
|||
+ no-ignore-partial # some ignore files
|
||||
"(no-ignore-full --no-ignore-vcs)--no-ignore-vcs[don't respect .gitignore files]"
|
||||
"!(no-ignore-full --no-global-ignore-file)--no-global-ignore-file[don't respect the global ignore file]"
|
||||
$no'(no-ignore-full --no-ignore-parent)--no-ignore-parent[]'
|
||||
|
||||
+ '(case)' # case-sensitivity
|
||||
{-s,--case-sensitive}'[perform a case-sensitive search]'
|
||||
|
|
@ -138,6 +139,7 @@ _fd() {
|
|||
+ '(exec-cmds)' # execute command
|
||||
'(long-listing max-results)'{-x+,--exec=}'[execute command for each search result]:command: _command_names -e:*\;::program arguments: _normal'
|
||||
'(long-listing max-results)'{-X+,--exec-batch=}'[execute command for all search results at once]:command: _command_names -e:*\;::program arguments: _normal'
|
||||
'(long-listing max-results)--batch-size=[max number of args for each -X call]:size'
|
||||
|
||||
+ other
|
||||
'!(--max-buffer-time)--max-buffer-time=[set amount of time to buffer before showing output]:time (ms)'
|
||||
|
|
@ -153,6 +155,9 @@ _fd() {
|
|||
$no'(--base-directory)--base-directory=[change the current working directory to the given path]:directory:_files -/'
|
||||
$no'(*)*--search-path=[set search path (instead of positional <path> arguments)]:directory:_files -/'
|
||||
|
||||
+ strip-cwd-prefix
|
||||
$no'(strip-cwd-prefix exec-cmds)--strip-cwd-prefix[Strip ./ prefix when output is redirected]'
|
||||
|
||||
+ args # positional arguments
|
||||
'1: :_guard "^-*" pattern'
|
||||
'(--search-path)*:directory:_files -/'
|
||||
|
|
@ -220,7 +225,7 @@ _fd() {
|
|||
_fd "$@"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users
|
||||
# Copyright (c) 2011 GitHub zsh-users - http://github.com/zsh-users
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
|
|
|||
|
|
@ -7,7 +7,3 @@ To use it, add `ripgrep` to the plugins array in your zshrc file:
|
|||
```zsh
|
||||
plugins=(... ripgrep)
|
||||
```
|
||||
|
||||
Completion is taken from the ripgrep release [`12.1.1`](https://github.com/BurntSushi/ripgrep/releases/tag/12.1.1).
|
||||
|
||||
Updated on April 1st, 2021.
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ _rg() {
|
|||
"(pretty-vimgrep)--no-heading[don't show matches grouped by file name]"
|
||||
|
||||
+ '(hidden)' # Hidden-file options
|
||||
'--hidden[search hidden files and directories]'
|
||||
{-.,--hidden}'[search hidden files and directories]'
|
||||
$no"--no-hidden[don't search hidden files and directories]"
|
||||
|
||||
+ '(hybrid)' # hybrid regex options
|
||||
|
|
@ -303,6 +303,8 @@ _rg() {
|
|||
'--context-separator=[specify string used to separate non-continuous context lines in output]:separator'
|
||||
$no"--no-context-separator[don't print context separators]"
|
||||
'--debug[show debug messages]'
|
||||
'--field-context-separator[set string to delimit fields in context lines]'
|
||||
'--field-match-separator[set string to delimit fields in matching lines]'
|
||||
'--trace[show more verbose debug messages]'
|
||||
'--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)'
|
||||
"(1 stats)--files[show each file that would be searched (but don't search)]"
|
||||
|
|
|
|||
|
|
@ -95,13 +95,21 @@ function has_typed_input() {
|
|||
emulate -L zsh
|
||||
zmodload zsh/zselect
|
||||
|
||||
# Back up stty settings prior to disabling canonical mode
|
||||
# Consider that no input can be typed if stty fails
|
||||
# (this might happen if stdin is not a terminal)
|
||||
local termios
|
||||
termios=$(stty --save 2>/dev/null) || return 1
|
||||
{
|
||||
local termios=$(stty --save)
|
||||
# Disable canonical mode so that typed input counts
|
||||
# regardless of whether Enter was pressed
|
||||
stty -icanon
|
||||
|
||||
# Poll stdin (fd 0) for data ready to be read
|
||||
zselect -t 0 -r 0
|
||||
return $?
|
||||
} always {
|
||||
# Restore stty settings
|
||||
stty $termios
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue