-
-
Save iandundas/7863c6c248f76e14a3a8 to your computer and use it in GitHub Desktop.
# strip out iBooks citation | |
sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g' | sed -E -e 's/^(Excerpt From).*//g' |
The correct code should be this, as noted above:
sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g' | sed -E -e 's/^(Excerpt From).*//g' | tr -d '\n'
It doesn't work with multi-line code as all new line characters are removed by tr
. I found a great solution from this link:
sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g' | sed -E -e 's/^(Excerpt From).*//g' | awk '/^$/ {nlstack=nlstack "\n";next;} {printf "%s",nlstack; nlstack=""; print;}'
sixtyonePRIME's instructions worked for me in Apr 2021. A very big help.
Don't forget to restart iBooks after setting up the shortcut in System Preferences.
Hey folks!
This script has stopped working fine after updating to macOS Monterey.
I believe it's related to the new original output format.
“Currying is similar to partial application”
Excerpt From
Functional-Light JavaScript: Balanced, Pragmatic FP in JavaScript
Kyle Simpson
This material may be protected by copyright.
Any ideas on how to get it working with the new output format?
same here, need help!
Hey folks!
This script has stopped working fine after updating to macOS Monterey.
I believe it's related to the new original output format.
“Currying is similar to partial application” Excerpt From Functional-Light JavaScript: Balanced, Pragmatic FP in JavaScript Kyle Simpson This material may be protected by copyright.
Any ideas on how to get it working with the new output format?
When using the proposal form @iandundas, I run into the issue, that the clipboard is stacking up with all the copied content. Therefore you have to delete the "Get Contents of Clipboard" step in Automator.
Here is a step by step guide (the screenshots are in German, but you get the point):
(You can see Step 2-4 in the Screenshot below Step 4)
2. Change following in the headers first row (leave the remaining rows as they are)
2.1. Workflow receives current: chosse "text"
2.2. in: choose Application "Books"
3.1. Choose "/bin/zsh" in Shell
3.2. Add this following script:
# strip out iBooks citation sed -E -e 's/^[ ]?[0-9]* //g' | sed -E -e 's/“[ ]?[0-9]?[ ]?//g' | sed -E -e 's/”$//g' | sed -E -e 's/^(Excerpt From).*//g'
Attention: If you work in German language, then change "Excerpt From" with "Auszug von" in the script. This is valid also for other languages, just change the needed translation for "Excerpt From"
Save the script with your desired name.
Now go to the system settings to the keyboard and select tap "Shortcuts"
6.1. On the left side select "Services" and make sure that on the ride side your scriptname is selected
6.2. Add a new shortcut for this script.