Server IP : 51.89.169.208 / Your IP : 216.73.216.94 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/root/proc/thread-self/root/usr/share/zsh/5.5.1/functions/ |
Upload File : |
# Split a command line into shell arguments and whitespace in $reply. # Odd elements (starting from 1) are whitespace, even elements # are shell arguments (possibly quoted strings). Whitespace at # start and end is always included in the array but may be an empty string. # $REPLY holds NO_KSH_ARRAYS index of current word in $reply. # $REPLY2 holds NO_KSH_ARRAYS index of current character in current word. # Hence ${reply[$REPLY][$REPLY2]} is the character under the cursor. # # reply, REPLY, REPLY2 should therefore be local to the enclosing function. emulate -L zsh setopt extendedglob local -a bufwords lbufwords local word integer pos=1 cpos=$((CURSOR+1)) opos iword ichar bufwords=(${(Z+n+)BUFFER}) typeset -ga reply reply=() while [[ ${BUFFER[pos]} = [[:space:]] ]]; do (( pos++ )) done reply+=${BUFFER[1,pos-1]} (( cpos < pos )) && (( iword = 1, ichar = cpos )) for word in "${bufwords[@]}"; do (( opos = pos )) (( pos += ${#word} )) reply+=("$word") if (( iword == 0 && cpos < pos )); then (( iword = ${#reply} )) (( ichar = cpos - opos + 1 )) fi (( opos = pos )) while [[ ${BUFFER[pos]} = [[:space:]] ]]; do (( pos++ )) done reply+=("${BUFFER[opos,pos-1]}") if (( iword == 0 && cpos < pos )); then (( iword = ${#reply} )) (( ichar = cpos - opos + 1 )) fi done typeset -g REPLY REPLY2 if (( iword == 0 )); then # At the end of the line, so off the indexable positions # (but still a valid cursor position). (( REPLY = ${#reply} )) (( REPLY2 = 1 )) else (( REPLY = iword )) (( REPLY2 = ichar )) fi