aboutsummaryrefslogtreecommitdiffstats
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rwxr-xr-xcli/colors.sh37
-rwxr-xr-xcli/colortest.bash39
-rwxr-xr-xcli/colortest.lua22
-rwxr-xr-xcli/colortest.pl365
-rwxr-xr-xcli/colortest.py18
-rwxr-xr-xcli/colortest.rb26
-rwxr-xr-xcli/colortest.sh53
-rwxr-xr-xcli/csv2json.py67
-rwxr-xr-xcli/jpegs2pdf.sh42
-rwxr-xr-xcli/pdfmerge.sh23
-rwxr-xr-xcli/shrinkpdf.sh56
-rwxr-xr-xcli/term_color.sh28
-rwxr-xr-xcli/term_color_2.sh32
-rwxr-xr-xcli/term_color_3.sh33
-rwxr-xr-xcli/unzip-gbk.py26
-rwxr-xr-xcli/vimpager85
16 files changed, 952 insertions, 0 deletions
diff --git a/cli/colors.sh b/cli/colors.sh
new file mode 100755
index 0000000..a28c261
--- /dev/null
+++ b/cli/colors.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# https://gist.github.com/esundahl/1651086
+
+function color_test {
+ # Daniel Crisman's ANSI color chart script from
+ # The Bash Prompt HOWTO: 6.1. Colours
+ # http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x329.html
+ #
+ # This function echoes a bunch of color codes to the
+ # terminal to demonstrate what's available. Each
+ # line is the color code of one forground color,
+ # out of 17 (default + 16 escapes), followed by a
+ # test use of that color on all nine background
+ # colors (default + 8 escapes).
+ #
+
+ T='gYw' # The test text
+
+ echo -e "\n 40m 41m 42m 43m\
+ 44m 45m 46m 47m"
+
+ for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' \
+ ' 32m' '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' \
+ ' 35m' '1;35m' ' 36m' '1;36m' ' 37m' '1;37m';
+ do
+ FG=${FGs// /}
+ echo -en " $FGs \033[$FG $T "
+ for BG in 40m 41m 42m 43m 44m 45m 46m 47m; do
+ echo -en "$EINS \033[$FG\033[$BG $T \033[0m"
+ done
+ echo;
+ done
+ echo
+}
+
+color_test
+
diff --git a/cli/colortest.bash b/cli/colortest.bash
new file mode 100755
index 0000000..c777b9e
--- /dev/null
+++ b/cli/colortest.bash
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+#
+# ANSI color scheme script featuring Space Invaders
+#
+# Original: http://crunchbang.org/forums/viewtopic.php?pid=126921%23p126921#p126921
+# Modified by lolilolicon
+#
+
+f=3 b=4
+for j in f b; do
+ for i in {0..7}; do
+ printf -v $j$i %b "\e[${!j}${i}m"
+ done
+done
+bld=$'\e[1m'
+rst=$'\e[0m'
+
+cat << EOF
+
+ $f1 ▀▄ ▄▀ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4 ▀▄ ▄▀ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
+ $f1 ▄█▀███▀█▄ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4 ▄█▀███▀█▄ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
+ $f1█▀███████▀█ $f2▀▀███▀▀███▀▀ $f3▀█▀██▀█▀ $f4█▀███████▀█ $f5▀▀███▀▀███▀▀ $f6▀█▀██▀█▀$rst
+ $f1▀ ▀▄▄ ▄▄▀ ▀ $f2 ▀█▄ ▀▀ ▄█▀ $f3▀▄ ▄▀ $f4▀ ▀▄▄ ▄▄▀ ▀ $f5 ▀█▄ ▀▀ ▄█▀ $f6▀▄ ▄▀$rst
+
+ $bld$f1▄ ▀▄ ▄▀ ▄ $f2 ▄▄▄████▄▄▄ $f3 ▄██▄ $f4▄ ▀▄ ▄▀ ▄ $f5 ▄▄▄████▄▄▄ $f6 ▄██▄ $rst
+ $bld$f1█▄█▀███▀█▄█ $f2███▀▀██▀▀███ $f3▄█▀██▀█▄ $f4█▄█▀███▀█▄█ $f5███▀▀██▀▀███ $f6▄█▀██▀█▄$rst
+ $bld$f1▀█████████▀ $f2▀▀▀██▀▀██▀▀▀ $f3▀▀█▀▀█▀▀ $f4▀█████████▀ $f5▀▀▀██▀▀██▀▀▀ $f6▀▀█▀▀█▀▀$rst
+ $bld$f1 ▄▀ ▀▄ $f2▄▄▀▀ ▀▀ ▀▀▄▄ $f3▄▀▄▀▀▄▀▄ $f4 ▄▀ ▀▄ $f5▄▄▀▀ ▀▀ ▀▀▄▄ $f6▄▀▄▀▀▄▀▄$rst
+
+
+ $f7▌$rst
+
+ $f7▌$rst
+
+ $f7 ▄█▄ $rst
+ $f7▄█████████▄$rst
+ $f7▀▀▀▀▀▀▀▀▀▀▀$rst
+
+EOF
diff --git a/cli/colortest.lua b/cli/colortest.lua
new file mode 100755
index 0000000..8f8c95f
--- /dev/null
+++ b/cli/colortest.lua
@@ -0,0 +1,22 @@
+#!/usr/bin/env lua
+
+function cl(e)
+ return string.format('\27[%sm', e)
+end
+
+function print_fg(bg, pre)
+ for fg = 30,37 do
+ fg = pre..fg
+ io.write(cl(bg), cl(fg), string.format(' %6s ', fg), cl(0))
+ end
+end
+
+for bg = 40,47 do
+ io.write(cl(0), ' ', bg, ' ')
+ print_fg(bg, ' ')
+ io.write('\n ')
+ print_fg(bg, '1;')
+ io.write('\n\n')
+end
+
+-- Andres P
diff --git a/cli/colortest.pl b/cli/colortest.pl
new file mode 100755
index 0000000..767789e
--- /dev/null
+++ b/cli/colortest.pl
@@ -0,0 +1,365 @@
+#!/usr/bin/env perl
+
+# by entheon, do whatever the hell you want with this file
+
+print "\n";
+print "*****************************\n";
+print "* XTERM 256Color Test Chart *\n";
+print "*****************************\n";
+print "* 16 = black\n";
+print "* 255 = white\n";
+print "*\n";
+print "* Usage:\n";
+print "* colortest.pl -w\n";
+print "* wide display\n";
+print "*\n";
+print "* colortest.pl -w -r\n";
+print "* wide display reversed\n";
+print "*\n";
+print "* colortest.pl -w -s\n";
+print "* extra spaces padding\n";
+print "*\n";
+print "* colortest.pl -w -r -s\n";
+print "* available combination\n";
+print "*\n";
+print "**************************\n";
+
+if( $ARGV[0] eq "-w" || $ARGV[1] eq "-w" || $ARGV[2] eq "-w" ) {
+ push(@arr, [( " 16: 00/00/00", " 17: 00/00/5f", " 18: 00/00/87", " 19: 00/00/af", " 20: 00/00/d7", " 21: 00/00/ff")] );
+ push(@arr, [( " 22: 00/5f/00", " 23: 00/5f/5f", " 24: 00/5f/87", " 25: 00/5f/af", " 26: 00/5f/d7", " 27: 00/5f/ff")] );
+ push(@arr, [( " 28: 00/87/00", " 29: 00/87/5f", " 30: 00/87/87", " 31: 00/87/af", " 32: 00/87/d7", " 33: 00/87/ff")] );
+ push(@arr, [( " 34: 00/af/00", " 35: 00/af/5f", " 36: 00/af/87", " 37: 00/af/af", " 38: 00/af/d7", " 39: 00/af/ff")] );
+ push(@arr, [( " 40: 00/d7/00", " 41: 00/d7/5f", " 42: 00/d7/87", " 43: 00/d7/af", " 44: 00/d7/d7", " 45: 00/d7/ff")] );
+ push(@arr, [( " 46: 00/ff/00", " 47: 00/ff/5f", " 48: 00/ff/87", " 49: 00/ff/af", " 50: 00/ff/d7", " 51: 00/ff/ff")] );
+ push(@arr, [( " 52: 5f/00/00", " 53: 5f/00/5f", " 54: 5f/00/87", " 55: 5f/00/af", " 56: 5f/00/d7", " 57: 5f/00/ff")] );
+ push(@arr, [( " 58: 5f/5f/00", " 59: 5f/5f/5f", " 60: 5f/5f/87", " 61: 5f/5f/af", " 62: 5f/5f/d7", " 63: 5f/5f/ff")] );
+ push(@arr, [( " 64: 5f/87/00", " 65: 5f/87/5f", " 66: 5f/87/87", " 67: 5f/87/af", " 68: 5f/87/d7", " 69: 5f/87/ff")] );
+ push(@arr, [( " 70: 5f/af/00", " 71: 5f/af/5f", " 72: 5f/af/87", " 73: 5f/af/af", " 74: 5f/af/d7", " 75: 5f/af/ff")] );
+ push(@arr, [( " 76: 5f/d7/00", " 77: 5f/d7/5f", " 78: 5f/d7/87", " 79: 5f/d7/af", " 80: 5f/d7/d7", " 81: 5f/d7/ff")] );
+ push(@arr, [( " 82: 5f/ff/00", " 83: 5f/ff/5f", " 84: 5f/ff/87", " 85: 5f/ff/af", " 86: 5f/ff/d7", " 87: 5f/ff/ff")] );
+ push(@arr, [( " 88: 87/00/00", " 89: 87/00/5f", " 90: 87/00/87", " 91: 87/00/af", " 92: 87/00/d7", " 93: 87/00/ff")] );
+ push(@arr, [( " 94: 87/5f/00", " 95: 87/5f/5f", " 96: 87/5f/87", " 97: 87/5f/af", " 98: 87/5f/d7", " 99: 87/5f/ff")] );
+ push(@arr, [( " 100: 87/87/00", " 101: 87/87/5f", " 102: 87/87/87", " 103: 87/87/af", " 104: 87/87/d7", " 105: 87/87/ff")] );
+ push(@arr, [( " 106: 87/af/00", " 107: 87/af/5f", " 108: 87/af/87", " 109: 87/af/af", " 110: 87/af/d7", " 111: 87/af/ff")] );
+ push(@arr, [( " 112: 87/d7/00", " 113: 87/d7/5f", " 114: 87/d7/87", " 115: 87/d7/af", " 116: 87/d7/d7", " 117: 87/d7/ff")] );
+ push(@arr, [( " 118: 87/ff/00", " 119: 87/ff/5f", " 120: 87/ff/87", " 121: 87/ff/af", " 122: 87/ff/d7", " 123: 87/ff/ff")] );
+ push(@arr, [( " 124: af/00/00", " 125: af/00/5f", " 126: af/00/87", " 127: af/00/af", " 128: af/00/d7", " 129: af/00/ff")] );
+ push(@arr, [( " 130: af/5f/00", " 131: af/5f/5f", " 132: af/5f/87", " 133: af/5f/af", " 134: af/5f/d7", " 135: af/5f/ff")] );
+ push(@arr, [( " 136: af/87/00", " 137: af/87/5f", " 138: af/87/87", " 139: af/87/af", " 140: af/87/d7", " 141: af/87/ff")] );
+ push(@arr, [( " 142: af/af/00", " 143: af/af/5f", " 144: af/af/87", " 145: af/af/af", " 146: af/af/d7", " 147: af/af/ff")] );
+ push(@arr, [( " 148: af/d7/00", " 149: af/d7/5f", " 150: af/d7/87", " 151: af/d7/af", " 152: af/d7/d7", " 153: af/d7/ff")] );
+ push(@arr, [( " 154: af/ff/00", " 155: af/ff/5f", " 156: af/ff/87", " 157: af/ff/af", " 158: af/ff/d7", " 159: af/ff/ff")] );
+ push(@arr, [( " 160: d7/00/00", " 161: d7/00/5f", " 162: d7/00/87", " 163: d7/00/af", " 164: d7/00/d7", " 165: d7/00/ff")] );
+ push(@arr, [( " 166: d7/5f/00", " 167: d7/5f/5f", " 168: d7/5f/87", " 169: d7/5f/af", " 170: d7/5f/d7", " 171: d7/5f/ff")] );
+ push(@arr, [( " 172: d7/87/00", " 173: d7/87/5f", " 174: d7/87/87", " 175: d7/87/af", " 176: d7/87/d7", " 177: d7/87/ff")] );
+ push(@arr, [( " 178: d7/af/00", " 179: d7/af/5f", " 180: d7/af/87", " 181: d7/af/af", " 182: d7/af/d7", " 183: d7/af/ff")] );
+ push(@arr, [( " 184: d7/d7/00", " 185: d7/d7/5f", " 186: d7/d7/87", " 187: d7/d7/af", " 188: d7/d7/d7", " 189: d7/d7/ff")] );
+ push(@arr, [( " 190: d7/ff/00", " 191: d7/ff/5f", " 192: d7/ff/87", " 193: d7/ff/af", " 194: d7/ff/d7", " 195: d7/ff/ff")] );
+ push(@arr, [( " 196: ff/00/00", " 197: ff/00/5f", " 198: ff/00/87", " 199: ff/00/af", " 200: ff/00/d7", " 201: ff/00/ff")] );
+ push(@arr, [( " 202: ff/5f/00", " 203: ff/5f/5f", " 204: ff/5f/87", " 205: ff/5f/af", " 206: ff/5f/d7", " 207: ff/5f/ff")] );
+ push(@arr, [( " 208: ff/87/00", " 209: ff/87/5f", " 210: ff/87/87", " 211: ff/87/af", " 212: ff/87/d7", " 213: ff/87/ff")] );
+ push(@arr, [( " 214: ff/af/00", " 215: ff/af/5f", " 216: ff/af/87", " 217: ff/af/af", " 218: ff/af/d7", " 219: ff/af/ff")] );
+ push(@arr, [( " 220: ff/d7/00", " 221: ff/d7/5f", " 222: ff/d7/87", " 223: ff/d7/af", " 224: ff/d7/d7", " 225: ff/d7/ff")] );
+ push(@arr, [( " 226: ff/ff/00", " 227: ff/ff/5f", " 228: ff/ff/87", " 229: ff/ff/af", " 230: ff/ff/d7", " 231: ff/ff/ff")] );
+ push(@arr, [( " 232: 08/08/08", " 233: 12/12/12", " 234: 1c/1c/1c", " 235: 26/26/26", " 236: 30/30/30", " 237: 3a/3a/3a")] );
+ push(@arr, [( " 238: 44/44/44", " 239: 4e/4e/4e", " 240: 58/58/58", " 241: 62/62/62", " 242: 6c/6c/6c", " 243: 76/76/76")] );
+ push(@arr, [( " 244: 80/80/80", " 245: 8a/8a/8a", " 246: 94/94/94", " 247: 9e/9e/9e", " 248: a8/a8/a8", " 249: b2/b2/b2")] );
+ push(@arr, [( " 250: bc/bc/bc", " 251: c6/c6/c6", " 252: d0/d0/d0", " 253: da/da/da", " 254: e4/e4/e4", " 255: ee/ee/ee")] );
+
+ if( $ARGV[0] eq "-s" || $ARGV[1] eq "-s" || $ARGV[2] eq "-s" ){
+ $padding = " ";
+ }
+ else {
+
+ }
+
+ # display in reverse order
+ if( $ARGV[0] eq "-r" || $ARGV[1] eq "-r" || $ARGV[2] eq "-r" ){
+ for( $dimone = 0; $dimone < scalar @arr; $dimone++ ) {
+
+ $seed = ($dimone % 6) * -1;
+ for( $dimtwo = 0; $dimtwo < 6; $dimtwo++ ) {
+
+ $movone = $seed;
+ $movtwo = $seed * -1;
+
+ print $arr[$dimone][$dimtwo] . $padding;
+
+ $seed = $seed+1;
+ }
+
+ print "\n";
+ }
+ }
+ else {
+ for( $dimone = 0; $dimone < scalar @arr; $dimone++ ) {
+
+ $seed = ($dimone % 6) * -1;
+ for( $dimtwo = 0; $dimtwo < 6; $dimtwo++ ) {
+
+ $movone = $seed;
+ $movtwo = $seed * -1;
+
+ $newone = $dimone+$movone;
+ $newtwo = $dimtwo+$movtwo;
+
+ if( $newone < scalar @arr ){
+ print $arr[$newone][$newtwo] . $padding;
+ }
+
+ $seed = $seed+1;
+ }
+
+ print "\n";
+ }
+ }
+ print "\n";
+ print "\n";
+
+}
+else {
+ print " 16: 00/00/00\n";
+ print " 17: 00/00/5f\n";
+ print " 18: 00/00/87\n";
+ print " 19: 00/00/af\n";
+ print " 20: 00/00/d7\n";
+ print " 21: 00/00/ff\n";
+ print " 22: 00/5f/00\n";
+ print " 23: 00/5f/5f\n";
+ print " 24: 00/5f/87\n";
+ print " 25: 00/5f/af\n";
+ print " 26: 00/5f/d7\n";
+ print " 27: 00/5f/ff\n";
+ print " 28: 00/87/00\n";
+ print " 29: 00/87/5f\n";
+ print " 30: 00/87/87\n";
+ print " 31: 00/87/af\n";
+ print " 32: 00/87/d7\n";
+ print " 33: 00/87/ff\n";
+ print " 34: 00/af/00\n";
+ print " 35: 00/af/5f\n";
+ print " 36: 00/af/87\n";
+ print " 37: 00/af/af\n";
+ print " 38: 00/af/d7\n";
+ print " 39: 00/af/ff\n";
+ print " 40: 00/d7/00\n";
+ print " 41: 00/d7/5f\n";
+ print " 42: 00/d7/87\n";
+ print " 43: 00/d7/af\n";
+ print " 44: 00/d7/d7\n";
+ print " 45: 00/d7/ff\n";
+ print " 46: 00/ff/00\n";
+ print " 47: 00/ff/5f\n";
+ print " 48: 00/ff/87\n";
+ print " 49: 00/ff/af\n";
+ print " 50: 00/ff/d7\n";
+ print " 51: 00/ff/ff\n";
+ print " 52: 5f/00/00\n";
+ print " 53: 5f/00/5f\n";
+ print " 54: 5f/00/87\n";
+ print " 55: 5f/00/af\n";
+ print " 56: 5f/00/d7\n";
+ print " 57: 5f/00/ff\n";
+ print " 58: 5f/5f/00\n";
+ print " 59: 5f/5f/5f\n";
+ print " 60: 5f/5f/87\n";
+ print " 61: 5f/5f/af\n";
+ print " 62: 5f/5f/d7\n";
+ print " 63: 5f/5f/ff\n";
+ print " 64: 5f/87/00\n";
+ print " 65: 5f/87/5f\n";
+ print " 66: 5f/87/87\n";
+ print " 67: 5f/87/af\n";
+ print " 68: 5f/87/d7\n";
+ print " 69: 5f/87/ff\n";
+ print " 70: 5f/af/00\n";
+ print " 71: 5f/af/5f\n";
+ print " 72: 5f/af/87\n";
+ print " 73: 5f/af/af\n";
+ print " 74: 5f/af/d7\n";
+ print " 75: 5f/af/ff\n";
+ print " 76: 5f/d7/00\n";
+ print " 77: 5f/d7/5f\n";
+ print " 78: 5f/d7/87\n";
+ print " 79: 5f/d7/af\n";
+ print " 80: 5f/d7/d7\n";
+ print " 81: 5f/d7/ff\n";
+ print " 82: 5f/ff/00\n";
+ print " 83: 5f/ff/5f\n";
+ print " 84: 5f/ff/87\n";
+ print " 85: 5f/ff/af\n";
+ print " 86: 5f/ff/d7\n";
+ print " 87: 5f/ff/ff\n";
+ print " 88: 87/00/00\n";
+ print " 89: 87/00/5f\n";
+ print " 90: 87/00/87\n";
+ print " 91: 87/00/af\n";
+ print " 92: 87/00/d7\n";
+ print " 93: 87/00/ff\n";
+ print " 94: 87/5f/00\n";
+ print " 95: 87/5f/5f\n";
+ print " 96: 87/5f/87\n";
+ print " 97: 87/5f/af\n";
+ print " 98: 87/5f/d7\n";
+ print " 99: 87/5f/ff\n";
+ print " 100 :87/87/00\n";
+ print " 101 :87/87/5f\n";
+ print " 102 :87/87/87\n";
+ print " 103 :87/87/af\n";
+ print " 104 :87/87/d7\n";
+ print " 105 :87/87/ff\n";
+ print " 106 :87/af/00\n";
+ print " 107 :87/af/5f\n";
+ print " 108 :87/af/87\n";
+ print " 109 :87/af/af\n";
+ print " 110 :87/af/d7\n";
+ print " 111 :87/af/ff\n";
+ print " 112 :87/d7/00\n";
+ print " 113 :87/d7/5f\n";
+ print " 114 :87/d7/87\n";
+ print " 115 :87/d7/af\n";
+ print " 116 :87/d7/d7\n";
+ print " 117 :87/d7/ff\n";
+ print " 118 :87/ff/00\n";
+ print " 119 :87/ff/5f\n";
+ print " 120 :87/ff/87\n";
+ print " 121 :87/ff/af\n";
+ print " 122 :87/ff/d7\n";
+ print " 123 :87/ff/ff\n";
+ print " 124 :af/00/00\n";
+ print " 125 :af/00/5f\n";
+ print " 126 :af/00/87\n";
+ print " 127 :af/00/af\n";
+ print " 128 :af/00/d7\n";
+ print " 129 :af/00/ff\n";
+ print " 130 :af/5f/00\n";
+ print " 131 :af/5f/5f\n";
+ print " 132 :af/5f/87\n";
+ print " 133 :af/5f/af\n";
+ print " 134 :af/5f/d7\n";
+ print " 135 :af/5f/ff\n";
+ print " 136 :af/87/00\n";
+ print " 137 :af/87/5f\n";
+ print " 138 :af/87/87\n";
+ print " 139 :af/87/af\n";
+ print " 140 :af/87/d7\n";
+ print " 141 :af/87/ff\n";
+ print " 142 :af/af/00\n";
+ print " 143 :af/af/5f\n";
+ print " 144 :af/af/87\n";
+ print " 145 :af/af/af\n";
+ print " 146 :af/af/d7\n";
+ print " 147 :af/af/ff\n";
+ print " 148 :af/d7/00\n";
+ print " 149 :af/d7/5f\n";
+ print " 150 :af/d7/87\n";
+ print " 151 :af/d7/af\n";
+ print " 152 :af/d7/d7\n";
+ print " 153 :af/d7/ff\n";
+ print " 154 :af/ff/00\n";
+ print " 155 :af/ff/5f\n";
+ print " 156 :af/ff/87\n";
+ print " 157 :af/ff/af\n";
+ print " 158 :af/ff/d7\n";
+ print " 159 :af/ff/ff\n";
+ print " 160 :d7/00/00\n";
+ print " 161 :d7/00/5f\n";
+ print " 162 :d7/00/87\n";
+ print " 163 :d7/00/af\n";
+ print " 164 :d7/00/d7\n";
+ print " 165 :d7/00/ff\n";
+ print " 166 :d7/5f/00\n";
+ print " 167 :d7/5f/5f\n";
+ print " 168 :d7/5f/87\n";
+ print " 169 :d7/5f/af\n";
+ print " 170 :d7/5f/d7\n";
+ print " 171 :d7/5f/ff\n";
+ print " 172 :d7/87/00\n";
+ print " 173 :d7/87/5f\n";
+ print " 174 :d7/87/87\n";
+ print " 175 :d7/87/af\n";
+ print " 176 :d7/87/d7\n";
+ print " 177 :d7/87/ff\n";
+ print " 178 :d7/af/00\n";
+ print " 179 :d7/af/5f\n";
+ print " 180 :d7/af/87\n";
+ print " 181 :d7/af/af\n";
+ print " 182 :d7/af/d7\n";
+ print " 183 :d7/af/ff\n";
+ print " 184 :d7/d7/00\n";
+ print " 185 :d7/d7/5f\n";
+ print " 186 :d7/d7/87\n";
+ print " 187 :d7/d7/af\n";
+ print " 188 :d7/d7/d7\n";
+ print " 189 :d7/d7/ff\n";
+ print " 190 :d7/ff/00\n";
+ print " 191 :d7/ff/5f\n";
+ print " 192 :d7/ff/87\n";
+ print " 193 :d7/ff/af\n";
+ print " 194 :d7/ff/d7\n";
+ print " 195 :d7/ff/ff\n";
+ print " 196 :ff/00/00\n";
+ print " 197 :ff/00/5f\n";
+ print " 198 :ff/00/87\n";
+ print " 199 :ff/00/af\n";
+ print " 200 :ff/00/d7\n";
+ print " 201 :ff/00/ff\n";
+ print " 202 :ff/5f/00\n";
+ print " 203 :ff/5f/5f\n";
+ print " 204 :ff/5f/87\n";
+ print " 205 :ff/5f/af\n";
+ print " 206 :ff/5f/d7\n";
+ print " 207 :ff/5f/ff\n";
+ print " 208 :ff/87/00\n";
+ print " 209 :ff/87/5f\n";
+ print " 210 :ff/87/87\n";
+ print " 211 :ff/87/af\n";
+ print " 212 :ff/87/d7\n";
+ print " 213 :ff/87/ff\n";
+ print " 214 :ff/af/00\n";
+ print " 215 :ff/af/5f\n";
+ print " 216 :ff/af/87\n";
+ print " 217 :ff/af/af\n";
+ print " 218 :ff/af/d7\n";
+ print " 219 :ff/af/ff\n";
+ print " 220 :ff/d7/00\n";
+ print " 221 :ff/d7/5f\n";
+ print " 222 :ff/d7/87\n";
+ print " 223 :ff/d7/af\n";
+ print " 224 :ff/d7/d7\n";
+ print " 225 :ff/d7/ff\n";
+ print " 226 :ff/ff/00\n";
+ print " 227 :ff/ff/5f\n";
+ print " 228 :ff/ff/87\n";
+ print " 229 :ff/ff/af\n";
+ print " 230 :ff/ff/d7\n";
+ print " 231 :ff/ff/ff\n";
+ print " 232 :08/08/08\n";
+ print " 233 :12/12/12\n";
+ print " 234 :1c/1c/1c\n";
+ print " 235 :26/26/26\n";
+ print " 236 :30/30/30\n";
+ print " 237 :3a/3a/3a\n";
+ print " 238 :44/44/44\n";
+ print " 239 :4e/4e/4e\n";
+ print " 240 :58/58/58\n";
+ print " 241 :62/62/62\n";
+ print " 242 :6c/6c/6c\n";
+ print " 243 :76/76/76\n";
+ print " 244 :80/80/80\n";
+ print " 245 :8a/8a/8a\n";
+ print " 246 :94/94/94\n";
+ print " 247 :9e/9e/9e\n";
+ print " 248 :a8/a8/a8\n";
+ print " 249 :b2/b2/b2\n";
+ print " 250 :bc/bc/bc\n";
+ print " 251 :c6/c6/c6\n";
+ print " 252 :d0/d0/d0\n";
+ print " 253 :da/da/da\n";
+ print " 254 :e4/e4/e4\n";
+ print " 255 :ee/ee/ee\n";
+ print "\n";
+ print "\n";
+}
+print "0m";
+exit;
diff --git a/cli/colortest.py b/cli/colortest.py
new file mode 100755
index 0000000..2d29590
--- /dev/null
+++ b/cli/colortest.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+#
+# http://askubuntu.com/questions/27314/script-to-display-all-terminal-colors
+
+import sys
+
+terse = "-t" in sys.argv[1:] or "--terse" in sys.argv[1:]
+
+for i in range(2 if terse else 10):
+ for j in range(30, 38):
+ for k in range(40, 48):
+ if terse:
+ print "\33[%d;%d;%dm%d;%d;%d\33[m " % (i, j, k, i, j, k),
+ else:
+ print ("%d;%d;%d: \33[%d;%d;%dm Hello, World! \33[m " %
+ (i, j, k, i, j, k, ))
+ print
+
diff --git a/cli/colortest.rb b/cli/colortest.rb
new file mode 100755
index 0000000..cc5d6d6
--- /dev/null
+++ b/cli/colortest.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+# coding: utf-8
+
+# ANSI color scheme script
+# Author: Ivaylo Kuzev < Ivo >
+# Original: http://crunchbang.org/forums/viewtopic.php?pid=134749%23p134749#p134749
+# Modified using Ruby.
+
+CL = "\e[0m"
+BO = "\e[1m"
+
+R = "\e[31m"
+G = "\e[32m"
+Y = "\e[33m"
+B = "\e[34m"
+P = "\e[35m"
+C = "\e[36m"
+
+print <<EOF
+
+#{BO}#{R} ██████ #{CL} #{BO}#{G}██████ #{CL}#{BO}#{Y} ██████#{CL} #{BO}#{B}██████ #{CL} #{BO}#{P} ██████#{CL} #{BO}#{C} ███████#{CL}
+#{BO}#{R} ████████#{CL} #{BO}#{G}██ ██ #{CL}#{BO}#{Y}██ #{CL} #{BO}#{B}██ ██#{CL} #{BO}#{P}██████ #{CL} #{BO}#{C} █████████#{CL}
+#{R} ██ ████#{CL} #{G}██ ████#{CL}#{Y} ████ #{CL} #{B}████ ██#{CL} #{P}████ #{CL} #{C}█████ #{CL}
+#{R} ██ ██#{CL} #{G}██████ #{CL}#{Y} ████████#{CL} #{B}██████ #{CL} #{P}████████#{CL} #{C}██ #{CL}
+
+EOF
diff --git a/cli/colortest.sh b/cli/colortest.sh
new file mode 100755
index 0000000..3974d69
--- /dev/null
+++ b/cli/colortest.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Original Posted at http://crunchbang.org/forums/viewtopic.php?pid=126921%23p126921#p126921
+# [ESC] character in original post removed here.
+
+# ANSI Color -- use these variables to easily have different color
+# and format output. Make sure to output the reset sequence after
+# colors (f = foreground, b = background), and use the 'off'
+# feature for anything you turn on.
+
+initializeANSI()
+{
+ esc="$(echo -en '\e')"
+
+ blackf="${esc}[30m"; redf="${esc}[31m"; greenf="${esc}[32m"
+ yellowf="${esc}[33m" bluef="${esc}[34m"; purplef="${esc}[35m"
+ cyanf="${esc}[36m"; whitef="${esc}[37m"
+
+ blackb="${esc}[40m"; redb="${esc}[41m"; greenb="${esc}[42m"
+ yellowb="${esc}[43m" blueb="${esc}[44m"; purpleb="${esc}[45m"
+ cyanb="${esc}[46m"; whiteb="${esc}[47m"
+
+ boldon="${esc}[1m"; boldoff="${esc}[22m"
+ italicson="${esc}[3m"; italicsoff="${esc}[23m"
+ ulon="${esc}[4m"; uloff="${esc}[24m"
+ invon="${esc}[7m"; invoff="${esc}[27m"
+
+ reset="${esc}[0m"
+}
+
+# note in this first use that switching colors doesn't require a reset
+# first - the new color overrides the old one.
+
+#clear
+
+initializeANSI
+
+cat << EOF
+
+ ${yellowf} ▄███████▄${reset} ${redf} ▄██████▄${reset} ${greenf} ▄██████▄${reset} ${bluef} ▄██████▄${reset} ${purplef} ▄██████▄${reset} ${cyanf} ▄██████▄${reset}
+ ${yellowf}▄█████████▀▀${reset} ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄${reset} ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄${reset} ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄${reset} ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄${reset} ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset}
+ ${yellowf}███████▀${reset} ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███${reset} ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███${reset} ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███${reset} ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███${reset} ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset}
+ ${yellowf}███████▄${reset} ${redf}████████████${reset} ${greenf}████████████${reset} ${bluef}████████████${reset} ${purplef}████████████${reset} ${cyanf}████████████${reset}
+ ${yellowf}▀█████████▄▄${reset} ${redf}██▀██▀▀██▀██${reset} ${greenf}██▀██▀▀██▀██${reset} ${bluef}██▀██▀▀██▀██${reset} ${purplef}██▀██▀▀██▀██${reset} ${cyanf}██▀██▀▀██▀██${reset}
+ ${yellowf} ▀███████▀${reset} ${redf}▀ ▀ ▀ ▀${reset} ${greenf}▀ ▀ ▀ ▀${reset} ${bluef}▀ ▀ ▀ ▀${reset} ${purplef}▀ ▀ ▀ ▀${reset} ${cyanf}▀ ▀ ▀ ▀${reset}
+
+ ${boldon}${yellowf} ▄███████▄ ${redf} ▄██████▄ ${greenf} ▄██████▄ ${bluef} ▄██████▄ ${purplef} ▄██████▄ ${cyanf} ▄██████▄${reset}
+ ${boldon}${yellowf}▄█████████▀▀ ${redf}▄${whitef}█▀█${redf}██${whitef}█▀█${redf}██▄ ${greenf}▄${whitef}█▀█${greenf}██${whitef}█▀█${greenf}██▄ ${bluef}▄${whitef}█▀█${bluef}██${whitef}█▀█${bluef}██▄ ${purplef}▄${whitef}█▀█${purplef}██${whitef}█▀█${purplef}██▄ ${cyanf}▄${whitef}█▀█${cyanf}██${whitef}█▀█${cyanf}██▄${reset}
+ ${boldon}${yellowf}███████▀ ${redf}█${whitef}▄▄█${redf}██${whitef}▄▄█${redf}███ ${greenf}█${whitef}▄▄█${greenf}██${whitef}▄▄█${greenf}███ ${bluef}█${whitef}▄▄█${bluef}██${whitef}▄▄█${bluef}███ ${purplef}█${whitef}▄▄█${purplef}██${whitef}▄▄█${purplef}███ ${cyanf}█${whitef}▄▄█${cyanf}██${whitef}▄▄█${cyanf}███${reset}
+ ${boldon}${yellowf}███████▄ ${redf}████████████ ${greenf}████████████ ${bluef}████████████ ${purplef}████████████ ${cyanf}████████████${reset}
+ ${boldon}${yellowf}▀█████████▄▄ ${redf}██▀██▀▀██▀██ ${greenf}██▀██▀▀██▀██ ${bluef}██▀██▀▀██▀██ ${purplef}██▀██▀▀██▀██ ${cyanf}██▀██▀▀██▀██${reset}
+ ${boldon}${yellowf} ▀███████▀ ${redf}▀ ▀ ▀ ▀ ${greenf}▀ ▀ ▀ ▀ ${bluef}▀ ▀ ▀ ▀ ${purplef}▀ ▀ ▀ ▀ ${cyanf}▀ ▀ ▀ ▀${reset}
+
+EOF
diff --git a/cli/csv2json.py b/cli/csv2json.py
new file mode 100755
index 0000000..54f6be2
--- /dev/null
+++ b/cli/csv2json.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# This is a simple tool that converts CSV file into a JSON file.
+# The first line of the input CSV file is used as the field names.
+#
+# Use 'OrderedDict' to keep the input fields order.
+#
+# Aaron LI
+# 2015/06/11
+#
+
+from __future__ import print_function, division
+
+__version__ = "0.1.0"
+__date__ = "2015/06/11"
+
+import sys
+import argparse
+import csv
+import json
+
+from collections import OrderedDict
+
+
+def csv2json(csvfile, jsonfile=None):
+ """
+ Convert CSV data to JSON data.
+ The first line of CSV data is used as the field names.
+
+ Return:
+ If jsonfile is None, then return a list of JSON dict.
+ """
+ if not hasattr(csvfile, "read"):
+ csvfile = open(csvfile, "r")
+ if (jsonfile is not None) and (not hasattr(jsonfile, "write")):
+ jsonfile = open(jsonfile, "w")
+ csvdata = list(csv.reader(csvfile))
+ fieldnames = csvdata[0]
+ # use 'OrderedDict' to keep fields order
+ jsondata = [ OrderedDict(zip(fieldnames, row)) for row in csvdata[1:] ]
+ csvfile.close()
+ if jsonfile is None:
+ return jsondata
+ else:
+ # 'ensure_ascii=False' to support UTF-8
+ json.dump(jsondata, jsonfile, ensure_ascii=False, indent=4)
+ jsonfile.close()
+
+
+def main():
+ # command line options & arguments
+ parser = argparse.ArgumentParser(
+ description="Simple CSV to JSON convertor")
+ parser.add_argument("-V", "--version", action="version",
+ version="%(prog)s " + "%s (%s)" % (__version__, __date__))
+ parser.add_argument("csvfile", help="Input CSV file")
+ parser.add_argument("jsonfile", nargs="?", default=sys.stdout,
+ help="Output JSON file (default stdout)")
+ args = parser.parse_args()
+
+ csv2json(args.csvfile, args.jsonfile)
+
+
+if __name__ == "__main__":
+ main()
+
diff --git a/cli/jpegs2pdf.sh b/cli/jpegs2pdf.sh
new file mode 100755
index 0000000..6d42bab
--- /dev/null
+++ b/cli/jpegs2pdf.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+#############################################################################
+#
+# Shellscript to convert a set of JPEG files to a multipage PDF.
+#
+# Requirements: (1) Ghostscript needs to be installed on the local system.
+# (2) ImageMagick needs to be installed on the local system.
+#
+# Usage: jpegs2pdf.sh output.pdf file1.jpeg [file2.jpeg [file2.jpeg [...]]]
+#
+# Copyright (c) 2007, <pipitas@gmail.com>
+# Use, distribute and modify without any restrictions.
+#
+# Versions:
+# v1.0.0, Jul 12 2007: initial version
+# v1.0.1, Jan 07 2011: set viewJPEG.ps path (self-compiled GS 9.02)
+#
+#############################################################################
+
+if [ $# -eq 0 ]; then
+ echo "Usage:"
+ echo " `basename $0` output.pdf 1.jpg ..."
+ exit 1
+fi
+
+outfile=$1
+shift
+
+param=""
+for i in "$@" ; do
+ dimension=$(identify -format "%[fx:(w)] %[fx:(h)]" "${i}")
+ param="${param} <</PageSize [${dimension}]>> setpagedevice (${i}) viewJPEG showpage"
+done
+
+gs \
+ -sDEVICE=pdfwrite \
+ -dPDFSETTINGS=/prepress \
+ -o "$outfile" \
+ viewjpeg.ps \
+ -c "${param}"
+
diff --git a/cli/pdfmerge.sh b/cli/pdfmerge.sh
new file mode 100755
index 0000000..aef72db
--- /dev/null
+++ b/cli/pdfmerge.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Merge multiple PDFs with pdftk.
+#
+# Ref:
+# Merging Multiple PDFs under GNU/Linux
+# https://blog.dbrgn.ch/2013/8/14/merge-multiple-pdfs/
+#
+# Weitian LI
+# 2015/01/23
+#
+
+if [ $# -lt 2 ]; then
+ printf "Usage: `basename $0` out.pdf in1.pdf ...\n"
+ exit 1
+fi
+
+outpdf="$1"
+shift
+
+echo "Input files: $@"
+pdftk "$@" cat output "${outpdf}"
+
diff --git a/cli/shrinkpdf.sh b/cli/shrinkpdf.sh
new file mode 100755
index 0000000..1190fce
--- /dev/null
+++ b/cli/shrinkpdf.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Shrink the size of PDF files by adjust its quality using gs.
+#
+# Aaron LI
+# 2013/09/18
+#
+
+case "$1" in
+ -[hH]*|--[hH]*)
+ printf "usage:\n"
+ printf " `basename $0` in=<input.pdf> out=<output.pdf> quality=<screen|ebook|printer|prepress> imgdpi=<img_dpi>\n"
+ exit 1
+ ;;
+esac
+
+getopt_keyval() {
+ until [ -z "$1" ]
+ do
+ key=${1%%=*} # extract key
+ val=${1#*=} # extract value
+ keyval="${key}=\"${val}\""
+ echo "## getopt: eval '${keyval}'"
+ eval ${keyval}
+ shift # shift, process next one
+ done
+}
+getopt_keyval "$@"
+
+if [ -z "${in}" ] || [ -z "${out}" ]; then
+ printf "Error: 'in' or 'out' not specified\n"
+ exit 2
+fi
+quality=${quality:-ebook}
+imgdpi=${imgdpi:-120}
+
+printf "# in: ${in}
+# out: ${out}
+# quality: ${quality}
+# imgdpi: ${imgdpi}\n"
+
+gs -dNOPAUSE -dBATCH -dSAFER \
+ -sDEVICE=pdfwrite \
+ -dCompatibilityLevel=1.4 \
+ -dPDFSETTINGS="/${quality}" \
+ -dEmbedAllFonts=true \
+ -dSubsetFonts=true \
+ -dColorImageDownsampleType=/Bicubic \
+ -dColorImageResolution=${imgdpi} \
+ -dGrayImageDownsampleType=/Bicubic \
+ -dGrayImageResolution=${imgdpi} \
+ -dMonoImageDownsampleType=/Bicubic \
+ -dMonoImageResolution=${imgdpi} \
+ -sOutputFile=${out} \
+ ${in}
+
diff --git a/cli/term_color.sh b/cli/term_color.sh
new file mode 100755
index 0000000..f10f916
--- /dev/null
+++ b/cli/term_color.sh
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#
+# This file echoes a bunch of color codes to the
+# terminal to demonstrate what's available. Each
+# line is the color code of one forground color,
+# out of 17 (default + 16 escapes), followed by a
+# test use of that color on all nine background
+# colors (default + 8 escapes).
+#
+# Ref: https://wiki.archlinux.org/index.php/X_resources
+#
+
+T='gYw' # The test text
+
+echo -e "\n 40m 41m 42m 43m\
+ 44m 45m 46m 47m";
+
+for FGs in ' m' ' 1m' ' 30m' '1;30m' ' 31m' '1;31m' ' 32m' \
+ '1;32m' ' 33m' '1;33m' ' 34m' '1;34m' ' 35m' '1;35m' \
+ ' 36m' '1;36m' ' 37m' '1;37m';
+ do FG=${FGs// /}
+ echo -en " $FGs \033[$FG $T "
+ for BG in 40m 41m 42m 43m 44m 45m 46m 47m;
+ do echo -en "$EINS \033[$FG\033[$BG $T \033[0m";
+ done
+ echo;
+done
+echo
diff --git a/cli/term_color_2.sh b/cli/term_color_2.sh
new file mode 100755
index 0000000..4dc2ef2
--- /dev/null
+++ b/cli/term_color_2.sh
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+# Original: http://frexx.de/xterm-256-notes/
+# http://frexx.de/xterm-256-notes/data/colortable16.sh
+# Modified by Aaron Griffin
+# and further by Kazuo Teramoto
+FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
+BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
+
+echo " ┌──────────────────────────────────────────────────────────────────────────┐"
+for b in {0..8}; do
+ ((b>0)) && bg=$((b+39))
+
+ echo -en "\033[0m ${BGNAMES[b]} │ "
+
+ for f in {0..7}; do
+ echo -en "\033[${bg}m\033[$((f+30))m ${FGNAMES[f]} "
+ done
+
+ echo -en "\033[0m │"
+ echo -en "\033[0m\n\033[0m │ "
+
+ for f in {0..7}; do
+ echo -en "\033[${bg}m\033[1;$((f+30))m ${FGNAMES[f]} "
+ done
+
+ echo -en "\033[0m │"
+ echo -e "\033[0m"
+
+ ((b<8)) &&
+ echo " ├──────────────────────────────────────────────────────────────────────────┤"
+done
+echo " └──────────────────────────────────────────────────────────────────────────┘"
diff --git a/cli/term_color_3.sh b/cli/term_color_3.sh
new file mode 100755
index 0000000..85b499a
--- /dev/null
+++ b/cli/term_color_3.sh
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+# Original: http://frexx.de/xterm-256-notes/
+# http://frexx.de/xterm-256-notes/data/colortable16.sh
+# Modified by Aaron Griffin
+# and further by Kazuo Teramoto
+
+
+FGNAMES=(' black ' ' red ' ' green ' ' yellow' ' blue ' 'magenta' ' cyan ' ' white ')
+BGNAMES=('DFT' 'BLK' 'RED' 'GRN' 'YEL' 'BLU' 'MAG' 'CYN' 'WHT')
+echo " ----------------------------------------------------------------------------"
+for b in $(seq 0 8); do
+ if [ "$b" -gt 0 ]; then
+ bg=$(($b+39))
+ fi
+
+ echo -en "\033[0m ${BGNAMES[$b]} : "
+ for f in $(seq 0 7); do
+ echo -en "\033[${bg}m\033[$(($f+30))m ${FGNAMES[$f]} "
+ done
+ echo -en "\033[0m :"
+
+ echo -en "\033[0m\n\033[0m : "
+ for f in $(seq 0 7); do
+ echo -en "\033[${bg}m\033[1;$(($f+30))m ${FGNAMES[$f]} "
+ done
+ echo -en "\033[0m :"
+ echo -e "\033[0m"
+
+ if [ "$b" -lt 8 ]; then
+ echo " ----------------------------------------------------------------------------"
+ fi
+done
+echo " ----------------------------------------------------------------------------"
diff --git a/cli/unzip-gbk.py b/cli/unzip-gbk.py
new file mode 100755
index 0000000..423e10f
--- /dev/null
+++ b/cli/unzip-gbk.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# unzip-gbk.py
+#
+# http://note.ninehills.info/linux-gbk.html
+#
+
+import os
+import sys
+import zipfile
+
+print "Processing File " + sys.argv[1]
+
+file=zipfile.ZipFile(sys.argv[1],"r");
+for name in file.namelist():
+ utf8name=name.decode('gbk')
+ print "Extracting " + utf8name
+ pathname = os.path.dirname(utf8name)
+ if not os.path.exists(pathname) and pathname!= "":
+ os.makedirs(pathname)
+ data = file.read(name)
+ if not os.path.exists(utf8name):
+ fo = open(utf8name, "w")
+ fo.write(data)
+ fo.close
+file.close()
diff --git a/cli/vimpager b/cli/vimpager
new file mode 100755
index 0000000..447fd9a
--- /dev/null
+++ b/cli/vimpager
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# Script for using ViM as a PAGER.
+# Based on Bram's less.sh.
+# Version 1.3
+
+file="$@"
+if [ -z "$file" ]; then file="-"; fi
+
+if uname -s | grep -iq cygwin; then
+ cygwin=1
+elif uname -s | grep -iq linux; then
+ linux=1
+elif uname -s | grep -iq sunos; then
+ solaris=1
+else
+ bsd=1
+fi
+
+less_vim() {
+ vim -R \
+ -c 'let no_plugin_maps = 1' \
+ -c 'set scrolloff=999' \
+ -c 'runtime! macros/less.vim' \
+ -c 'set foldlevel=999' \
+ -c 'set mouse=h' \
+ -c 'set nonu' \
+ -c 'nmap <ESC>u :nohlsearch<cr>' \
+ "$@"
+}
+
+do_ps() {
+ if [ $solaris ]; then
+ ps -u `id -u` -o pid,comm=
+ elif [ $bsd ]; then
+ ps -U `id -u` -o pid,comm=
+ else
+ ps fuxw
+ fi
+}
+
+pproc() {
+ if [ $linux ]; then
+ ps -p $1 -o comm=
+ elif [ $cygwin ]; then
+ ps -p $1 | sed -e 's/^I/ /' | grep -v PID
+ else
+ ps -p $1 -o comm= | grep -v PID
+ fi
+}
+
+ppid() {
+ if [ $linux ]; then
+ ps -p $1 -o ppid=
+ elif [ $cygwin ]; then
+ ps -p $1 | sed -e 's/^I/ /' | grep -v PID | awk '{print $2}'
+ else
+ ps -p $1 -o ppid= | grep -v PID
+ fi
+}
+
+# Check if called from man, perldoc or pydoc
+if do_ps | grep -q '\(py\(thon\|doc\)\|man\|perl\(doc\)\?\([0-9.]*\)\?\)\>'; then
+ proc=$$
+ while next_parent=`ppid $proc` && [ $next_parent != 1 ]; do
+ if pproc $next_parent | grep -q 'man\>'; then
+ cat $file | sed -e 's/\[[^m]*m//g' | sed -e 's/.//g' | less_vim -c 'set ft=man' -; exit
+ elif pproc $next_parent | grep -q 'py\(thon\|doc\)\>'; then
+ cat $file | sed -e 's/\[[^m]*m//g' | sed -e 's/.//g' | less_vim -c 'set ft=man' -; exit
+ elif pproc $next_parent | grep -q 'perl\(doc\)\?\([0-9.]*\)\?\>'; then
+ cat $file | sed -e 's/.//g' | less_vim -c 'set ft=man' -; exit
+ fi
+ proc=$next_parent
+ done
+fi
+
+less_vim "$file"
+
+# CONTRIBUTORS:
+#
+# Rafael Kitover
+# Antonio Ospite
+# Jean-Marie Gaillourdet
+# Perry Hargrave
+# Koen Smits