0

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 !

0

2 Answers 2

2

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 automatically
  • p 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
0

For the benefit of future readers here is my setup. Based on @nohillside 's answer I used Automator to create a service that runs the (bash) shell script:

sed -n 'p;s/./-/gp'

That makes it easy to add a keyboard shortcut that can be accessed from text editors. Here it is:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .