This page looks best with JavaScript enabled

exa: An improved ls with colors

 ·  🎃 kr0m

The exa utility will allow us to list the files in a more visual and colorful way, acting as a replacement for the well-known ls command.

To display file icons with exa, we must install compatible fonts. Some of them are nerd-fonts and powerline-fonts:

pkg install nerd-fonts powerline-fonts exa

Choose a font from the list:
https://github.com/ryanoasis/nerd-fonts
https://github.com/powerline/fonts

Here’s a script to easily test all the fonts by modifying the Xresources file. Just keep in mind that the last 3 lines of the Xresources file must be a blank line and two lines with the typography configuration. To move on to the next configuration, press Ctrl+d.

vi testFonts.sh

#!/usr/local/bin/bash

clear
IFS=$'\n'
total=$(fc-list | grep -e nerd-fonts -e powerline-fonts|wc -l|awk '{print$1}')
counter=1
for font_style in $(fc-list | grep -e nerd-fonts -e powerline-fonts | awk -F ":" '{print$2":"$3}'); do
	echo =========== Testing font: $counter/$total ===========
	let counter=$counter+1
	echo FONT_STYLE: $font_style
	fonts=$(echo $font_style|awk -F ":" '{print$1}')
	#echo FONTS: $fonts
	styles=$(echo $font_style|awk -F ":style=" '{print$2}')
	#echo STYLES: $styles
	for font in $(echo $fonts | tr "," "\n"); do
		#echo FONT: $font
		style_counter=0
		for style in $(echo $styles | tr "," "\n"); do
			#echo STYLE: $style
			N=$(wc -l .Xresources|awk '{print$1}')
			let N=$N-3

			if [ $style_counter -eq 0 ]; then
				# WITHOUT STYLE:
				let style_counter=$style_counter+1
				head -n $N ~/.Xresources > /tmp/.Xresources
				echo ----------------------------
				echo $font
				echo "" >> /tmp/.Xresources
				echo "URxvt.font: xft:$font:pixelsize=14:antialias=true" >> /tmp/.Xresources
				echo "URxvt.boldFont: xft:$font:pixelsize=14:antialias=true:style=bold" >> /tmp/.Xresources
				mv /tmp/.Xresources ~/.Xresources
				xrdb .Xresources
				urxvt -e bash -i -c "ls -la;bash"
			fi

			# WITH EACH STYLE:
			head -n $N ~/.Xresources > /tmp/.Xresources
			echo ----------------------------
			echo $font - $style
			echo "" >> /tmp/.Xresources
			echo "URxvt.font: xft:$font:pixelsize=14:antialias=true:style=$style" >> /tmp/.Xresources
			echo "URxvt.boldFont: xft:$font:pixelsize=14:antialias=true:style=bold" >> /tmp/.Xresources
			mv /tmp/.Xresources ~/.Xresources
			xrdb .Xresources
			urxvt -e bash -i -c "ls -la;bash"
		done
	done
done

My preferred fonts are:

FiraCode Nerd Font Mono
FuraCode Nerd Font Mono
VictorMono Nerd Font Mono
CaskaydiaCove Nerd Font Mono
mononoki Nerd Font Mono
Inconsolata Nerd Font Mono
LiterationMono Nerd Font Mono
FantasqueSansMono Nerd Font Mono
BitstreamVeraSansMono Nerd Font Mono
Cousine Nerd Font Mono
JetBrainsMono Nerd Font Mono
NotoMono Nerd Font Mono
BlexMono Nerd Font Mono
MesloLGS Nerd Font Mono
Hasklug Nerd Font Mono
DroidSansMono Nerd Font Mono
InconsolataLGC Nerd Font Mono
DejaVuSansMono Nerd Font Mono
Hack Nerd Font Mono
CodeNewRoman Nerd Font Mono
agave Nerd Font Mono
GoMono Nerd Font Mono
InconsolataGo Nerd Font Mono
SauceCodePro Nerd Font Mono
MesloLGSDZ Nerd Font Mono
JetBrainsMonoMedium Nerd Font Mono
AurulentSansMono Nerd Font Mono
Anonymice Nerd Font Mono

On the other hand, if we want some more unusual fonts, we can try the following:

VictorMono Nerd Font Mono - Italic
Monofurbold Nerd Font Mono
Iosevka - Oblique

With this simple script, we can test only a small group:

vi checkFonts.sh

#!/usr/local/bin/bash

clear
IFS=$'\n'

for font in $(<fonts.txt); do
    N=$(wc -l .Xresources|awk '{print$1}')
    let N=$N-3

    head -n $N ~/.Xresources > /tmp/.Xresources
    echo ----------------------------
    echo FONT: $font
    echo "" >> /tmp/.Xresources
    echo "URxvt.font: xft:$font:pixelsize=14:antialias=true" >> /tmp/.Xresources
    echo "URxvt.boldFont: xft:$font:pixelsize=14:antialias=true:style=bold" >> /tmp/.Xresources
    mv /tmp/.Xresources ~/.Xresources
    xrdb .Xresources
    urxvt -e bash -i -c "ls -la;bash"
done

Modify our Xresources configuration file to use the correct fonts:

vi .Xresources

URxvt.font: xft: FiraCode Nerd Font Mono:pixelsize=14:antialias=true:style=Regular
URxvt.boldFont: xft: FiraCode Nerd Font Mono:pixelsize=14:antialias=true:style=bold
xrdb .Xresources

Define which colors we want to use following the exa documentation:
https://the.exa.website/docs/colour-themes

In addition, we define an alias to replace ls with exa:

vi .bashrc
export EXA_COLORS="\
da=38;5;245:\
di=38;5;14:\
sn=38;5;28:\
sb=38;5;28:\
uu=38;5;40:\
un=38;5;160:\
gu=38;5;40:\
gn=38:5:160:\
bl=38;5;220:\
ur=37:\
uw=37:\
ux=37:\
ue=37:\
gr=37:\
gw=37:\
gx=37:\
tr=37:\
tw=37:\
tx=37:\
su=37:\
sf=37:\
xa=37"

alias ls='exa --icons'

Now, in another terminal, we execute an ls command and we will see the following result:

If you liked the article, you can treat me to a RedBull here