-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase.sh
113 lines (91 loc) · 1.83 KB
/
base.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
fn_exists() {
test "$(type -t "$1")" = 'function'
return $?
}
maybesource() {
if [ -f "$1" ]; then
echo "sourcing $1..."
source "$1"
elif [ -d "$1" ]; then
for i in $(ls "$1"); do
maybesource "$1/$i"
done
fi
}
audio_ext='ogg'
maybesource "$(pwd)/.diary100rc"
maybesource "~/.diary100rc"
fn_exists com-sig || com-sig() {
echo "$(whoami)@$(hostname): $(date)"
}
beep() {
tput bel
}
# check differences
chkdiff() {
if [ $(git status --porcelain -uno | wc -l) -gt 0 ]; then
return 0
else
return 1
fi
}
# ensure/existing commit
ecom() {
if ! chkdiff; then
echo "You don't have any changes to commit. Not committing."
else
git status && git commit -m "$(com-sig)"
fi
}
# quick commit
qcom() {
if chkdiff; then
git status
echo "You already have some changes that you haven't committed. Not adding any more files."
else
git add -A && ecom
fi
}
LAST_DIARY100_FILE=""
# quick edit
qed() {
nano "$1"
maybe_add "$1"
return $?
}
maybe_add() {
if dialog --yesno "Commit changes to this file?" 0 0; then
LAST_DIARY100_FILE="$1"
git add "$LAST_DIARY100_FILE" && ecom
return $?
fi
return 1
}
fn_exists audio_filename || audio_filename() {
echo "audio/$(date -u +%F_%H_%M_%S)-$1.${audio_ext}"
}
qrec() {
echo "Press Ctrl-C to stop"
arecord -c 2 -r 96000 "$1.tmp"
ffmpeg -loglevel error -f wav -i "$1.tmp" -af loudnorm "$1"
rm "$1.tmp"
}
# quick play (autoexit)
qplay() {
ffplay -autoexit "$1"
}
# long play
lplay() {
vlc "file:///$(pwd)/$1"
}
# quick audio
qad() {
newfilename="$(audio_filename "$1")"
qrec "$newfilename"
lplay "$newfilename"
if ! maybe_add "$newfilename"; then
rm "$newfilename"
return 1
fi
}