1

I'm using the following formatting for echo Screenshot of the terminal appearance

It should output text that is both bold and underlined, but instead of making it bold it's giving a 'brighter' variant of color and takes the underlined code (4) as if it was cyan, resulting in Light Cyan text.

I'm using Cygwin's Bash on a windows 7 PC.

Edit: I've found a link that appears relevant to my case but I'm not sure how it applies since they're taking about the windows 10 update bash while I'm using Cygwin's enter link description here

Dazcii
  • 41
  • 4
  • 2
    Possible duplicate of [How does one output bold text in Bash?](https://stackoverflow.com/questions/2924697/how-does-one-output-bold-text-in-bash) – Aserre Nov 29 '18 at 13:38
  • replacing your `¥e` sequences by `\033` works for me – Aserre Nov 29 '18 at 13:39
  • @Aserre I tried \033 and \E as well, the yen sign is the equivalent of backslash for the system locale I'm using and it hasn't proven an issue yet so I don't believe that is the problem but if there are known issues that arise due to changing system locale please do let know. – Dazcii Nov 29 '18 at 13:58
  • 1
    What terminal are you using ? Mintty produces the expect "Bold and underlined" while on CMD produces cyan. – matzeri Nov 29 '18 at 20:36
  • @matzeri Yes, this is exactly it, I found Mintty in my pc (within the cygwin directory/folders) and it produced the output I needed when entering the same command, I more or less understand that the shell and terminal are separate things, but then does that mean bash uses CMD by default? can I change that somehow? by the way I don't really specify a terminal(?) I just open the bash executable as it is – Dazcii Nov 29 '18 at 22:43

2 Answers2

2

It seems you are running bash through the old cygwin.bat, so you are using the Windows Console as terminal, and not through the default Mintty that is a more advanced Terminal.

By default Cygwin setup install the "Cygwin Terminal" entry in the windows menu

The content of the menu entry is like

C:\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

with path like

C:\cygwin64\bin

These items can be a also recreated at the last step of cygwin setup running. There are two box entries :

□ Create icon on Desktop
□ Add icon to Start Menu

If you enable them, both will be recreated

matzeri
  • 8,062
  • 2
  • 15
  • 16
1

I have this in my profile :

## NORMAL
export NORMAL=$(tput sgr0)

## FOREGROUND
export FGBLACK=$(tput setaf 0)
export FGRED=$(tput setaf 1)
export FGGREEN=$(tput setaf 2)
export FGYELLOW=$(tput setaf 3)
export FGBLUE=$(tput setaf 4)
export FGMAGENTA=$(tput setaf 5)
export FGCYAN=$(tput setaf 6)
export FGWHITE=$(tput setaf 7)
export FGBRIGHT=$(tput bold)
export FGNORMAL=$(tput sgr0)
export FGBOLD=$(tput bold)

## BACKGROUND
export BGBLACK=$(tput setab 0)
export BGRED=$(tput setab 1)
export BGGREEN=$(tput setab 2)
export BGYELLOW=$(tput setab 3)
export BGBLUE=$(tput setab 4)
export BGMAGENTA=$(tput setab 5)
export BGCYAN=$(tput setab 6)
export BGWHITE=$(tput setab 7)

## SHAPE
export SHUNDERLINE=$(tput smul)
export SHBOLD=$(tput bold)
export SHSBOLD=$(tput smso)

So I can easily use it in the command line or in my scripts. For instance :

#!/bin/bash

echo "This is ${FGRED}foreground red${NORMAL}"
echo "This is ${BGRED}background red${NORMAL}"
echo "This is ${FGYELLOW}${BGRED}background red and foreground yellow${NORMAL}"
echo "This is ${SHUNDERLINE}underlined${NORMAL}"
echo "This is ${FGCYAN}${SHUNDERLINE}cyan underlined${NORMAL}"
echo "This is ${SHBOLD}bold${NORMAL}"
echo "This is ${SHUNDERLINE}${SHBOLD}underlined bold${NORMAL}"
echo "This is ${FGBLUE}${SHBOLD}blue bold${NORMAL} and this ${FGBLUE} normal blue${NORMAL}"
echo "This is ${SHSBOLD}standout bold${NORMAL}"

Which results in outputs like this :

enter image description here

Hope its useful for you!

Matias Barrios
  • 4,674
  • 3
  • 22
  • 49