-
Notifications
You must be signed in to change notification settings - Fork 6
/
simple_bookmarker.sh
36 lines (30 loc) · 1.19 KB
/
simple_bookmarker.sh
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
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# A super simple bookmarking system.
# $ bk "https://coollink.com" # saves a link
# $ bkls # easy way to view links from this month
# This is half a step above pasting links into a plain text file.
# Made because most bookmarking systems are made to work for the use case of
# "I'll use this once a week for the next semester" rather than
# "Someday in the future I want to read this!"
# Pocket kind of works for that but I found the advertisements to be pretty invasive.
# Where bookmarks should be stored
bookmarks=~/bookmarks
# list current months bookmarks
bkls () {
name=$bookmarks/$(date +%b%Y | tr [:upper:] [:lower:]).txt
cat $name
}
# bookmark following text.
# Be careful of not quoting, if you use a "*" for instance it will expand as normal unless quoted,
# and you'll only realize it when you're looking through your bookmarks later.
bk () {
mkdir -p $bookmarks/backups
name=$bookmarks/$(date +%b%Y | tr [:upper:] [:lower:]).txt
backupname=$bookmarks/backups/$(date +%F).txt.bak
echo "making backup in $backupname"
cp $name $backupname
before=$(wc -l < $name)
echo $* >> $name
after=$(wc -l < $name)
echo "$before before, $after after in $name"
}