-
Notifications
You must be signed in to change notification settings - Fork 1
/
addbmark
executable file
·45 lines (38 loc) · 935 Bytes
/
addbmark
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
#!/bin/bash
source $HOME/.config/robot/config
if [[ $1 == "--help" ]]; then
echo "add pass files for rofi-pass"
exit
else
if [[ -z $1 && -z $2 && -z $3 && -z $4 ]]; then
echo "Missing --name options. Try --help"
exit
else
if [[ $4 != *"://"* ]]; then
echo "not a valid URI scheme"
exit
fi
fi
fi
cd "${root}"
filename="$2"
url="$4"
group=$(find . \( ! -regex '.*/\..*' \) -type d | cut -c 3- | tail -n +2 | rofi -dmenu -p "Group > " -mesg "Choose Group or enter a new one > ")
val=$?
if [[ $val -eq 1 ]]; then
exit
else
:
fi
echo "Storing file ${filename} in group ${group}"
if [[ -d "$group" ]]; then
echo "${url}" > "${group}/${filename}"
else
mkdir -p "${group}"
echo "${url}" > "${group}/${filename}"
fi
if [[ -d .git ]]; then
cd "${root}"
git add "${group}/${filename}"
git commit -m "Added ${group}/${filename}"
fi