mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-23 02:35:38 +01:00
Merge branch 'master' of https://github.com/ohmyzsh/ohmyzsh
This commit is contained in:
commit
7dbe397837
36 changed files with 511 additions and 282 deletions
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/.github/workflows/dependencies"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
day: "sunday"
|
||||
11
.github/dependencies.yml
vendored
11
.github/dependencies.yml
vendored
|
|
@ -18,3 +18,14 @@ dependencies:
|
|||
set -e
|
||||
test -e _zshz && mv -f _zshz _z
|
||||
test -e zsh-z.plugin.zsh && mv -f zsh-z.plugin.zsh z.plugin.zsh
|
||||
plugins/history-substring-search:
|
||||
repo: zsh-users/zsh-history-substring-search
|
||||
branch: master
|
||||
version: 8dd05bfcc12b0cd1ee9ea64be725b3d9f713cf64
|
||||
precopy: |
|
||||
set -e
|
||||
rm -f zsh-history-substring-search.plugin.zsh
|
||||
test -e zsh-history-substring-search.zsh && mv zsh-history-substring-search.zsh history-substring-search.zsh
|
||||
postcopy: |
|
||||
set -e
|
||||
test -e dependencies/OMZ-README.md && cat dependencies/OMZ-README.md >> README.md
|
||||
|
|
|
|||
4
.github/workflows/installer.yml
vendored
4
.github/workflows/installer.yml
vendored
|
|
@ -26,7 +26,7 @@ jobs:
|
|||
- macos-latest
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install zsh
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
|
|
@ -42,7 +42,7 @@ jobs:
|
|||
- test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install Vercel CLI
|
||||
run: npm install -g vercel
|
||||
- name: Setup project and deploy
|
||||
|
|
|
|||
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -24,7 +24,7 @@ jobs:
|
|||
if: github.repository == 'ohmyzsh/ohmyzsh'
|
||||
steps:
|
||||
- name: Set up git repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Install zsh
|
||||
run: sudo apt-get update; sudo apt-get install zsh
|
||||
- name: Check syntax
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ zstyle ':completion:*:*:*:users' ignored-patterns \
|
|||
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
||||
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
||||
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
||||
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
||||
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
||||
|
|
|
|||
|
|
@ -32,19 +32,26 @@ if [[ -n "${terminfo[knp]}" ]]; then
|
|||
fi
|
||||
|
||||
# Start typing + [Up-Arrow] - fuzzy find history forward
|
||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
autoload -U up-line-or-beginning-search
|
||||
zle -N up-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "^[[A" up-line-or-beginning-search
|
||||
bindkey -M viins "^[[A" up-line-or-beginning-search
|
||||
bindkey -M vicmd "^[[A" up-line-or-beginning-search
|
||||
if [[ -n "${terminfo[kcuu1]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
|
||||
fi
|
||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
# Start typing + [Down-Arrow] - fuzzy find history backward
|
||||
autoload -U down-line-or-beginning-search
|
||||
zle -N down-line-or-beginning-search
|
||||
|
||||
bindkey -M emacs "^[[B" down-line-or-beginning-search
|
||||
bindkey -M viins "^[[B" down-line-or-beginning-search
|
||||
bindkey -M vicmd "^[[B" down-line-or-beginning-search
|
||||
if [[ -n "${terminfo[kcud1]}" ]]; then
|
||||
bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
|
||||
|
|
|
|||
|
|
@ -40,5 +40,5 @@ ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
|||
# use this to enable users to see their ruby version, no matter which
|
||||
# version management system they use
|
||||
function ruby_prompt_info() {
|
||||
echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
|
||||
echo "$(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ typeset -AHg FX FG BG
|
|||
FX=(
|
||||
reset "%{[00m%}"
|
||||
bold "%{[01m%}" no-bold "%{[22m%}"
|
||||
dim "%{[02m%}" no-dim "%{[22m%}"
|
||||
italic "%{[03m%}" no-italic "%{[23m%}"
|
||||
underline "%{[04m%}" no-underline "%{[24m%}"
|
||||
blink "%{[05m%}" no-blink "%{[25m%}"
|
||||
|
|
|
|||
|
|
@ -1,18 +1,19 @@
|
|||
declare -a autojump_paths
|
||||
autojump_paths=(
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
$HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
|
||||
$HOME/.autojump/share/autojump/autojump.zsh # manual installation
|
||||
$HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
|
||||
/run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
|
||||
/etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
|
||||
/usr/share/autojump/autojump.zsh # Debian and Ubuntu package
|
||||
/etc/profile.d/autojump.zsh # manual installation
|
||||
/etc/profile.d/autojump.sh # Gentoo installation
|
||||
/usr/local/share/autojump/autojump.zsh # FreeBSD installation
|
||||
/usr/pkg/share/autojump/autojump.zsh # NetBSD installation
|
||||
/opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
|
||||
/usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
|
||||
/opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
|
||||
/etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
|
||||
)
|
||||
|
||||
for file in $autojump_paths; do
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ plugins=(... aws)
|
|||
Some themes might overwrite the value of RPROMPT instead of appending to it, so they'll need to be fixed to
|
||||
see the AWS profile/region prompt.
|
||||
|
||||
* Set `AWS_PROFILE_STATE_ENABLED=true` in your zshrc file if you want the aws profile to persist between shell sessions.
|
||||
This option might slow down your shell startup time.
|
||||
By default the state file path is `/tmp/.aws_current_profile`. This means that the state won't survive a reboot or otherwise GC.
|
||||
You can control the state file path using the `AWS_STATE_FILE` environment variable.
|
||||
|
||||
## Theme
|
||||
|
||||
The plugin creates an `aws_prompt_info` function that you can use in your theme, which displays
|
||||
|
|
|
|||
|
|
@ -6,10 +6,26 @@ function agr() {
|
|||
echo $AWS_REGION
|
||||
}
|
||||
|
||||
# Update state file if enabled
|
||||
function _aws_update_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo "${AWS_PROFILE} ${AWS_REGION}" > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _aws_clear_state() {
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
test -d $(dirname ${AWS_STATE_FILE}) || exit 1
|
||||
echo -n > "${AWS_STATE_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
# AWS profile selection
|
||||
function asp() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_PROFILE AWS_PROFILE AWS_EB_PROFILE AWS_PROFILE_REGION
|
||||
_aws_clear_state
|
||||
echo AWS profile cleared.
|
||||
return
|
||||
fi
|
||||
|
|
@ -28,6 +44,8 @@ function asp() {
|
|||
|
||||
export AWS_PROFILE_REGION=$(aws configure get region)
|
||||
|
||||
_aws_update_state
|
||||
|
||||
if [[ "$2" == "login" ]]; then
|
||||
if [[ -n "$3" ]]; then
|
||||
aws sso login --sso-session $3
|
||||
|
|
@ -43,6 +61,7 @@ function asp() {
|
|||
function asr() {
|
||||
if [[ -z "$1" ]]; then
|
||||
unset AWS_DEFAULT_REGION AWS_REGION
|
||||
_aws_update_state
|
||||
echo AWS region cleared.
|
||||
return
|
||||
fi
|
||||
|
|
@ -56,6 +75,7 @@ function asr() {
|
|||
|
||||
export AWS_REGION=$1
|
||||
export AWS_DEFAULT_REGION=$1
|
||||
_aws_update_state
|
||||
}
|
||||
|
||||
# AWS profile switch
|
||||
|
|
@ -202,8 +222,17 @@ function aws_change_access_key() {
|
|||
}
|
||||
|
||||
function aws_regions() {
|
||||
local region
|
||||
if [[ $AWS_DEFAULT_REGION ]];then
|
||||
region="$AWS_DEFAULT_REGION"
|
||||
elif [[ $AWS_REGION ]];then
|
||||
region="$AWS_REGION"
|
||||
else
|
||||
region="us-west-1"
|
||||
fi
|
||||
|
||||
if [[ $AWS_DEFAULT_PROFILE || $AWS_PROFILE ]];then
|
||||
aws ec2 describe-regions |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
aws ec2 describe-regions --region $region |grep RegionName | awk -F ':' '{gsub(/"/, "", $2);gsub(/,/, "", $2);gsub(/ /, "", $2); print $2}'
|
||||
else
|
||||
echo "You must specify a AWS profile."
|
||||
fi
|
||||
|
|
@ -246,6 +275,22 @@ if [[ "$SHOW_AWS_PROMPT" != false && "$RPROMPT" != *'$(aws_prompt_info)'* ]]; th
|
|||
RPROMPT='$(aws_prompt_info)'"$RPROMPT"
|
||||
fi
|
||||
|
||||
if [[ "$AWS_PROFILE_STATE_ENABLED" == true ]]; then
|
||||
AWS_STATE_FILE="${AWS_STATE_FILE:-/tmp/.aws_current_profile}"
|
||||
test -s "${AWS_STATE_FILE}" || return
|
||||
|
||||
aws_state=($(cat $AWS_STATE_FILE))
|
||||
|
||||
export AWS_DEFAULT_PROFILE="${aws_state[1]}"
|
||||
export AWS_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
export AWS_EB_PROFILE="$AWS_DEFAULT_PROFILE"
|
||||
|
||||
test -z "${aws_state[2]}" && AWS_REGION=$(aws configure get region)
|
||||
|
||||
export AWS_REGION=${AWS_REGION:-$aws_state[2]}
|
||||
export AWS_DEFAULT_REGION="$AWS_REGION"
|
||||
fi
|
||||
|
||||
# Load awscli completions
|
||||
|
||||
# AWS CLI v2 comes with its own autocompletion. Check if that is there, otherwise fall back
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Bazel plugin
|
||||
|
||||
This plugin adds completion for [bazel](https://bazel.build), an open-source build and
|
||||
test tool that scalably supports multi-language and multi-platform projects.
|
||||
This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
|
||||
|
||||
To use it, add `bazel` to the plugins array in your zshrc file:
|
||||
|
||||
|
|
@ -12,3 +11,12 @@ plugins=(... bazel)
|
|||
The plugin has a copy of [the completion script from the git repository][1].
|
||||
|
||||
[1]: https://github.com/bazelbuild/bazel/blob/master/scripts/zsh_completion/_bazel
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| ------- | -------------------------------------- | ------------------------------------------------------ |
|
||||
| bzb | `bazel build` | The `bazel build` command |
|
||||
| bzt | `bazel test` | The `bazel test` command |
|
||||
| bzr | `bazel run` | The `bazel run` command |
|
||||
| bzq | `bazel query` | The `bazel query` command |
|
||||
|
|
|
|||
5
plugins/bazel/bazel.plugin.zsh
Normal file
5
plugins/bazel/bazel.plugin.zsh
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Aliases for bazel
|
||||
alias bzb='bazel build'
|
||||
alias bzt='bazel test'
|
||||
alias bzr='bazel run'
|
||||
alias bzq='bazel query'
|
||||
|
|
@ -36,7 +36,6 @@ fi
|
|||
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias bcubo='brew update && brew outdated --cask'
|
||||
alias bcubc='brew upgrade --cask && brew cleanup'
|
||||
alias brewp='brew pin'
|
||||
alias brewsp='brew list --pinned'
|
||||
alias bubc='brew upgrade && brew cleanup'
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ Where `type` is one of the following:
|
|||
- `rev`
|
||||
- `style`
|
||||
- `test`
|
||||
- `wip`
|
||||
|
||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
||||
> NOTE: the alias for `revert` type is `rev`, as otherwise it conflicts with the git command of the same name.
|
||||
> It will still generate a commit message in the format `revert: <message>`
|
||||
|
||||
## Examples
|
||||
|
|
@ -38,5 +39,6 @@ Where `type` is one of the following:
|
|||
| Git alias | Command |
|
||||
| --------------------------------------------- | ---------------------------------------------------- |
|
||||
| `git style "remove trailing whitespace"` | `git commit -m "style: remove trailing whitespace"` |
|
||||
| `git wip "work in progress"` | `git commit -m "work in progress"` |
|
||||
| `git fix -s "router" "correct redirect link"` | `git commit -m "fix(router): correct redirect link"` |
|
||||
| `git rev -s "api" "rollback v2"` | `git commit -m "revert(api): rollback v2"` |
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ _git_commit_aliases=(
|
|||
'revert'
|
||||
'style'
|
||||
'test'
|
||||
'wip'
|
||||
)
|
||||
|
||||
local alias type
|
||||
|
|
|
|||
|
|
@ -152,6 +152,7 @@ plugins=(... git)
|
|||
| `grbd` | `git rebase $(git_develop_branch)` |
|
||||
| `grbm` | `git rebase $(git_main_branch)` |
|
||||
| `grbom` | `git rebase origin/$(git_main_branch)` |
|
||||
| `grf` | `git reflog` |
|
||||
| `gr` | `git remote` |
|
||||
| `grv` | `git remote --verbose` |
|
||||
| `gra` | `git remote add` |
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ alias grbs='git rebase --skip'
|
|||
alias grbd='git rebase $(git_develop_branch)'
|
||||
alias grbm='git rebase $(git_main_branch)'
|
||||
alias grbom='git rebase origin/$(git_main_branch)'
|
||||
alias grf='git reflog'
|
||||
alias gr='git remote'
|
||||
alias grv='git remote --verbose'
|
||||
alias gra='git remote add'
|
||||
|
|
|
|||
|
|
@ -23,7 +23,15 @@ Install
|
|||
Using the [Homebrew]( https://brew.sh ) package manager:
|
||||
|
||||
brew install zsh-history-substring-search
|
||||
echo 'source /usr/local/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
||||
echo 'source $(brew --prefix)/share/zsh-history-substring-search/zsh-history-substring-search.zsh' >> ~/.zshrc
|
||||
|
||||
Using [Fig](https://fig.io):
|
||||
|
||||
Fig adds apps, shortcuts, and autocomplete to your existing terminal.
|
||||
|
||||
Install `zsh-history-substring-search` in just one click.
|
||||
|
||||
<a href="https://fig.io/plugins/other/zsh-history-substring-search" target="_blank"><img src="https://fig.io/badges/install-with-fig.svg" /></a>
|
||||
|
||||
Using [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh):
|
||||
|
||||
|
|
@ -33,24 +41,63 @@ Using [Oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh):
|
|||
|
||||
2. Activate the plugin in `~/.zshrc`:
|
||||
|
||||
plugins=( [plugins...] history-substring-search)
|
||||
plugins=( [plugins...] zsh-history-substring-search)
|
||||
|
||||
3. Source `~/.zshrc` to take changes into account:
|
||||
3. Run `exec zsh` to take changes into account:
|
||||
|
||||
source ~/.zshrc
|
||||
exec zsh
|
||||
|
||||
Using [zplug](https://github.com/zplug/zplug):
|
||||
|
||||
1. Add this repo to `~/.zshrc`:
|
||||
|
||||
zplug "zsh-users/zsh-history-substring-search", as: plugin
|
||||
|
||||
Using [antigen](https://github.com/zsh-users/antigen):
|
||||
|
||||
1. Add the `antigen bundle` command just before `antigen apply`, like this:
|
||||
|
||||
```
|
||||
antigen bundle zsh-users/zsh-history-substring-search
|
||||
antigen apply
|
||||
```
|
||||
|
||||
2. Then, **after** `antigen apply`, add the key binding configurations, like this:
|
||||
|
||||
```
|
||||
# zsh-history-substring-search configuration
|
||||
bindkey '^[[A' history-substring-search-up # or '\eOA'
|
||||
bindkey '^[[B' history-substring-search-down # or '\eOB'
|
||||
HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=1
|
||||
```
|
||||
|
||||
Using [Zinit](https://github.com/zdharma-continuum/zinit):
|
||||
|
||||
1. Use the `Oh-my-zsh` Zinit snippet in `~/.zshrc`:
|
||||
|
||||
zinit snippet OMZ::plugins/git/git.plugin.zsh`
|
||||
|
||||
2. Load the plugin in `~/.zshrc`:
|
||||
|
||||
zinit load 'zsh-users/zsh-history-substring-search
|
||||
zinit ice wait atload'_history_substring_search_config'
|
||||
|
||||
3. Run `exec zsh` to take changes into account:
|
||||
|
||||
exec zsh
|
||||
|
||||
Usage
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
1. Load this script into your interactive ZSH session:
|
||||
|
||||
% source zsh-history-substring-search.zsh
|
||||
source zsh-history-substring-search.zsh
|
||||
|
||||
If you want to use [zsh-syntax-highlighting][6] along with this script,
|
||||
then make sure that you load it *before* you load this script:
|
||||
|
||||
% source zsh-syntax-highlighting.zsh
|
||||
% source zsh-history-substring-search.zsh
|
||||
source zsh-syntax-highlighting.zsh
|
||||
source zsh-history-substring-search.zsh
|
||||
|
||||
2. Bind keyboard shortcuts to this script's functions.
|
||||
|
||||
|
|
@ -73,6 +120,10 @@ Usage
|
|||
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||
|
||||
Users have also observed that `[OA` and `[OB` are correct values,
|
||||
_even if_ these were not the observed values. If you are having trouble
|
||||
with the observed values, give these a try.
|
||||
|
||||
You might also want to bind the Control-P/N keys for use in EMACS mode:
|
||||
|
||||
bindkey -M emacs '^P' history-substring-search-up
|
||||
|
|
@ -115,7 +166,7 @@ Configuration
|
|||
------------------------------------------------------------------------------
|
||||
|
||||
This script defines the following global variables. You may override their
|
||||
default values only after having loaded this script into your ZSH session.
|
||||
default values.
|
||||
|
||||
* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND` is a global variable that defines
|
||||
how the query should be highlighted inside a matching command. Its default
|
||||
|
|
@ -141,6 +192,12 @@ default values only after having loaded this script into your ZSH session.
|
|||
value, causes this script to perform a fuzzy search by words, matching in
|
||||
given order e.g. `ab c` will match `*ab*c*`
|
||||
|
||||
* `HISTORY_SUBSTRING_SEARCH_PREFIXED` is a global variable that defines how
|
||||
the command history will be searched for your query. If set to a non-empty
|
||||
value, your query will be matched against the start of each history entry.
|
||||
For example, if this variable is empty, `ls` will match `ls -l` and `echo
|
||||
ls`; if it is non-empty, `ls` will only match `ls -l`.
|
||||
|
||||
* `HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE` is a global variable that defines
|
||||
whether all search results returned are _unique_. If set to a non-empty
|
||||
value, then only unique search results are presented. This behaviour is off
|
||||
|
|
@ -155,6 +212,9 @@ default values only after having loaded this script into your ZSH session.
|
|||
receive globally unique search results only once, then use this
|
||||
configuration variable, or use `setopt HIST_IGNORE_ALL_DUPS`.
|
||||
|
||||
* `HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT` is a global variable that
|
||||
defines a timeout in seconds for clearing the search highlight.
|
||||
|
||||
|
||||
History
|
||||
------------------------------------------------------------------------------
|
||||
|
|
@ -175,24 +235,17 @@ History
|
|||
|
||||
* March 2016: Geza Lore (@gezalore) greatly refactored it in pull request #55.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Oh My Zsh Distribution Notes
|
||||
------------------------------------------------------------------------------
|
||||
---
|
||||
|
||||
What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search
|
||||
as an OMZ module inside the Oh My Zsh distribution.
|
||||
## Oh My Zsh Distribution Notes
|
||||
|
||||
The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at
|
||||
What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search as an OMZ module inside
|
||||
the Oh My Zsh distribution.
|
||||
|
||||
The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at
|
||||
https://github.com/zsh-users/zsh-history-substring-search.
|
||||
|
||||
This downstream copy was last updated from the following upstream commit:
|
||||
|
||||
SHA: 0f80b8eb3368b46e5e573c1d91ae69eb095db3fb
|
||||
Commit date: 2019-05-12 17:35:54 -0700
|
||||
|
||||
Everything above this section is a copy of the original upstream's README, so things
|
||||
may differ slightly when you're using this inside OMZ. In particular, you do not
|
||||
need to set up key bindings for the up and down arrows yourself in `~/.zshrc`; the OMZ
|
||||
plugin does that for you. You may still want to set up additional emacs- or vi-specific
|
||||
bindings as mentioned above.
|
||||
|
||||
Everything above this section is a copy of the original upstream's README, so things may differ slightly when
|
||||
you're using this inside OMZ. In particular, you do not need to set up key bindings for the up and down arrows
|
||||
yourself in `~/.zshrc`; the OMZ plugin does that for you. You may still want to set up additional emacs- or
|
||||
vi-specific bindings as mentioned above.
|
||||
|
|
|
|||
15
plugins/history-substring-search/dependencies/OMZ-README.md
Normal file
15
plugins/history-substring-search/dependencies/OMZ-README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
---
|
||||
|
||||
## Oh My Zsh Distribution Notes
|
||||
|
||||
What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search as an OMZ module inside
|
||||
the Oh My Zsh distribution.
|
||||
|
||||
The upstream repo, zsh-users/zsh-history-substring-search, can be found on GitHub at
|
||||
https://github.com/zsh-users/zsh-history-substring-search.
|
||||
|
||||
Everything above this section is a copy of the original upstream's README, so things may differ slightly when
|
||||
you're using this inside OMZ. In particular, you do not need to set up key bindings for the up and down arrows
|
||||
yourself in `~/.zshrc`; the OMZ plugin does that for you. You may still want to set up additional emacs- or
|
||||
vi-specific bindings as mentioned above.
|
||||
|
|
@ -43,11 +43,12 @@
|
|||
# declare global configuration variables
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=''
|
||||
typeset -g HISTORY_SUBSTRING_SEARCH_FUZZY=''
|
||||
: ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=magenta,fg=white,bold'}
|
||||
: ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=red,fg=white,bold'}
|
||||
: ${HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i'}
|
||||
: ${HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=''}
|
||||
: ${HISTORY_SUBSTRING_SEARCH_FUZZY=''}
|
||||
: ${HISTORY_SUBSTRING_SEARCH_PREFIXED=''}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# declare internal global variables
|
||||
|
|
@ -64,6 +65,7 @@ typeset -g -i _history_substring_search_raw_match_index
|
|||
typeset -g -a _history_substring_search_matches
|
||||
typeset -g -i _history_substring_search_match_index
|
||||
typeset -g -A _history_substring_search_unique_filter
|
||||
typeset -g -i _history_substring_search_zsh_5_9
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# the main ZLE widgets
|
||||
|
|
@ -97,6 +99,11 @@ zle -N history-substring-search-down
|
|||
#-----------------------------------------------------------------------------
|
||||
|
||||
zmodload -F zsh/parameter
|
||||
autoload -Uz is-at-least
|
||||
|
||||
if is-at-least 5.9 $ZSH_VERSION; then
|
||||
_history_substring_search_zsh_5_9=1
|
||||
fi
|
||||
|
||||
#
|
||||
# We have to "override" some keys and widgets if the
|
||||
|
|
@ -117,80 +124,125 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then
|
|||
}
|
||||
|
||||
#
|
||||
# The following snippet was taken from the zsh-syntax-highlighting project:
|
||||
# Check if $1 denotes the name of a callable function, i.e. it is fully
|
||||
# defined or it is marked for autoloading and autoloading it at the first
|
||||
# call to it will succeed. In particular, if $1 has been marked for
|
||||
# autoloading but is not available in $fpath, then it will return 1 (false).
|
||||
#
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/56b134f5d62ae3d4e66c7f52bd0cc2595f9b305b/zsh-syntax-highlighting.zsh#L126-161
|
||||
# This is based on the zsh-syntax-highlighting plugin.
|
||||
#
|
||||
# Copyright (c) 2010-2011 zsh-syntax-highlighting contributors
|
||||
# All rights reserved.
|
||||
_history-substring-search-function-callable() {
|
||||
if (( ${+functions[$1]} )) && ! [[ "$functions[$1]" == *"builtin autoload -X"* ]]; then
|
||||
return 0 # already fully loaded
|
||||
else
|
||||
# "$1" is either an autoload stub, or not a function at all.
|
||||
# We expect 'autoload +X' to return non-zero if it fails to fully load
|
||||
# the function.
|
||||
( autoload -U +X -- "$1" 2>/dev/null )
|
||||
return $?
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
# The zsh-syntax-highlighting plugin uses zle-line-pre-redraw hook instead
|
||||
# of the legacy "bind all widgets" if 1) zsh has the memo= feature (added in
|
||||
# version 5.9) and 2) add-zle-hook-widget is available.
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# * Neither the name of the zsh-syntax-highlighting contributors nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
#--------------8<-------------------8<-------------------8<-----------------
|
||||
# Rebind all ZLE widgets to make them invoke _zsh_highlights.
|
||||
_zsh_highlight_bind_widgets()
|
||||
{
|
||||
# Load ZSH module zsh/zleparameter, needed to override user defined widgets.
|
||||
zmodload zsh/zleparameter 2>/dev/null || {
|
||||
echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
|
||||
return 1
|
||||
if [[ $_history_substring_search_zsh_5_9 -eq 1 ]] && _history-substring-search-function-callable add-zle-hook-widget; then
|
||||
#
|
||||
# The following code is based on the zsh-syntax-highlighting plugin.
|
||||
#
|
||||
autoload -U add-zle-hook-widget
|
||||
|
||||
_history-substring-search-zle-line-finish() {
|
||||
#
|
||||
# Reset $WIDGET since the 'main' highlighter depends on it.
|
||||
#
|
||||
# Since $WIDGET is declared by zle as read-only in this function's scope,
|
||||
# a nested function is required in order to shadow its built-in value;
|
||||
# see "User-defined widgets" in zshall.
|
||||
#
|
||||
() {
|
||||
local -h -r WIDGET=zle-line-finish
|
||||
_zsh_highlight
|
||||
}
|
||||
}
|
||||
|
||||
# Override ZLE widgets to make them invoke _zsh_highlight.
|
||||
local cur_widget
|
||||
for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|yank*)}; do
|
||||
case $widgets[$cur_widget] in
|
||||
_history-substring-search-zle-line-pre-redraw() {
|
||||
#
|
||||
# If the zsh-syntax-highlighting plugin has been loaded (after our plugin
|
||||
# plugin, otherwise this hook wouldn't be called), remove our hooks.
|
||||
#
|
||||
if [[ $+ZSH_HIGHLIGHT_VERSION -eq 1 ]]; then
|
||||
autoload -U add-zle-hook-widget
|
||||
add-zle-hook-widget -d zle-line-pre-redraw _history-substring-search-zle-line-pre-redraw
|
||||
add-zle-hook-widget -d zle-line-finish _history-substring-search-zle-line-finish
|
||||
return 0
|
||||
fi
|
||||
#
|
||||
# Set $? to 0 for _zsh_highlight. Without this, subsequent
|
||||
# zle-line-pre-redraw hooks won't run, since add-zle-hook-widget happens to
|
||||
# call us with $? == 1 in the common case.
|
||||
#
|
||||
true && _zsh_highlight "$@"
|
||||
}
|
||||
|
||||
# Already rebound event: do nothing.
|
||||
user:$cur_widget|user:_zsh_highlight_widget_*);;
|
||||
if [[ -o zle ]]; then
|
||||
add-zle-hook-widget zle-line-pre-redraw _history-substring-search-zle-line-pre-redraw
|
||||
add-zle-hook-widget zle-line-finish _history-substring-search-zle-line-finish
|
||||
fi
|
||||
else
|
||||
#
|
||||
# The following snippet was taken from the zsh-syntax-highlighting project:
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/56b134f5d62ae3d4e66c7f52bd0cc2595f9b305b/zsh-syntax-highlighting.zsh#L126-161
|
||||
#
|
||||
# SPDX-SnippetBegin
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
# SPDX-SnippetCopyrightText: 2010-2011 zsh-syntax-highlighting contributors
|
||||
#--------------8<-------------------8<-------------------8<-----------------
|
||||
# Rebind all ZLE widgets to make them invoke _zsh_highlights.
|
||||
_zsh_highlight_bind_widgets()
|
||||
{
|
||||
# Load ZSH module zsh/zleparameter, needed to override user defined widgets.
|
||||
zmodload zsh/zleparameter 2>/dev/null || {
|
||||
echo 'zsh-syntax-highlighting: failed loading zsh/zleparameter.' >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
# User defined widget: override and rebind old one with prefix "orig-".
|
||||
user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \
|
||||
_zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
# Override ZLE widgets to make them invoke _zsh_highlight.
|
||||
local cur_widget
|
||||
for cur_widget in ${${(f)"$(builtin zle -la)"}:#(.*|_*|orig-*|run-help|which-command|beep|yank*)}; do
|
||||
case $widgets[$cur_widget] in
|
||||
|
||||
# Completion widget: override and rebind old one with prefix "orig-".
|
||||
completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \
|
||||
_zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
# Already rebound event: do nothing.
|
||||
user:$cur_widget|user:_zsh_highlight_widget_*);;
|
||||
|
||||
# Builtin widget: override and make it call the builtin ".widget".
|
||||
builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
# User defined widget: override and rebind old one with prefix "orig-".
|
||||
user:*) eval "zle -N orig-$cur_widget ${widgets[$cur_widget]#*:}; \
|
||||
_zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
|
||||
# Default: unhandled case.
|
||||
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
#-------------->8------------------->8------------------->8-----------------
|
||||
# Completion widget: override and rebind old one with prefix "orig-".
|
||||
completion:*) eval "zle -C orig-$cur_widget ${${widgets[$cur_widget]#*:}/:/ }; \
|
||||
_zsh_highlight_widget_$cur_widget() { builtin zle orig-$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
|
||||
_zsh_highlight_bind_widgets
|
||||
# Builtin widget: override and make it call the builtin ".widget".
|
||||
builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \
|
||||
zle -N $cur_widget _zsh_highlight_widget_$cur_widget";;
|
||||
|
||||
# Default: unhandled case.
|
||||
*) echo "zsh-syntax-highlighting: unhandled ZLE widget '$cur_widget'" >&2 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
#-------------->8------------------->8------------------->8-----------------
|
||||
# SPDX-SnippetEnd
|
||||
|
||||
_zsh_highlight_bind_widgets
|
||||
fi
|
||||
|
||||
unfunction _history-substring-search-function-callable
|
||||
fi
|
||||
|
||||
_history-substring-search-begin() {
|
||||
|
|
@ -243,10 +295,17 @@ _history-substring-search-begin() {
|
|||
fi
|
||||
|
||||
#
|
||||
# Escape and join query parts with wildcard character '*' as separator
|
||||
# `(j:CHAR:)` join array to string with CHAR as separator
|
||||
# Escape and join query parts with wildcard character '*' as seperator
|
||||
# `(j:CHAR:)` join array to string with CHAR as seperator
|
||||
#
|
||||
local search_pattern="*${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||
local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"
|
||||
|
||||
#
|
||||
# Support anchoring history search to the beginning of the command
|
||||
#
|
||||
if [[ -z $HISTORY_SUBSTRING_SEARCH_PREFIXED ]]; then
|
||||
search_pattern="*${search_pattern}"
|
||||
fi
|
||||
|
||||
#
|
||||
# Find all occurrences of the search pattern in the history file.
|
||||
|
|
@ -304,12 +363,21 @@ _history-substring-search-begin() {
|
|||
_history-substring-search-end() {
|
||||
setopt localoptions extendedglob
|
||||
|
||||
local highlight_memo=
|
||||
_history_substring_search_result=$BUFFER
|
||||
|
||||
if [[ $_history_substring_search_zsh_5_9 -eq 1 ]]; then
|
||||
highlight_memo='memo=history-substring-search'
|
||||
fi
|
||||
|
||||
# the search was successful so display the result properly by clearing away
|
||||
# existing highlights and moving the cursor to the end of the result buffer
|
||||
if [[ $_history_substring_search_refresh_display -eq 1 ]]; then
|
||||
region_highlight=()
|
||||
if [[ -n $highlight_memo ]]; then
|
||||
region_highlight=( "${(@)region_highlight:#*${highlight_memo}*}" )
|
||||
else
|
||||
region_highlight=()
|
||||
fi
|
||||
CURSOR=${#BUFFER}
|
||||
fi
|
||||
|
||||
|
|
@ -329,7 +397,9 @@ _history-substring-search-end() {
|
|||
if [[ $query_part_match_index -le ${#BUFFER:$highlight_start_index} ]]; then
|
||||
highlight_start_index=$(( $highlight_start_index + $query_part_match_index ))
|
||||
highlight_end_index=$(( $highlight_start_index + ${#query_part} ))
|
||||
region_highlight+=("$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) $_history_substring_search_query_highlight")
|
||||
region_highlight+=(
|
||||
"$(($highlight_start_index - 1)) $(($highlight_end_index - 1)) ${_history_substring_search_query_highlight}${highlight_memo:+,$highlight_memo}"
|
||||
)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
|
@ -338,6 +408,23 @@ _history-substring-search-end() {
|
|||
# zle -R "mn: "$_history_substring_search_match_index" m#: "${#_history_substring_search_matches}
|
||||
# read -k -t 200 && zle -U $REPLY
|
||||
|
||||
#
|
||||
# When this function returns, z-sy-h runs its line-pre-redraw hook. It has no
|
||||
# logic for determining highlight priority, when two different memo= marked
|
||||
# region highlights overlap; instead, it always prioritises itself. Below is
|
||||
# a workaround for dealing with it.
|
||||
#
|
||||
if [[ $_history_substring_search_zsh_5_9 -eq 1 ]]; then
|
||||
zle -R
|
||||
#
|
||||
# After line redraw with desired highlight, wait for timeout or user input
|
||||
# before removing search highlight and exiting. This ensures no highlights
|
||||
# are left lingering after search is finished.
|
||||
#
|
||||
read -k -t ${HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_TIMEOUT:-1} && zle -U $REPLY
|
||||
region_highlight=( "${(@)region_highlight:#*${highlight_memo}*}" )
|
||||
fi
|
||||
|
||||
# Exit successfully from the history-substring-search-* widgets.
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,129 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# update-from-upstream.zsh
|
||||
#
|
||||
# This script updates the Oh My Zsh version of the zsh-history-substring-search
|
||||
# plugin from the independent upstream repo. This is to be run by OMZ developers
|
||||
# when they want to pull in new changes from upstream to OMZ. It is not run
|
||||
# during normal use of the plugin.
|
||||
#
|
||||
# The official upstream repo is zsh-users/zsh-history-substring-search
|
||||
# https://github.com/zsh-users/zsh-history-substring-search
|
||||
#
|
||||
# This is a zsh script, not a function. Call it with `zsh update-from-upstream.zsh`
|
||||
# from the command line, running it from within the plugin directory.
|
||||
#
|
||||
# You can set the environment variable REPO_PATH to point it at an upstream
|
||||
# repo you have already prepared. Otherwise, it will do a clean checkout of
|
||||
# upstream's HEAD to a temporary local repo and use that.
|
||||
|
||||
|
||||
# Just bail on any error so we don't have to do extra checking.
|
||||
# This is a developer-use script, so terse output like that should
|
||||
# be fine.
|
||||
set -e
|
||||
|
||||
|
||||
upstream_basename=zsh-history-substring-search
|
||||
plugin_basename=history-substring-search
|
||||
UPSTREAM_REPO=zsh-users/$upstream_basename
|
||||
need_repo_cleanup=false
|
||||
upstream_github_url="https://github.com/$UPSTREAM_REPO"
|
||||
|
||||
if [[ -z "$UPSTREAM_REPO_PATH" ]]; then
|
||||
# Do a clean checkout
|
||||
my_tempdir=$(mktemp -d -t omz-update-histsubstrsrch)
|
||||
UPSTREAM_REPO_PATH="$my_tempdir/$upstream_basename"
|
||||
git clone "$upstream_github_url" "$UPSTREAM_REPO_PATH"
|
||||
need_repo_cleanup=true
|
||||
print "Checked out upstream repo to $UPSTREAM_REPO_PATH"
|
||||
else
|
||||
print "Using existing $upstream_basename repo at $UPSTREAM_REPO_PATH"
|
||||
fi
|
||||
|
||||
upstream="$UPSTREAM_REPO_PATH"
|
||||
|
||||
# Figure out what we're pulling in
|
||||
upstream_sha=$(cd $upstream && git rev-parse HEAD)
|
||||
upstream_commit_date=$(cd $upstream && git log -1 --pretty=format:%ci)
|
||||
upstream_just_date=${${=upstream_commit_date}[1]}
|
||||
print "upstream SHA: $upstream_sha"
|
||||
print "upstream commit time: $upstream_commit_date"
|
||||
print "upstream commit date: $upstream_just_date"
|
||||
print
|
||||
|
||||
# Copy the files over, using the OMZ plugin's names where needed
|
||||
cp -v "$upstream"/* .
|
||||
mv -v zsh-history-substring-search.zsh $plugin_basename.zsh
|
||||
mv -v zsh-history-substring-search.plugin.zsh $plugin_basename.plugin.zsh
|
||||
|
||||
if [[ $need_repo_cleanup == true ]]; then
|
||||
print "Removing temporary repo at $my_tempdir"
|
||||
rm -rf "$my_tempdir"
|
||||
fi
|
||||
|
||||
# Do OMZ-specific edits
|
||||
|
||||
print
|
||||
print "Updating files with OMZ-specific stuff"
|
||||
print
|
||||
|
||||
# OMZ binds the keys as part of the plugin loading
|
||||
|
||||
cat >> $plugin_basename.plugin.zsh <<EOF
|
||||
|
||||
|
||||
# Bind terminal-specific up and down keys
|
||||
|
||||
if [[ -n "\$terminfo[kcuu1]" ]]; then
|
||||
bindkey -M emacs "\$terminfo[kcuu1]" history-substring-search-up
|
||||
bindkey -M viins "\$terminfo[kcuu1]" history-substring-search-up
|
||||
fi
|
||||
if [[ -n "\$terminfo[kcud1]" ]]; then
|
||||
bindkey -M emacs "\$terminfo[kcud1]" history-substring-search-down
|
||||
bindkey -M viins "\$terminfo[kcud1]" history-substring-search-down
|
||||
fi
|
||||
|
||||
EOF
|
||||
|
||||
# Tack OMZ-specific notes on to readme
|
||||
|
||||
thin_line="------------------------------------------------------------------------------"
|
||||
cat >> README.md <<EOF
|
||||
|
||||
$thin_line
|
||||
Oh My Zsh Distribution Notes
|
||||
$thin_line
|
||||
|
||||
What you are looking at now is Oh My Zsh's repackaging of zsh-history-substring-search
|
||||
as an OMZ module inside the Oh My Zsh distribution.
|
||||
|
||||
The upstream repo, $UPSTREAM_REPO, can be found on GitHub at
|
||||
$upstream_github_url.
|
||||
|
||||
This downstream copy was last updated from the following upstream commit:
|
||||
|
||||
SHA: $upstream_sha
|
||||
Commit date: $upstream_commit_date
|
||||
|
||||
Everything above this section is a copy of the original upstream's README, so things
|
||||
may differ slightly when you're using this inside OMZ. In particular, you do not
|
||||
need to set up key bindings for the up and down arrows yourself in \`~/.zshrc\`; the OMZ
|
||||
plugin does that for you. You may still want to set up additional emacs- or vi-specific
|
||||
bindings as mentioned above.
|
||||
|
||||
EOF
|
||||
|
||||
# Announce success and generate git commit messages
|
||||
|
||||
cat <<EOF
|
||||
Done OK
|
||||
|
||||
Now you can check the results and commit like this:
|
||||
|
||||
git add *
|
||||
git commit -m "history-substring-search: update to upstream version $upstream_just_date" \\
|
||||
-m "Updates OMZ's copy to commit $upstream_sha from $UPSTREAM_REPO"
|
||||
|
||||
EOF
|
||||
|
||||
|
|
@ -8,8 +8,10 @@
|
|||
#
|
||||
export MARKPATH=$HOME/.marks
|
||||
|
||||
|
||||
jump() {
|
||||
builtin cd -P "$MARKPATH/$1" 2>/dev/null || {echo "No such mark: $1"; return 1}
|
||||
local markpath="$(readlink $MARKPATH/$1)" || {echo "No such mark: $1"; return 1}
|
||||
builtin cd "$markpath" 2>/dev/null || {echo "Destination does not exist for mark [$1]: $markpath"; return 2}
|
||||
}
|
||||
|
||||
mark() {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@ One can rename default context name for better readability.
|
|||
|
||||
_Example_. Add to **.zshrc**:
|
||||
```
|
||||
kubectx_mapping[minikube]="mini"
|
||||
kubectx_mapping[context_name_from_kubeconfig]="$emoji[wolf_face]"
|
||||
kubectx_mapping[production_cluster]="%{$fg[yellow]%}prod!%{$reset_color%}"
|
||||
kubectx_mapping["minikube"]="mini"
|
||||
kubectx_mapping["context_name_from_kubeconfig"]="$emoji[wolf_face]"
|
||||
kubectx_mapping["production_cluster"]="%{$fg[yellow]%}prod!%{$reset_color%}"
|
||||
```
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ function kubectx_prompt_info() {
|
|||
|
||||
# use value in associative array if it exists
|
||||
# otherwise fall back to the context name
|
||||
echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
|
||||
echo "${kubectx_mapping[\"$current_ctx\"]:-${current_ctx:gs/%/%%}}"
|
||||
}
|
||||
|
|
|
|||
46
plugins/ssh/ssh.plugin.zsh
Normal file
46
plugins/ssh/ssh.plugin.zsh
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
############################################################
|
||||
# Take all host sections in .ssh/config and offer them for
|
||||
# completion as hosts (e.g. for ssh, rsync, scp and the like)
|
||||
# Filter out wildcard host sections.
|
||||
_ssh_configfile="$HOME/.ssh/config"
|
||||
if [[ -f "$_ssh_configfile" ]]; then
|
||||
_hosts=($(egrep '^Host.*' "$_ssh_configfile" | awk '{print $2}' | grep -v '^*' | sed -e 's/\.*\*$//'))
|
||||
zstyle ':completion:*:hosts' hosts $_hosts
|
||||
unset _hosts
|
||||
fi
|
||||
unset _ssh_configfile
|
||||
|
||||
############################################################
|
||||
# Remove host key from known hosts based on a host section
|
||||
# name from .ssh/config
|
||||
function ssh_rmhkey {
|
||||
local ssh_configfile="$HOME/.ssh/config"
|
||||
local ssh_host="$1"
|
||||
if [[ -z "$ssh_host" ]]; then return; fi
|
||||
ssh-keygen -R $(grep -A10 "$ssh_host" "$ssh_configfile" | grep -i HostName | head -n 1 | awk '{print $2}')
|
||||
}
|
||||
compctl -k hosts ssh_rmhkey
|
||||
|
||||
############################################################
|
||||
# Load SSH key into agent
|
||||
function ssh_load_key() {
|
||||
local key="$1"
|
||||
if [[ -z "$key" ]]; then return; fi
|
||||
local keyfile="$HOME/.ssh/$key"
|
||||
local keysig=$(ssh-keygen -l -f "$keyfile")
|
||||
if ( ! ssh-add -l | grep -q "$keysig" ); then
|
||||
ssh-add "$keyfile"
|
||||
fi
|
||||
}
|
||||
|
||||
############################################################
|
||||
# Remove SSH key from agent
|
||||
function ssh_unload_key {
|
||||
local key="$1"
|
||||
if [[ -z "$key" ]]; then return; fi
|
||||
local keyfile="$HOME/.ssh/$key"
|
||||
local keysig=$(ssh-keygen -l -f "$keyfile")
|
||||
if ( ssh-add -l | grep -q "$keysig" ); then
|
||||
ssh-add -d "$keyfile"
|
||||
fi
|
||||
}
|
||||
9
plugins/stripe/README.md
Normal file
9
plugins/stripe/README.md
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Struoe
|
||||
|
||||
This plugin provides completion for the [Stripe CLI](https://stripe.com/docs/stripe-cli).
|
||||
|
||||
To use it add stripe to the plugins array in your zshrc file.
|
||||
|
||||
```bash
|
||||
plugins=(... stripe)
|
||||
```
|
||||
13
plugins/stripe/stripe.plugin.zsh
Normal file
13
plugins/stripe/stripe.plugin.zsh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
if (( ! $+commands[stripe] )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `stripe`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_stripe" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _stripe
|
||||
_comps[stripe]=_stripe
|
||||
fi
|
||||
|
||||
stripe completion --shell zsh --write-to-stdout >| "$ZSH_CACHE_DIR/completions/_stripe" &|
|
||||
|
|
@ -4,7 +4,7 @@ alias st=subl
|
|||
alias stt='subl .'
|
||||
|
||||
# Define sst only if sudo exists
|
||||
(( $+commands[sudo] )) && alias sst='sudo subl'
|
||||
(( $+commands[sudo] )) && alias sst='sudo -EH subl'
|
||||
|
||||
alias stp=find_project
|
||||
alias stn=create_project
|
||||
|
|
@ -62,7 +62,7 @@ alias stn=create_project
|
|||
for _sublime_path in $_sublime_paths; do
|
||||
if [[ -a $_sublime_path ]]; then
|
||||
alias subl="'$_sublime_path'"
|
||||
(( $+commands[sudo] )) && alias sst="sudo '$_sublime_path'"
|
||||
(( $+commands[sudo] )) && alias sst="sudo -EH '$_sublime_path'"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
|
|||
|
|
@ -88,4 +88,5 @@ if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
|
|||
# http://zsh.sourceforge.net/Doc/Release/Functions.html
|
||||
autoload -U add-zsh-hook
|
||||
add-zsh-hook chpwd workon_cwd
|
||||
[[ $PWD != ~ ]] && workon_cwd
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# VS Code
|
||||
|
||||
This plugin provides useful aliases to simplify the interaction between the command line and VS Code or VSCodium editor.
|
||||
This plugin provides useful aliases to simplify the interaction between the command line and VS Code or
|
||||
VSCodium editor.
|
||||
|
||||
To start using it, add the `vscode` plugin to your `plugins` array in `~/.zshrc`:
|
||||
|
||||
|
|
@ -14,26 +15,30 @@ This plugin requires to have a flavour of VS Code installed and it's executable
|
|||
|
||||
You can install either:
|
||||
|
||||
* VS Code (code)
|
||||
* VS Code Insiders (code-insiders)
|
||||
* VSCodium (codium)
|
||||
- VS Code (code)
|
||||
- VS Code Insiders (code-insiders)
|
||||
- VSCodium (codium)
|
||||
|
||||
### MacOS
|
||||
|
||||
While Linux installations will add the executable to PATH, MacOS users might still have to do this manually:
|
||||
|
||||
[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line), open
|
||||
the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
|
||||
[For VS Code and VS Code Insiders](https://code.visualstudio.com/docs/setup/mac#_launching-from-the-command-line),
|
||||
open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
|
||||
|
||||
> Shell Command: Install 'code' command in PATH
|
||||
|
||||
[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal), open
|
||||
the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
|
||||
[For VSCodium](https://github.com/VSCodium/vscodium/blob/master/DOCS.md#how-do-i-open-vscodium-from-the-terminal),
|
||||
open the Command Palette via (F1 or ⇧⌘P) and type shell command to find the Shell Command:
|
||||
|
||||
> Shell Command: Install 'codium' command in PATH
|
||||
|
||||
## Using multiple flavours
|
||||
|
||||
If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code Insiders, you can
|
||||
manually specify the flavour's executable. Add the following line to the .zshrc file (between the `ZSH_THEME` and the `plugins=()` lines).
|
||||
This will make the plugin use your manually defined executable.
|
||||
If for any reason, you ever require to use multiple flavours of VS Code i.e. VS Code (stable) and VS Code
|
||||
Insiders, you can manually specify the flavour's executable. Add the following line to the .zshrc file
|
||||
(between the `ZSH_THEME` and the `plugins=()` lines). This will make the plugin use your manually defined
|
||||
executable.
|
||||
|
||||
```zsh
|
||||
ZSH_THEME=...
|
||||
|
|
@ -61,6 +66,7 @@ source $ZSH/oh-my-zsh.sh
|
|||
| vscr | code --reuse-window | Force to open a file or folder in the last active window. |
|
||||
| vscw | code --wait | Wait for the files to be closed before returning. |
|
||||
| vscu `dir` | code --user-data-dir `dir` | Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code. |
|
||||
| vscp `profile` | code --profile `profile` | Specifies the profile to open Code with. |
|
||||
|
||||
## Extensions aliases
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
# https://github.com/MarsiBarsi (original author)
|
||||
# https://github.com/babakks
|
||||
# https://github.com/SteelShot
|
||||
# https://github.com/AliSajid
|
||||
|
||||
# Verify if any manual user choice of VS Code exists first.
|
||||
if [[ -n "$VSCODE" ]] && ! which $VSCODE &>/dev/null; then
|
||||
|
|
@ -38,6 +39,7 @@ alias vscn="$VSCODE --new-window"
|
|||
alias vscr="$VSCODE --reuse-window"
|
||||
alias vscw="$VSCODE --wait"
|
||||
alias vscu="$VSCODE --user-data-dir"
|
||||
alias vscp="$VSCODE --profile"
|
||||
|
||||
alias vsced="$VSCODE --extensions-dir"
|
||||
alias vscie="$VSCODE --install-extension"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ Available search contexts are:
|
|||
| `scholar` | `https://scholar.google.com/scholar?q=` |
|
||||
| `ask` | `https://www.ask.com/web?q=` |
|
||||
| `youtube` | `https://www.youtube.com/results?search_query=` |
|
||||
| `deepl` | `https://www.deepl.com/translator#auto/auto/` |
|
||||
| `dockerhub` | `https://hub.docker.com/search?q=` |
|
||||
| `npmpkg` | `https://www.npmjs.com/search?q=` |
|
||||
| `packagist` | `https://packagist.org/?query=` |
|
||||
| `gopkg` | `https://pkg.go.dev/search?m=package&q=` |
|
||||
|
||||
Also there are aliases for bang-searching DuckDuckGo:
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@ function web_search() {
|
|||
scholar "https://scholar.google.com/scholar?q="
|
||||
ask "https://www.ask.com/web?q="
|
||||
youtube "https://www.youtube.com/results?search_query="
|
||||
deepl "https://www.deepl.com/translator#auto/auto/"
|
||||
dockerhub "https://hub.docker.com/search?q="
|
||||
npmpkg "https://www.npmjs.com/search?q="
|
||||
packagist "https://packagist.org/?query="
|
||||
gopkg "https://pkg.go.dev/search?m=package&q="
|
||||
)
|
||||
|
||||
# check whether the search engine is supported
|
||||
|
|
@ -36,9 +41,14 @@ function web_search() {
|
|||
|
||||
# search or go to main page depending on number of arguments passed
|
||||
if [[ $# -gt 1 ]]; then
|
||||
# if search goes in the query string ==> space as +, otherwise %20
|
||||
# see https://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20
|
||||
local param="-P"
|
||||
[[ "$urls[$1]" == *\?*= ]] && param=""
|
||||
|
||||
# build search url:
|
||||
# join arguments passed with '+', then append to search engine URL
|
||||
url="${urls[$1]}$(omz_urlencode ${@[2,-1]})"
|
||||
url="${urls[$1]}$(omz_urlencode $param ${@[2,-1]})"
|
||||
else
|
||||
# build main page url:
|
||||
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
|
||||
|
|
@ -68,6 +78,11 @@ alias archive='web_search archive'
|
|||
alias scholar='web_search scholar'
|
||||
alias ask='web_search ask'
|
||||
alias youtube='web_search youtube'
|
||||
alias deepl='web_search deepl'
|
||||
alias dockerhub='web_search dockerhub'
|
||||
alias npmpkg='web_search npmpkg'
|
||||
alias packagist='web_search packagist'
|
||||
alias gopkg='web_search gopkg'
|
||||
|
||||
#add your own !bang searches here
|
||||
alias wiki='web_search duckduckgo \!w'
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# the svn plugin has to be activated for this to work.
|
||||
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)"
|
||||
PROMPT='${ret_status}%{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
|
||||
PROMPT='%{${ret_status}%}%{$fg_bold[green]%} %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}$(svn_prompt_info)%{$reset_color%}'
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
|
|
|
|||
|
|
@ -6,10 +6,15 @@ local current_dir="%B%{$fg[blue]%}%~ %{$reset_color%}"
|
|||
local vcs_branch='$(git_prompt_info)$(hg_prompt_info)'
|
||||
local rvm_ruby='$(ruby_prompt_info)'
|
||||
local venv_prompt='$(virtualenv_prompt_info)'
|
||||
if [[ "${plugins[@]}" =~ 'kube-ps1' ]]; then
|
||||
local kube_prompt='$(kube_ps1)'
|
||||
else
|
||||
local kube_prompt=''
|
||||
fi
|
||||
|
||||
ZSH_THEME_RVM_PROMPT_OPTIONS="i v g"
|
||||
|
||||
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}
|
||||
PROMPT="╭─${user_host}${current_dir}${rvm_ruby}${vcs_branch}${venv_prompt}${kube_prompt}
|
||||
╰─%B${user_symbol}%b "
|
||||
RPROMPT="%B${return_code}%b"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue