Skip to content

Commit b5ca3de

Browse files
kodietresni
authored andcommittedFeb 10, 2017
Added Home Config Example (matryer#692)
* Added Home Config Example * Make Home Config Tutorial executable
1 parent 4a5cbd6 commit b5ca3de

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
 

‎Tutorial/config.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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]}"

0 commit comments

Comments
 (0)
Please sign in to comment.