-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to send selected text to ad_repl
- Loading branch information
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |