Re-join lines based on Emacs style backslash line continuation indicators
|
|
||
|---|---|---|
| ejoin.go | initial commit | |
| go.mod | initial commit | |
| README.md | Add sed snippet as an alternative. | |
ejoin as a very simple program to re-join lines based on Emacs style backslash (\) line continuation markers.
I use it to extract URLs from terminal emulators that support piping
the current terminal pane into an external script, for example
st with the
externalpipe patch or
foot's
pipe-command-output option.
Example pipelines using xurls:
# Open an URL selected using dmenu
ejoin | xurls | tac | uniq | dmenu -i -l 20 -w $WINDOWID | xargs -r browse.sh
# Open the last URL
ejoin | xurls | tail -n 1 | xargs -r browse.sh
# Open all URLs
ejoin | xurls | uniq | xargs -r browse.sh
Alternative implementation using sed:
sed ':a;N;s/\\\n//;ta;P;D'