mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Added color support to taskie.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
73f634318f
commit
7a53e76d85
3 changed files with 64 additions and 2 deletions
48
inc/taskie/common.inc.sh
Normal file
48
inc/taskie/common.inc.sh
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
|
||||
|
||||
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"
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue