2022-01-30 07:22:24 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-02-22 13:46:25 -06:00
|
|
|
x=$(tmux capture-pane -p -S '-' -J -t !)
|
2022-01-30 07:22:24 -06:00
|
|
|
readarray -t pane_contents <<<"$x"
|
|
|
|
|
|
|
|
# reverse loop through pane contents lines
|
|
|
|
for (( idx=${#pane_contents[@]}-2 ; idx>=0 ; idx-- )) ; do
|
|
|
|
line=${pane_contents[idx]}
|
|
|
|
|
|
|
|
# strip trailing whitespace from line
|
|
|
|
line=$(sed 's/[[:space:]]*$//' <<<"$line")
|
|
|
|
|
2022-02-22 13:46:25 -06:00
|
|
|
if [[ $line =~ "$PROMPT_PATTERN" ]]; then
|
2022-01-30 07:22:24 -06:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
# prepend line to result array
|
|
|
|
result="$line"$'\n'"$result"
|
|
|
|
done
|
|
|
|
|
|
|
|
EDITOR_CMD=${EDITOR_CMD:-"$EDITOR -"}
|
|
|
|
|
|
|
|
echo "$result" | $EDITOR_CMD
|