Prompt colours
Posted: 2018-01-12 Filed under: desktop, system | Tags: .bashrc, .bash_profile, .dir_colors, PS1 Leave a commentNow, I have set up my .bashrc and .bash_profile and I have colourful output in my terminal. I decided to customize things a just little bit more…
As a start, I copied the default colour scheme /etc/DIR_COLORS as ~/.dir_colors. I edited to my liking, for example, I do not want coloured files to be in bold.
Here it is (it’s long!):
# Configuration file for dircolors, a utility to help you set the
# LS_COLORS environment variable used by GNU ls with the --color option.
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
# slackware version of dircolors) are recognized but ignored.
# (see the scripts in /etc/profile.d/coreutils-dircolors.* to change default
# options in the Slackware aliases)
# Below, there should be one TERM entry for each termtype that is colorizable
TERM Eterm
TERM ansi
TERM color-xterm
TERM con132x25
TERM con132x30
TERM con132x43
TERM con132x60
TERM con80x25
TERM con80x28
TERM con80x30
TERM con80x43
TERM con80x50
TERM con80x60
TERM cons25
TERM console
TERM cygwin
TERM dtterm
TERM eterm-color
TERM gnome
TERM gnome-256color
TERM jfbterm
TERM konsole
TERM kterm
TERM linux
TERM linux-c
TERM mach-color
TERM mlterm
TERM putty
TERM rxvt
TERM rxvt-256color
TERM rxvt-cygwin
TERM rxvt-cygwin-native
TERM rxvt-unicode
TERM rxvt-unicode-256color
TERM rxvt-unicode256
TERM screen
TERM screen-256color
TERM screen-256color-bce
TERM screen-bce
TERM screen-w
TERM screen.linux
TERM screen.rxvt
TERM terminator
TERM vt100
TERM xterm
TERM xterm-16color
TERM xterm-256color
TERM xterm-88color
TERM xterm-color
TERM xterm-debian
# Below are the color init strings for the basic file types. A color init
# string consists of one or more of the following numeric codes:
# Attribute codes:
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
# Text color codes:
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
# Background color codes:
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
# RESET 0 # reset to "normal" color
DIR 01;34 # directory
LINK 00;36 # symbolic link. (If you set this to 'target' instead of a
# numerical value, the color is as for the file pointed to.)
# HARDLINK 44;37 # regular file with more than one link
FIFO 40;33 # pipe
SOCK 00;35 # socket
DOOR 00;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 40;31;01 # symlink to nonexistent file
SETUID 37;41 # file that is setuid (u+s)
SETGID 30;43 # file that is setgid (g+s)
CAPABILITY 30;41 # file with capability
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
EXEC 00;32 # This is for files with execute permission:
# List any file extensions like '.gz' or '.tar' that you would like ls
# to colorize below. Put the extension, a space, and the color init string.
# (and any comments you want to add after a '#')
# DOS-style executables (bright green)
.bat 00;32
.BAT 00;32
.btm 00;32
.BTM 00;32
.cmd 00;32
.CMD 00;32
.com 00;32
.COM 00;32
.dll 00;32
.DLL 00;32
.exe 00;32
.EXE 00;32
# archives or compressed (bright red)
.7z 00;31
.ace 00;31
.ACE 00;31
.arj 00;31
.bz2 00;31
.cpio 00;31
.deb 00;31
.dz 00;31
.gz 00;31
.jar 00;31
.lzh 00;31
.lzma 00;31
.rar 00;31
.RAR 00;31
.rpm 00;31
.rz 00;31
.tar 00;31
.taz 00;31
.tb2 00;31
.tbz2 00;31
.tbz 00;31
.tgz 00;31
.tlz 00;31
.trz 00;31
.txz 00;31
.tz 00;31
.tz2 00;31
.xz 00;31
.z 00;31
.Z 00;31
.zip 00;31
.ZIP 00;31
.zoo 00;31
# multimedia (video/image/sound) file formats
.aac 00;35
.AAC 00;35
.anx 00;35
.asf 00;35
.ASF 00;35
.au 00;35
.axa 00;35
.axv 00;35
.avi 00;35
.AVI 00;35
.bmp 00;35
.BMP 00;35
.divx 00;35
.DIVX 00;35
.flac 00;35
.FLAC 00;35
.gif 00;35
.GIF 00;35
.jpg 00;35
.JPG 00;35
.jpeg 00;35
.JPEG 00;35
.m2a 00;35
.M2A 00;35
.m2v 00;35
.M2V 00;35
.m4a 00;35
.M4A 00;35
.m4p 00;35
.M4P 00;35
.m4v 00;35
.M4V 00;35
.mid 00;35
.midi 00;35
.mka 00;35
.mkv 00;35
.MKV 00;35
.mov 00;35
.MOV 00;35
.mp3 00;35
.MP3 00;35
.mp4 00;35
.MP4 00;35
.mp4v 00;35
.mpc 00;35
.MPC 00;35
.mpeg 00;35
.MPEG 00;35
.mpg 00;35
.MPG 00;35
.nuv 00;35
.oga 00;35
.ogv 00;35
.ogx 00;35
.ogg 00;35
.OGG 00;35
.pbm 00;35
.pgm 00;35
.png 00;35
.PNG 00;35
.ppm 00;35
.qt 00;35
.ra 00;35
.RA 00;35
.ram 00;35
.RAM 00;35
.rm 00;35
.RM 00;35
.spx 00;35
.svg 00;35
.svgz 00;35
.tga 00;35
.TGA 00;35
.tif 00;35
.TIF 00;35
.tiff 00;35
.TIFF 00;35
.vob 00;35
.VOB 00;35
.wav 00;35
.WAV 00;35
.wma 00;35
.WMA 00;35
.wmv 00;35
.WMV 00;35
.xbm 00;35
.xcf 00;35
.xpm 00;35
.xspf 00;35
.xwd 00;35
.XWD 00;35
.xvid 00;35
A final touch was editing my .bashrc and setting up my own PS1 line. Extensive information is available at the excellent Gentoo wiki. Specifically, these are the placeholders that can be used in the PS1 variable:
\u Username. \h Hostname. \w Current directory. \d Current date. \t Current time. \$ Indicate the root user with '#' and normal users with '$'. \j Number of currently running tasks (jobs).
Colour codes are as follows:
\e[0;30m\] Black \e[0;31m\] Red \e[0;32m\] Green \e[0;33m\] Yellow \e[0;34m\] Blue \e[0;35m\] Magenta \e[0;36m\] Cyan \e[0;37m\] White \e[0m\] Reset to standard colors
So I ended up with the following PS1 line:
. /etc/profile export VISUAL=nano export EDITOR=nano PS1='\u@\h \[[\e[1;34m\]\W/\[\e[0m\]] \$ '
This plainly shows the user log in and the current directory in blue. I do not want the full path to the current directory, therefore I used capital W in the \W option.
