One of the things I discovered playing with tput last night trying some of this is that it will error if you don't have a terminal. ssh foo.example.com virsh start bar tput: No value for $TERM and no -T specified
To correct this using your example you can do: if [ -t 0 ] then prompt_term[0]=$(tput bold) prompt_term[1]=$(tput setaf 1) # red prompt_term[2]=$(tput sgr0) export PS1='\[${prompt_term[$(($??1:0))]}\]'"\w"'\[${prompt_term[2]}\]'" ==> " fi On Tue, May 23, 2023 at 7:10 AM Nick Clifton <ni...@redhat.com> wrote: > > >> What do people think overall? Are there other pros and cons of a color > >> prompt? > >> Any better ideas or direction? > > I like the idea of using tput to get the correct strings for > setting different terminal effects, so I now use: > > # Success prompt: > prompt_term[0]=$(tput bold) > > # Fail prompt: > prompt_term[1]=$(tput setaf 1) # red > > # Turn off all attributes > prompt_term[2]=$(tput sgr0) > > # Make the prompt reflect the exit status of the last command > export PS1='\[${prompt_term[$(($??1:0))]}\]'"\w"'\[${prompt_term[2]}\]'" > ==> " > > Cheers > Nick > _______________________________________________ > devel mailing list -- devel@lists.fedoraproject.org > To unsubscribe send an email to devel-le...@lists.fedoraproject.org > Fedora Code of Conduct: > https://docs.fedoraproject.org/en-US/project/code-of-conduct/ > List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines > List Archives: > https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org > Do not reply to spam, report it: > https://pagure.io/fedora-infrastructure/new_issue -- Jason Montleon | email: jmont...@redhat.com Red Hat, Inc. | gpg key: 0x069E3022 Cell: 508-496-0663 | irc: jmontleo / jmontleon _______________________________________________ devel mailing list -- devel@lists.fedoraproject.org To unsubscribe send an email to devel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue