Skip to content

Commit

Permalink
script to send selected text to ad_repl
Browse files Browse the repository at this point in the history
  • Loading branch information
davcam committed Nov 15, 2024
1 parent a503f46 commit ed7aac0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions data/contrib/sh/sendtoRepl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

source "$HOME/.ad/lib/ad.sh"

requireAd

# get id or ad_repl buffer
replbuf=$(9p read ad/buffers/index | grep win | cut -c 1)

# read in selected lines and get length
varin=$(bufRead "$bufid" dot)
nlines=$(echo "$varin" | wc -l)

# send to ad_repl buffer
echo "buffer $replbuf" | 9p write ad/ctl
echo "$varin" | bufWrite "$replbuf" body

# set lines sent as dot
echo '$-'"$nlines" | bufWrite "$replbuf" addr
echo '$-'"$nlines"',+'$((nlines-1)) | bufWrite "$replbuf" addr

# execute in repl
echo 'Execute' | 9p write ad/ctl

0 comments on commit ed7aac0

Please sign in to comment.