-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewsboat.tmux
executable file
·55 lines (45 loc) · 1.26 KB
/
newsboat.tmux
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
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PLUGIN_DIR="$CURRENT_DIR" # required by scripts/helpers.sh
source "$CURRENT_DIR/scripts/helpers.sh"
interpolation_strings=(
"\#{newsboat_new_articles}"
"\#{newsboat_unread_articles}"
"\#{newsboat_unread_feeds}"
)
interpolation_commands=(
"#(cat '$(new_articles_file)')"
"#(cat '$(unread_articles_file)')"
"#(cat '$(unread_feeds_file)')"
)
create_default_files() {
mkdir -p "$(newsboat_dir)"
if [ ! -f "$(new_articles_file)" ]; then
echo "?" > "$(new_articles_file)"
fi
if [ ! -f "$(unread_articles_file)" ]; then
echo "?" > "$(unread_articles_file)"
fi
if [ ! -f "$(unread_feeds_file)" ]; then
echo "?" > "$(unread_feeds_file)"
fi
}
interpolate() {
local interpolated="$1"
local count="${#interpolation_commands[@]}"
for ((i=0; i<"$count"; i++)); do
interpolated=${interpolated//${interpolation_strings[$i]}/${interpolation_commands[$i]}}
done
echo "$interpolated"
}
update_status_option() {
local option="$1"
local option_value="$(get_tmux_option "$option")"
set_tmux_option "$option" "$(interpolate "$option_value")"
}
main() {
create_default_files
update_status_option "status-right"
update_status_option "status-left"
}
main