-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from Drew-Daniels/gcalcli-support
add segment for gcalcli
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ kurczynski | |
Alejandro Espinosa (Halbard) <[email protected]> | ||
TN Khanh <[email protected]> | ||
Skywarth <[email protected]> | ||
Drew Daniels <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Print next Google Calendar Event | ||
|
||
TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT_DEFAULT=1 | ||
|
||
generate_segmentrc() { | ||
read -d '' rccontents << EORC | ||
# gcalcli uses 24hr time format by default - if you want to see 12hr time format, set TMUX_POWERLINE_SEG_GCALCLI_MILITARY_TIME_DEFAULT to 0 | ||
export TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT="${TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT_DEFAULT}" | ||
EORC | ||
echo "$rccontents" | ||
} | ||
|
||
__process_settings() { | ||
if [ -z "$TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT" ]; then | ||
export TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT="${TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT_DEFAULT}" | ||
fi | ||
} | ||
|
||
run_segment() { | ||
if ! command -v gcalcli &> /dev/null | ||
then | ||
echo "'gcalcli' could not be found" | ||
return 1 | ||
fi | ||
__process_settings | ||
gcmd=(gcalcli agenda) | ||
if [[ $TMUX_POWERLINE_SEG_GCALCLI_24HR_TIME_FORMAT == 0 ]]; then | ||
gcmd+=(--no-military) | ||
fi | ||
"${gcmd[@]}" | head -2 | tail -1 | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' | sed -E 's/ +/ /g' | ||
return 0 | ||
} |