-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadsquery
More file actions
executable file
·26 lines (19 loc) · 773 Bytes
/
adsquery
File metadata and controls
executable file
·26 lines (19 loc) · 773 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash
# Program to query the Astrophysics Data System (NASA/ADS) via the terminal.
# Currently accepts author:"^Author, First", year:YYYY style queries.
# DONE: Fix zero-input string behaviour!
# Defining our web browser.
DMBROWSER="brave"
# Ask for a query.
# The <&- is to close STDIN.
query=$(dmenu -c -bw 2 -p "Enter your ADS query" <&- | sed "s/,//g")
# Check if the query is empty
[ -z $query ] && exit
# Refine the query.
author=$(echo $query | awk '{print $1}')
year=$(echo $query | awk '{print $NF}')
# Prepare the query with HTML encoding.
url="https://ui.adsabs.harvard.edu/search/q="
webquery="author%3A\"%5E$author\"%2C%20year%3A$year&sort=citation_count%20desc%2C%20bibcode%20desc&p_=0"
# Launch the browswer
$DMBROWSER "$url""$webquery"