Bash

Bash Line Drawing Characters

Here are a few cool escape sequences:

 

echo -e "\033(0" # Set line drawing mode
echo -e "\033(B" # Set Text mode

 

Colorizing 'cat' with source-highlight, dump code in color

I always wanted to colorize a 'cat' of a file (lord knows why?!), but tonight, I figured out how to do it!

What you need

You need to install the packages

  • highlight
  • source-highlight

In Fedora, its as easy as

yum install -y highlight source-highlight

After this is complete, generate the script called 'scat' in /usr/bin:

#!/bin/bash
INFILE="$1"

if [ -n "$2" ]; then
        OPTS="-S $2"
fi

highlight $INFILE -A $OPTS

 

 

Colorized Console man Viewer

Here is a little trick to colorize man pages. Place these lines in your .bashrc file (~/.bashrc):

 

export LESS_TERMCAP_mb=$'\E[01;31m'       # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
export LESS_TERMCAP_me=$'\E[0m'           # end mode
export LESS_TERMCAP_se=$'\E[0m'           # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m'    # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m'           # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline

Then the output of man looks like this:

Syndicate content