Using iTerm2 on macOS here, and I don't think it's as predictable or reliable as one would like, but, for the record, here's a possible approach:
julia> using Colors
julia> function print_rgb(col, t)
colr = lowercase(hex(parse(Colorant, col)))
println(colr)
print("\033]Pg$(colr)\033\\", t)
end
julia> print_rgb("yellow", "hi there")
and this changes all foreground text to yellow. (The "g" after the "P" changes
the foreground color.) These escape codes are proprietary to iTerm, though.
