I use a coloured bash prompt like so:
blue=$(tput setaf 4) reset=$(tput sgr0) bold=$(tput bold) export PS1='($?) \[$bold$blue\]\u@\h:\w\[$reset\]$(__git_ps1)> '
I usually work in a terminal window (gnome-terminal) but sometimes in a full-screen console (CTRL+ALT+F3).
My coloured prompt is fine in the GUI terminal but hard to read in full-screen because the colours look different. So I'd like to use a different colour (e.g.
cyan=$(tput setaf 6)), when in console window. For this to work I need to figure out which mode I'm currently in and set my
I tried the
tty command. It gives
/dev/pts/0 # GUI terminal /dev/tty3 # console
I also tried to examine the value of
$TERM. It gives
xterm-256color # GUI terminal linux # console
Both of them would work for me but my question is: Is that the correct way to reliably distinguish console vs. terminal or are there better ways? I'm on 17.10.1 if that matters.