more zsh style code

This commit is contained in:
skywind3000 2018-02-08 02:55:05 +08:00
parent f06305c948
commit 491aff3a51
2 changed files with 6 additions and 0 deletions

View file

@ -65,8 +65,11 @@ _zsh_autosuggest_strategy_predefined() {
emulate -L zsh emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
# search the history at first
local result="${history[(r)${prefix}*]}" local result="${history[(r)${prefix}*]}"
# search the predefine files if nothing found in history
if [[ -z "$result" ]]; then if [[ -z "$result" ]]; then
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=() typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()

View file

@ -631,8 +631,11 @@ _zsh_autosuggest_strategy_predefined() {
emulate -L zsh emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}" local prefix="${1//(#m)[\\*?[\]<>()|^~#]/\\$MATCH}"
# search the history at first
local result="${history[(r)${prefix}*]}" local result="${history[(r)${prefix}*]}"
# search the predefine files if nothing found in history
if [[ -z "$result" ]]; then if [[ -z "$result" ]]; then
if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then if (( ! ${+_ZSH_AUTOSUGGEST_PREDEFINE} )); then
typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=() typeset -g _ZSH_AUTOSUGGEST_PREDEFINE=()