1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00
nux-env/inc/taskie/common.inc.sh
Tony Tkacik 7a53e76d85 Added color support to taskie.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2017-06-21 12:06:50 +02:00

48 lines
876 B
Bash

taskie.issue.display.short() {
local id="$1";
local state="$2";
shift;
shift;
echo -n "$id ";
taskie.state.colorized "$state" " ";
for arg in "$@"
do
local before="";
local after="";
if [[ "$arg" =~ "#" ]]; then
taskie.label.colorized "$arg" " "
else
echo -n "$arg"
fi
done
echo
}
taskie.colorized() {
local color_path="$1"
local message="$2"
local afterMessage="$3"
local before=""
local after=""
color=$(nux.cfg.read colors.$color_path)
if [ -n "$color" ]; then
color_var="nc_$color"
if [ -n "${!color_var}" ]; then
before=${!color_var}
after=$nc_end
fi
fi
echo -n "${before}${message}${after}${afterMessage}"
}
taskie.state.colorized() {
taskie.colorized state.$1 "$1" "$2"
}
taskie.label.colorized() {
local label=${1#"#"}
taskie.colorized labels.$label "$1" "$2"
}