Files
RedBear-OS/recipes/shells/zsh/source/Functions/Zle/replace-argument
T
vasilito ff4ff35918 feat: track all source trees in git — full fork offline-first model
Red Bear OS is a full fork. All sources must be available from git clone
with zero network access. Removed gitignore rules that excluded fetched
source trees under recipes/*/source/, local/recipes/kde/*/source/,
local/recipes/qt/*/source/, and vendor source trees.

Build artifacts (target/, build/, source.tar, *.o, *.so) remain excluded.

127291 files added — kernel, relibc, base, bootloader, pkgar, all KDE/Qt
frameworks, mesa, wayland, DRM drivers, and every other recipe source.
2026-05-14 10:55:53 +01:00

49 lines
1.1 KiB
Plaintext

# Replace an argument to a command, delimited by normal shell syntax.
# Prompts for the replacement.
# With no numeric argument, replace the current argument.
# With a numeric argument, replace that argument: 0 = command word,
# as in history expansion.
# If editing buffer is empty, use previous history line.
autoload -Uz split-shell-arguments read-from-minibuffer
if (( ${#BUFFER} == 0 )); then
(( HISTNO-- ))
CURSOR=${#BUFFER}
fi
local widget=$WIDGET numeric
integer cursor=CURSOR
if (( ${+NUMERIC} )); then
numeric=$NUMERIC
fi
local reply REPLY REPLY2
integer index
split-shell-arguments
if [[ -n $numeric ]]; then
if (( numeric < 0 )); then
(( index = ${#reply} - 1 + 2*(numeric+1) ))
else
(( index = 2 + 2*numeric ))
fi
else
(( index = REPLY & ~1 ))
fi
local edit
if [[ $widget = *edit* ]]; then
edit=$reply[$index]
fi
read-from-minibuffer "Replace $reply[$index] with: " $edit || return 1
integer diff=$(( ${#REPLY} - ${#reply[$index]} ))
reply[$index]=$REPLY
BUFFER=${(j..)reply}
if (( cursor > REPLY2 )); then
(( CURSOR = cursor + diff ))
else
(( CURSOR = REPLY2 ))
fi