Skip to content

Instantly share code, notes, and snippets.

@lnznt
Created May 12, 2012 01:10
Show Gist options
  • Save lnznt/2663516 to your computer and use it in GitHub Desktop.
Save lnznt/2663516 to your computer and use it in GitHub Desktop.
[sample] terminal escape sequence (Ruby)
#!/usr/bin/env ruby
# -*- coding: UTF-8 -*-
puts "\e[0m" "escape sequence(0m)" "\e[m" # RESET or NORMAL
puts "\e[1m" "escape sequence(1m)" "\e[m" # BRIGHT or BOLD
puts "\e[2m" "escape sequence(2m)" "\e[m"
puts "\e[3m" "escape sequence(3m)" "\e[m"
puts "\e[4m" "escape sequence(4m)" "\e[m" # UNDERLINE
puts "\e[5m" "escape sequence(5m)" "\e[m"
puts "\e[6m" "escape sequence(6m)" "\e[m"
puts "\e[7m" "escape sequence(7m)" "\e[m" # NEGATIVE or INVERSE or REVERSE
puts "\e[30m" "escape sequence(30m)" "\e[m" # BLACK
puts "\e[31m" "escape sequence(31m)" "\e[m" # RED
puts "\e[32m" "escape sequence(32m)" "\e[m" # GREEN
puts "\e[33m" "escape sequence(33m)" "\e[m" # YELLOW
puts "\e[34m" "escape sequence(34m)" "\e[m" # BLUE
puts "\e[35m" "escape sequence(35m)" "\e[m" # MAGENTA
puts "\e[36m" "escape sequence(36m)" "\e[m" # CYAN
puts "\e[37m" "escape sequence(37m)" "\e[m" # WHITE
puts "\e[1;30m" "escape sequence(1;30m)" "\e[m" # BRIGHT;BLACK
puts "\e[1;31m" "escape sequence(1;31m)" "\e[m" # BRIGHT;RED
puts "\e[1;32m" "escape sequence(1;32m)" "\e[m" # BRIGHT;GREEN
puts "\e[1;33m" "escape sequence(1;33m)" "\e[m" # BRIGHT;YELLOW
puts "\e[1;34m" "escape sequence(1;34m)" "\e[m" # BRIGHT;BLUE
puts "\e[1;35m" "escape sequence(1;35m)" "\e[m" # BRIGHT;MAGENTA
puts "\e[1;36m" "escape sequence(1;36m)" "\e[m" # BRIGHT;CYAN
puts "\e[1;37m" "escape sequence(1;37m)" "\e[m" # BRIGHT;WHITE
puts "\e[40m" "escape sequence(40m)" "\e[m" # BLACK (BACKGROUND)
puts "\e[41m" "escape sequence(41m)" "\e[m" # RED (BACKGROUND)
puts "\e[42m" "escape sequence(42m)" "\e[m" # GREEN (BACKGROUND)
puts "\e[43m" "escape sequence(43m)" "\e[m" # YELLOW (BACKGROUND)
puts "\e[44m" "escape sequence(44m)" "\e[m" # BLUE (BACKGROUND)
puts "\e[45m" "escape sequence(45m)" "\e[m" # MAGENTA(BACKGROUND)
puts "\e[46m" "escape sequence(46m)" "\e[m" # CYAN (BACKGROUND)
puts "\e[47m" "escape sequence(47m)" "\e[m" # WHITE (BACKGROUND)
puts "\e[1;40m" "escape sequence(1;40m)" "\e[m" # BRIGHT;BLACK (BACKGROUND)
puts "\e[1;41m" "escape sequence(1;41m)" "\e[m" # BRIGHT;RED (BACKGROUND)
puts "\e[1;42m" "escape sequence(1;42m)" "\e[m" # BRIGHT;GREEN (BACKGROUND)
puts "\e[1;43m" "escape sequence(1;43m)" "\e[m" # BRIGHT;YELLOW (BACKGROUND)
puts "\e[1;44m" "escape sequence(1;44m)" "\e[m" # BRIGHT;BLUE (BACKGROUND)
puts "\e[1;45m" "escape sequence(1;45m)" "\e[m" # BRIGHT;MAGENTA(BACKGROUND)
puts "\e[1;46m" "escape sequence(1;46m)" "\e[m" # BRIGHT;CYAN (BACKGROUND)
puts "\e[1;47m" "escape sequence(1;47m)" "\e[m" # BRIGHT;WHITE (BACKGROUND)
# vi:set ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment