Skip to content

Commit dd54170

Browse files
razvanazamfireidehesa
authored andcommitted
feat(browsing): command for doi string parsing
This is an additional command based on my previous commit that scans the clipboard for doi strings (rather than waiting for the user to paste the string) and opens the corresponding resource. Signed-off-by: Razvan Azamfirei <azamfireirazvan@gmail.com> feat(browsing): command for doi string parsing This is a package that parses a doi string (unique digital object identifier used to identify academic, professional, and government information) and opens the corresponding resource.
1 parent 3c7c87d commit dd54170

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Find Paper
6+
# @raycast.mode silent
7+
8+
# Optional parameters:
9+
# @raycast.icon 📖
10+
# @raycast.packageName DOI
11+
12+
# Documentation:
13+
# @raycast.description Scans clipboard and opens DOI links in your browser
14+
# @raycast.author Razvan Azamfirei
15+
# @raycast.authorURL https://github.com/razvanazamfirei
16+
LINK="$(pbpaste)"
17+
REGEX="^doi: 10."
18+
if [[ "$LINK" =~ ^doi:10. ]]; then
19+
IN="$LINK"
20+
arrIN=("${IN//doi:/}")
21+
URL="https://doi.org/${arrIN[0]}"
22+
open "$URL"
23+
elif [[ "$LINK" =~ ^doi/10. ]]; then
24+
IN="$LINK"
25+
arrIN=("${IN//doi///}")
26+
URL="https://doi.org/${arrIN[0]}"
27+
open "$URL"
28+
elif [[ "$LINK" =~ ${REGEX} ]]; then
29+
IN="$LINK"
30+
arrIN=("${IN//doi: //}")
31+
URL="https://doi.org/${arrIN[0]}"
32+
open "$URL"
33+
elif [[ "$LINK" =~ ^10. ]]; then
34+
URL="https://doi.org/${LINK}"
35+
open "$URL"
36+
else
37+
echo "Please specify a DOI"
38+
exit 1
39+
fi

commands/web-searches/doi.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Find Paper
6+
# @raycast.mode silent
7+
8+
# Optional parameters:
9+
# @raycast.icon 📖
10+
# @raycast.argument1 { "type": "text", "placeholder": "DOI" }
11+
# @raycast.packageName DOI
12+
13+
# Documentation:
14+
# @raycast.description Parses and opens DOI links in your browser
15+
# @raycast.author Razvan Azamfirei
16+
# @raycast.authorURL https://github.com/razvanazamfirei
17+
LINK="$1"
18+
REGEX="^doi: 10."
19+
if [[ "$LINK" =~ ^doi:10. ]]; then
20+
IN="$LINK"
21+
arrIN=("${IN//doi:/}")
22+
URL="https://doi.org/${arrIN[0]}"
23+
open "$URL"
24+
elif [[ "$LINK" =~ ^doi/10. ]]; then
25+
IN="$LINK"
26+
arrIN=("${IN//doi///}")
27+
URL="https://doi.org/${arrIN[0]}"
28+
open "$URL"
29+
elif [[ "$LINK" =~ ${REGEX} ]]; then
30+
IN="$LINK"
31+
arrIN=("${IN//doi: //}")
32+
URL="https://doi.org/${arrIN[0]}"
33+
open "$URL"
34+
elif [[ "$LINK" =~ ^10. ]]; then
35+
URL="https://doi.org/${LINK}"
36+
open "$URL"
37+
else
38+
echo "Please specify a DOI"
39+
exit 1
40+
fi

0 commit comments

Comments
 (0)