File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /usr/local/bin/bash
2
+ # shellcheck disable=SC2154
3
+
4
+ # <bitbar.title>Home Config</bitbar.title>
5
+ # <bitbar.version>v1.0</bitbar.version>
6
+ # <bitbar.author>Kodie Grantham</bitbar.author>
7
+ # <bitbar.author.github>kodie</bitbar.author.github>
8
+ # <bitbar.desc>Example of how to mimic the functionality of the home-config npm module in a bash BitBar plugin</bitbar.desc>
9
+ # <bitbar.dependencies>bash4</bitbar.dependencies>
10
+ # <bitbar.abouturl>https://github.com/kodie/bitbar-home-config</bitbar.abouturl>
11
+
12
+ typeset -A cfg
13
+ cfg[home_config,color]=" red"
14
+ cfg[home_config,text]=" Try editing $HOME /.bitbarrc"
15
+
16
+ cfgFile=" $HOME /.bitbarrc"
17
+ if [ ! -e " $cfgFile " ]; then touch " $cfgFile " ; fi
18
+ while read -r cfgLine; do
19
+ if [[ -z $cfgLine ]]; then continue ; fi
20
+ if [[ ${cfgLine: 0: 1} == ' [' ]]; then cfgKey=${cfgLine: 1:- 1} ;
21
+ else IFS=' =' ; cfgVar=($cfgLine ); unset IFS; cfg[$cfgKey ,${cfgVar[0]} ]=${cfgVar[1]} ; fi
22
+ done < " $cfgFile "
23
+
24
+ echo " Config Example | dropdown=false color=${cfg[home_config,color]} "
25
+ echo " ---"
26
+ echo " ${cfg[home_config,text]} "
You can’t perform that action at this time.
0 commit comments