Service to underline plain text with a line of dashes
-
02-06-2021 - |
Question
I am looking for a text service that I can call from a plain text editor (BBedit for example) and will operate the following modification:
Before:
This is a line of text
After:
This is a line of text
----------------------
Thanks !
Solution
BBedit can execute shell commands on selected text, so adapting something like
echo 'This is a line of text' | sed -n 'p;s/./-/gp'
to make it work when called from BBedit should work.
sed -n
runs sed without echoing its input automaticallyp
is the first command applied to the input, it just prints the input (technically the content of the pattern space)s/./-/gp
is the second command, it replaces all characters in the pattern space by-
and prints the result
Licensed under: CC-BY-SA with attribution
Not affiliated with apple.stackexchange