[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Temporary color prompt in bash script



On Mon 02 Sep 2019 at 08:48:50 (+0200), Computer Planet wrote:
> Thanks guys, 
> but this is not the solution I'm looking for ...

It's always nice to get feedback on why, so that we're more likely
to understand similar questions in future. For example, you never
really explained whether "command no problem, write in red until exit
or reboot" was something you want (everything red, or just prompts
in red?) or something you don't want (nothing red after the one
string) and whether you rebooted to clear a problem demonstrate that
red prompts were lost (against your wishes). We don't read minds.

> Now, I ask the question in other terms:
> Is It possible to print of a string at the exit of a bash script?
> e.g.: user@mypc: # bash script has just finished! [prompt] 
> with the prompt that remains immediately after the string printed.
> 
> Thanks, as always, for reply.

Sure:

$ ./my-script ; echo -n "the string"

or:

$ ./my-script ; echo -n -e "\e[0;31mthe string\e[m"

if you want "the string" in red.

So, using cat to stand for your script, and sleep to stand for the
time it takes your script to run:

wren!david 12:46:59 ~ $ cat /etc/network/interfaces ; date ; sleep 5 ; echo -n -e "\e[0;31mthe string\e[m"
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

#
Mon Sep  2 12:47:01 CDT 2019
the stringwren!david 12:47:06 ~ $ 

Cheers,
David.


Reply to: