Skip to content

Commit

Permalink
use zsh word parsing to remove assignments and not regex
Browse files Browse the repository at this point in the history
  • Loading branch information
MenkeTechnologies committed May 25, 2022
1 parent 2c12cd7 commit 1b5b8f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 4 additions & 0 deletions zpwrExpandApi.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ function zpwrExpandParseWords(){
firstIndex=$((i + 1))
break
;;
*=*)
#remove assignment
mywordsleft[$i]=()
;;
'>'* | '<'* | '&>'*)
#remove redirection operator from left words
mywordsleft[$i]=()
Expand Down
6 changes: 1 addition & 5 deletions zsh-expand.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,17 @@ fi
(){
local ws='[:space:]'
local l='[:graph:]'
ZPWR_VARS[lvalueRegex]="[$l]+="
ZPWR_VARS[startQuoteRegex]='(\$''|[\\"''])*'
ZPWR_VARS[endQuoteRegex]='["'']*'
local sq=${ZPWR_VARS[startQuoteRegex]}
local eq=${ZPWR_VARS[endQuoteRegex]}
ZPWR_VARS[rvalueRegex]='((\$''|["'']).*["'']|[[:graph:]]*)'
ZPWR_VARS[assignRegex]="(${ZPWR_VARS[lvalueRegex]}${ZPWR_VARS[rvalueRegex]}[$ws]+)*"
local a=${ZPWR_VARS[assignRegex]}

ZPWR_VARS[blacklistFirstPosRegex]='^(omz_history|grc|_z|zshz|cd|hub|_zsh_tmux_|_rails_|_rake_|mvn-or|gradle-or|noglob |rlwrap ).*$'

ZPWR_VARS[blacklistSubcommandPositionRegex]='^(cargo|jenv|svn|git|ng|pod|docker|kubectl|rndc|yarn|npm|pip[0-9\.]*|bundle|rails|gem|nmcli|brew|apt|dnf|yum|zypper|pacman|service|proxychains[0-9\.]*|zpwr|zm|zd|zg|zinit)$'
# the main regex to match x=1 \builtin* 'command'* '"sudo"' -* y=2 \env* -* z=3 cmd arg1 arg2 etc

ZPWR_VARS[continueFirstPositionRegexNoZpwr]="^([$ws]*)${a}((${sq}builtin${eq}[$ws]+)*${sq}${ZPWR_VARS[builtinSkips]}${eq})?([$ws]*)((${sq}[sS][uU][dD][oO]${eq}([$ws]+)(${sq}(-[ABbEHnPSis]+${eq}[$ws]*|-[CghpTu][$ws=]+[$l]*${eq}[$ws]+|--${eq})*)*)*${a}(${sq}[eE][nN][vV]${eq}[$ws]+${sq}(-[iv]+${eq}[$ws]*|-[PSu][$ws=]+[$l]*${eq}[$ws]+|--${eq})*)*${a})*([$ws]*)(.*)$"
ZPWR_VARS[continueFirstPositionRegexNoZpwr]="^([$ws]*)((${sq}builtin${eq}[$ws]+)*${sq}${ZPWR_VARS[builtinSkips]}${eq})?([$ws]*)((${sq}[sS][uU][dD][oO]${eq}([$ws]+)(${sq}(-[ABbEHnPSis]+${eq}[$ws]*|-[CghpTu][$ws=]+[$l]*${eq}[$ws]+|--${eq})*)*)*(${sq}[eE][nN][vV]${eq}[$ws]+(${sq}-[iv]+${eq}[$ws]*|-[PSu][$ws=]+[$l]*${eq}[$ws]+|--${eq})*)*)*([$ws]*)(.*)$"
}


Expand Down

0 comments on commit 1b5b8f8

Please sign in to comment.