1

My workflow involves lots of lists. I think in lists, I write my notes in lists.

An example note in my apple notes might look like

Here are the commands I need to Run!

  • echo "this is a command"
  • cat /tmp/some_file.txt

And very often I highlight the bullet point line, copy it, and paste it elsewhere. In this example, I would be pasting it in a terminal.

What really frustrates me is that every time I copy the line, the pasted output looks like this:

- echo "this is a command"
- cat /tmp/some_file.txt

The leading hyphen needs to be manually removed each time. It causes a lot of wasted time for me. I wonder if there is a way to copy a line of text in a bullet point without the leading hyphen?

2
  • There's a workaround, but it's equally annoying. Copy the line without the last character. This then pastes without the list mark. It also works if the last char is a space. [That would suggest that the 'indicator' is in the CR/LF somewhere]
    – Tetsujin
    Jan 12 at 17:39
  • 1
    @Tetsujin nice find. My workaround was actually inserting a space at the beginning and omitting that when copy+pasting. Also annoying but I like yours a little better Jan 23 at 18:30

1 Answer 1

1

With the bulleted text already on your clipboard, this following command in Terminal.app will remove the first 2 characters (the hyphen and the following space) from each line that is currently on the clipboard and copies that back to your clipboard.

pbpaste |sed 's/^..//g' |pbcopy

So instead of typing the above command every single time… in Terminal.app, you can create an alias for that full command so your new alias would run the full command.

For example in the following code, i assign the keys pt to run the full command.

alias pt='pbpaste |sed 's/^..//g' |pbcopy'

NOTE: In Terminal.app, before creating a custom alias, make sure it is not already being used so as to not over write an already existing command. To check if pt as I used above, isn't already being used, the command type pt lets me know if it has been already assigned or not.

So now in Terminal.app, when i type the command pt it removes the first 2 characters from my clipboard.

Now anywhere I decide to paste the text, the bullet or hyphen and the following space will be removed.

So now If I want to paste the "un-bulleted" text in Terminal, I type the command pt then hit Enter then Command + v.

It will really come in handy if you have multiple lines with bullets on your clipboard

OPTION 2: (My Choice)

Create a new Automator.app Quick Action and add a "Run Shell Script" action to the workflow. Next, paste this following code into that new Action.

osascript -e 'tell application "System Events" to keystroke "c" using {command down}' ; sleep 1 ; pbpaste |sed 's/^..//g' |pbcopy

enter image description here

Then save the new Quick Action. (I saved mine as "Remove_Leading_Bullets.workflow")

Now in System Settings, I can assign my new Quick Action a keyboard shortcut (I used ⌃P)

enter image description here

Now anytime I have bulleted text selected in any app, pressing the keyboard shortcut ^P (control + p) will copy the currently selected text with the first 2 characters (hyphen and space)removed so now I can paste into Terminal or wherever else.

You must log in to answer this question.

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