-
Notifications
You must be signed in to change notification settings - Fork 0
/
clip_mb_new_entry-no_toot.sh
executable file
·54 lines (44 loc) · 1.32 KB
/
clip_mb_new_entry-no_toot.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
#
# make a new entry for the microblog
# this is for the cases where you want to tweak stuff and then
# post elsewhere afterwards, therefore the post text is put onto
# the clipboard and you can then ctrl+v it wherever (say into the
# mastodon web-interface)
# this is a stopgap measure untill I figure out an automatic way
# to include Content Warnings/Notes into my posting flow.
# set up my variables
today=$(date +%F);
now=$(date +%F\ %H:%M);
iterator=1;
filename=$today-$(printf "%02d" $iterator).md;
# go to working dir
cd ~/microblog/_posts;
# make sure we have the hottest newest latest
git pull;
# determine the first available file for today
while [ -f $filename ]
do iterator=$(($iterator+1));
filename=$today-$(printf "%02d" $iterator).md;
done
# create the file
touch $filename;
# pre-populate the file
echo '---' >> $filename;
echo -n 'date: ' >> $filename;
echo $now >> $filename;
echo '---' >> $filename;
echo >> $filename;
# start editing
vim +star +4 $filename;
# and upload
git add $filename;
git commit -a -m $iterator;
git push;
# put post text into clipboard, linux version
tail -n +4 $filename | xclip -r -selection clipboard
# if you're on termux, comment the previous line and uncomment the following one:
# termux-clipboard-set $(tail -n +4 $filename)
echo;
echo all done with $filename;
echo;