<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AskApache &#187; Search Results  &#187;  putty</title>
	<atom:link href="http://www.askapache.com/search/putty/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.askapache.com</link>
	<description>Advanced Web Development</description>
	<lastBuildDate>Thu, 26 Apr 2012 11:29:28 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Optimized Vimrc with 256 Colorscheme</title>
		<link>http://www.askapache.com/linux/fast-vimrc.html</link>
		<comments>http://www.askapache.com/linux/fast-vimrc.html#comments</comments>
		<pubDate>Sun, 26 Feb 2012 18:15:32 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=7062</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/linux/fast-vimrc.html"><img src="http://uploads.askapache.com/2012/02/vimrc-colorscheme.png" alt="askapachecode 256color colorscheme and vimrc screenshot" title="askapachecode 256color colorscheme and vimrc screenshot" width="525" height="277" class="size-full wp-image-7074" /></a><strong>This is not your everyday vimrc</strong>.  This is <em>my</em> personalized vimrc.. works especially great on remote servers, in tmux, screen, etc. <br /><br />This doesn't require a git checkout, a vim update, a bash update, an OS update, a plugin.  No.  1 vimrc, 1 colorscheme, just use curl to download and it's on.  I use this on <a href="http://archlinux.org/">Arch Linux</a>, NetBSD, FreeBSD, OpenBSD, Debian, Ubuntu, Cent OS, Red Hat, and that's mostly it so far. <br />If you aren't already using vim as your primary editor in a powerful way, you are gonna owe me for this.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/fast-vimrc.html"></a><a href="http://www.askapache.com/linux/fast-vimrc.html"><cite>AskApache.com</cite></a></p><p>This is 90% geared for purely console/terminal/pty/tty/ssh/putty/telnet/tmux/screen users.  I've only just the past couple years started understanding why it was key to learn vim, in the past I never had the patience for it and preferred nano-like editors.  Now vim is all I use when on linux, it's so much more productive.. especially with a customized vimrc file.  This doesn't require a git checkout, a vim update, a bash update, an OS update, a plugin.  No.  This is a single file that I use on <a href="http://archlinux.org/">Arch Linux</a>, NetBSD, FreeBSD, OpenBSD, Debian, Ubuntu, Cent OS, Red Hat, and that's it so far.  This is geared for users who use SSH more than anything else.  Of course, it works perfect on an X enabled box locally as well.</p>

<h2>ScreenShot</h2>
<p><a href="http://uploads.askapache.com/2012/02/vimrc-screenshot.png"><img src="http://uploads.askapache.com/2012/02/vimrc-screenshot.png" alt="Screenshot of this vimrc in action" title="Screenshot of this vimrc in action" width="911" height="987" class="size-full wp-image-7073" /></a></p>

<h2>Setup</h2>
<p>I install this as <code>/etc/vimrc</code> if possible.  Individual users can use a vim config file in their home directories.</p>
<pre>source /etc/vimrc</pre>
<p>To install for a single user just save it in their home dir at <code>/home/username/.vimrc</code></p>

<h2>Portability</h2>
<p>For the portability needed to work on many different systems, this doesn't rely on any plugins other than those built into the default installation of vim 7.0.
It works well on all types of consoles, and depending on the TERM environment variable (and whether it has the right term capabilities) it will load 256 color support or not.  Usually on a new system I just scp this right over and it works without any modifications.  But an ongoing Work in progress.</p>



<h2>Optimized Vimrc</h2>
<p>Download - <a href='http://uploads.askapache.com/2012/02/vimrc.txt'>Optimized vimrc</a></p>
<pre>" Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
&nbsp;
" For all key mappings like &#039;, .&#039; to reload vimrc
let maplocalleader=&#039;,&#039;
&nbsp;
" BACKUPS, SWAPFILES, VIEWDIR, TMPDIR  "{{{1
" ================================================================================================================================================================
&nbsp;
" SET RUNTIMEPATH {{{3
if isdirectory(expand("$HOME/.vim"))
  let $VIMRUNTIME=expand("$HOME/.vim")
  set runtimepath=$VIMRUNTIME
endif
&nbsp;
" IF BKDIR IS NOT SET OR EMPTY, SET {{{3
if $BKDIR == ""
  let $BKDIR=expand("$HOME/.bk")
  if !isdirectory(expand("$BKDIR"))
    call mkdir(expand("$BKDIR"), "p", 0700)
  endif
endif
&nbsp;
" MAKE DIRS IF mkdir exists {{{3
if exists("*mkdir")
  if !isdirectory(expand("$BKDIR/.vim/viewdir"))|call mkdir(expand("$BKDIR/.vim/viewdir"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/tmp"))|call mkdir(expand("$BKDIR/.vim/tmp"), "p", 0700)|endif
  if !isdirectory(expand("$BKDIR/.vim/backups"))|call mkdir(expand("$BKDIR/.vim/backups"), "p", 0700)|endif
endif
&nbsp;
" SETTINGS USING NEW DIRS {{{3
let &amp;dir=expand("$BKDIR") . "/.vim"
let &amp;viewdir=expand("$BKDIR") . "/.vim/viewdir"
let &amp;backupdir=expand("$BKDIR") . "/.vim/backups"
"let &amp;verbosefile=expand("$BKDIR") . "/.vim/vim-messages.
&nbsp;
" VIMINFO {{{3
" COMMENTED OUT {{{4
"  "       Maximum number of lines saved for each register
"  %       When included, save and restore the buffer lis
"  &#039;       Maximum number of previously edited files for which the marks are remembere
"  /       Maximum number of items in the search pattern history to be saved
"  :        Maximum number of items in the command-line history
"  &lt;       Maximum number of lines saved for each register.
"   @       Maximum number of items in the input-line history
"  h       Disable the effect of &#039;hlsearch&#039; when loading the viminfo
"  n       Name of the viminfo file.  The name must immediately follow the &#039;n&#039;.  Must be the last oneEnvironment variables are expanded when opening the file, not when setting the option
"  r       Removable media.  The argument is a string
"  s       Maximum size of an item in Kbyte
"   }}}4 COMMENTED OUT
let &amp;viminfo="%200,&#039;200,/800,h,&lt;500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/.vim/tmp,n" . expand("$BKDIR") ."/.vim/.vinfo"
&nbsp;
" CUSTOM FUNCTIONS "{{{1
" ================================================================================================================================================================
if !exists("AskApacheLoaded")
  let AskApacheLoaded=1
&nbsp;
  " FUNCTION - LastMod {{{3
  " Warning, this is controlled by an autocmd triggered when closing the file that updates the file (in a great way)
  " Updated: Wed Feb 22 13:25:23 2012 by galileo@galileo
  function! LastMod()
    exe "silent! 1,20s/Updated: .*/" . printf(&#039;Updated: %s by %s@%s&#039;, strftime("%c"), expand("$LOGNAME"), hostname()) . "/e"
  endfunction
&nbsp;
  " FUNCTION - LastModNow {{{3
  " An even better version than LastMod()
  function! LastModNow()
    call setline(line(&#039;.&#039;), printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname()))
    "printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname())\|dd\|j\|dd&lt;CR&gt;&lt;ESC&gt;
    "printf(&#039;Updated: %s by %s %s&#039;, strftime("%c"), expand("$LOGNAME@$HOSTNAME")) ."/e"
  endfunction
&nbsp;
  " FUNCTION - AppendModeline {{{3
  " Append modeline after last line in buffer.  Use substitute() instead of printf() to handle &#039;%%s&#039; modeline
  function! AppendModeline()
    let l:modeline = printf(" vim: set ft=%s ts=%d sw=%d tw=%d foldmethod=%s :", &amp;filetype, &amp;tabstop, &amp;shiftwidth, &amp;textwidth, &amp;foldmethod)
    let l:modeline = substitute(&amp;commentstring, "%s", l:modeline, "")
    call append(line("$"), l:modeline)
  endfunction
&nbsp;
  " FUNCTION - LastModAAZZZ {{{3
  " AA_UPDATED=&#039;01/24/12-00:56:00&#039;
  function! LastModAAZZZ()
    exe "1,50s/AA_UPDATED=.*/AA_UPDATED=&#039;" . strftime("%c") . "&#039;"
  endfunction
&nbsp;
  " FUNCTION - StripTrailingWhitespace {{{3
  " automatically remove trailing whitespace before write
  function! StripTrailingWhitespace()
    normal mZ
    %s/\s\+$//e
    if line("&#039;Z") != line(".")|echo "Stripped whitespace\n"|endif
    normal `Z
  endfunction
&nbsp;
  " FUNCTION - MyTabL {{{3
  function! MyTabL()
    let s = &#039;&#039;|let t = tabpagenr()|let i = 1
    while i &lt;= tabpagenr(&#039;$&#039;)
      let bl = tabpagebuflist(i)|let wn = tabpagewinnr(i)
      let s .= &#039;%&#039; . i . &#039;T&#039;. (i == t ? &#039;%1*&#039; : &#039;%2*&#039;) . &#039;%*&#039; . (i == t ? &#039; %#TabLineSel# &#039; : &#039;%#TabLine#&#039;)
      let file = (i == t ? fnamemodify(bufname(bl[wn - 1]), &#039;:p&#039;) : fnamemodify(bufname(bl[wn - 1]), &#039;:t&#039;) )|if file == &#039;&#039;|let file = &#039;[No Name]&#039;|endif
      let s .= i.&#039; &#039;. file .(i == t ? &#039; &#039; : &#039;&#039;)|let i += 1
    endwhile
    let s .= &#039;%T%#TabLineFill#%=&#039; . (tabpagenr(&#039;$&#039;) &gt; 1 ? &#039;%999XX&#039; : &#039;X&#039;)
    return s
  endfunction
&nbsp;
  " FUNCTION - DiffWithSaved {{{3
  " Diff with saved version of the file
  function! s:DiffWithSaved()
    let filetype=&amp;ft
    diffthis
    vnew | r # | normal! 1Gdd
    diffthis
    exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
  endfunction
  com! DiffSaved call s:DiffWithSaved()
&nbsp;
  " FUNCTION - ShowWhitespace() {{{3
  function! ShowWhitespace(flags)
    let bad = &#039;&#039;
    let pat = []
    for c in split(a:flags, &#039;\zs&#039;)
      if c == &#039;e&#039;
        call add(pat, &#039;\s\+$&#039;)
      elseif c == &#039;i&#039;
        call add(pat, &#039;^\t*\zs \+&#039;)
      elseif c == &#039;s&#039;
        call add(pat, &#039; \+\ze\t&#039;)
      elseif c == &#039;t&#039;
        call add(pat, &#039;[^\t]\zs\t\+&#039;)
      else
        let bad .= c
      endif
    endfor
&nbsp;
    if len(pat) &gt; 0
      let s = join(pat, &#039;\|&#039;)
      exec &#039;syntax match ExtraWhitespace "&#039;.s.&#039;" containedin=ALL&#039;
    else
      syntax clear ExtraWhitespace
    endif
&nbsp;
    if len(bad) &gt; 0|echo &#039;ShowWhitespace ignored: &#039;.bad|endif
  endfunction
&nbsp;
  " FUNCTION - ToggleShowWhitespace {{{3
  " I use this all the time, it&#039;s mapped to , ts
  function! ToggleShowWhitespace()
    if !exists(&#039;b:ws_show&#039;)|let b:ws_show = 0|endif
    if !exists(&#039;b:ws_flags&#039;)|let b:ws_flags = &#039;est&#039;|endif
    let b:ws_show = !b:ws_show
    if b:ws_show|call ShowWhitespace(b:ws_flags)|else|call ShowWhitespace(&#039;&#039;)|endif
  endfunction
&nbsp;
endif
&nbsp;
" DYNAMIC SETTINGS / COLORS / TERMINAL {{{1
" ================================================================================================================================================================
&nbsp;
" DISABLE MOUSE NO GOOEYS {{{3
if has(&#039;mouse&#039;)|set mouse=|endif
&nbsp;
" SET TITLESTRING {{{3
if has(&#039;title&#039;)|set titlestring=%t%(\ [%R%M]%)|endif
&nbsp;
" SET TABLINE {{{3
if exists("*s:MyTabL")|set tabline=%!MyTabL()|endif
&nbsp;
let g:vimsyn_folding=&#039;af&#039;
&nbsp;
"DISABLE FILETYPE-SPECIFIC MAPS {{{3
let no_plugin_maps=1
&nbsp;
"}}}1 DYNAMIC SETTINGS / COLORS / TERMINAL
&nbsp;
" OPTIONS "{{{1
" ===========================================================================================================================================================================
&nbsp;
" BACKUP, FILE OPTIONS {{{2
" ================================================================================
set backup        " Make a backup before overwriting a file.  Leave it around after the file has been successfully written.
set backupcopy=auto " When writing a file and a backup is made, this option tells how it&#039;s done.  This is a comma separated list of words. - value: yes,no,auto - no:rename the file and write a new one
&nbsp;
set swapfile
set swapsync=fsync
&nbsp;
"}}}2 BACKUP, FILE OPTIONS
&nbsp;
" BASIC SETTINGS "{{{2
" ================================================================================
set nocompatible    " vim, not vi.. must be first, because it changes other options as a side effect
set modeline
&nbsp;
set statusline=%M%h%y\ %t\ %F\ %p%%\ %l/%L\ %=[%{&amp;ff},%{&amp;ft}]\ [a=\%03.3b]\ [h=\%02.2B]\ [%l,%v]
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ %{v:servername}
&nbsp;
"set tags=tags;/      " search recursively up for tags
&nbsp;
set ttyfast        " we have a fast terminal
set scrolljump=5    " when scrolling up down, show at least 5 lines
"set ttyscroll=999    " make vim redraw screen instead of scrolling when there are more than 3 lines to be scrolled
&nbsp;
"set tw=500        " default textwidth is a max of 5
&nbsp;
set undolevels=10    " 50 undos - saved in memory
set updatecount=250    " switch every 250 chars, save swap
&nbsp;
set whichwrap+=b,s,&lt;,&gt;,h,l,[,]      " backspaces and cursor keys wrap to
"set wildignore+=*.o,*~,.lo,*.exe,*.bak  " ignore object files
"set wildmenu              " menu has tab completion
"set wildmode=longest:full        " *wild* mode
set nowrap
&nbsp;
set autoindent smartindent    " auto/smart indent
&nbsp;
set autoread          " watch for file changes
&nbsp;
set backspace=indent,eol,start  " backspace over all kinds of things
&nbsp;
set cmdheight=1          " command line two lines high
set complete=.,w,b,u,U,t,i,d  " do lots of scanning on tab completion
set cursorline          " show the cursor line
"set enc=utf-8 fenc=utf-8    " utf-8
&nbsp;
set history=3000        " keep 3000 lines of command line history
&nbsp;
set keywordprg=TERM=mostlike\ man\ -s\ -Pless
&nbsp;
set laststatus=2
&nbsp;
"set lazyredraw          " don&#039;t redraw when don&#039;t have to
set linebreak          " wrap at &#039;breakat&#039; instead of last char
set magic            " Enable the "magic"
&nbsp;
set maxmem=25123  " 24 MB -  max mem in Kbyte to use for one buffer.  Max is 2000000
&nbsp;
set noautowrite          " don&#039;t automagically write on :next
&nbsp;
set noexpandtab          " no expand tabs to spaces"
set noruler          " show the line number on the bar
set nospell
set nohidden          " close the buffer when I close a tab (I use tabs more than buffers)
&nbsp;
set noerrorbells visualbell t_vb= " Disable ALL bells
&nbsp;
set number          " line numbers
&nbsp;
set pastetoggle=&lt;F11&gt;
&nbsp;
set scrolloff=3        " keep at least 3 lines above/below
set shiftwidth=3      " shift width
&nbsp;
set showcmd          " Show us the command we&#039;re typing
set showfulltag        " show full completion tags
set showmode        " show the mode all the time
&nbsp;
set sidescroll=2      " if wrap is off, this is fasster for horizontal scrolling
set sidescrolloff=2      "keep at least 5 lines left/right
&nbsp;
set noguipty
&nbsp;
set splitright
set splitbelow
&nbsp;
set restorescreen=on " restore screen contents when vim exits -  disable withset t_ti= t_te=
&nbsp;
"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,resize,sesdir,tabpages,winpos,winsize
set winheight=25
set winminheight=1  " minimal value for window height
"set winheight=30  " set the minimal window height
set equalalways    " all the windows are automatically sized same
set eadirection=both  " only equalalways for horizontally split windows
&nbsp;
set hlsearch
&nbsp;
set laststatus=2
&nbsp;
set tabstop=4
set softtabstop=4
&nbsp;
set shiftwidth=3
set switchbuf=usetab
&nbsp;
set commentstring=#%s
&nbsp;
set tabpagemax=55
set showtabline=2    " 2 always, 1 only if multiple tabs
set smarttab      " tab and backspace are smart
&nbsp;
set foldmethod=marker
set foldenable
set foldcolumn=6        " the blank left-most bar left of the numbered lines
&nbsp;
set incsearch          " incremental search
"set ignorecase          " search ignoring case
set sc              " override &#039;ignorecase&#039; when pattern has upper case characters
set smartcase          " Ignore case when searching lowercase
&nbsp;
set showmatch          " show matching bracket
set diffopt=filler,iwhite    " ignore all whitespace and sync"
set stal=2
&nbsp;
"}}}1 OPTIONS
&nbsp;
" PLUGIN SETTINGS {{{1
" ================================================================================================================================================================
" Settings for :TOhtml "{{{3
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
"}}}1 PLUGIN SETTINGS
&nbsp;
" COLORSCHEME IF MORE THAN 2 COLORS lol {{{1
" ================================================================================================================================================================
if &amp;t_Co &gt; 2
&nbsp;
  if &amp;term =~ "256"
&nbsp;
    set bg=dark t_Co=256 vb
    let &amp;t_vb="\&lt;Esc&gt;[?5h\&lt;Esc&gt;[?5l"  " flash screen for visual bell
&nbsp;
    if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
      colorscheme askapachecode
    elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"))
      colorscheme askapachecode
    else
      colorscheme default
    endif
&nbsp;
    filetype indent plugin on
    syntax on
&nbsp;
  else
    " things like cfdisk, crontab -e, visudo, vless, etc.
    set term=linux
    set t_Co=8
    syntax off
    filetype indent plugin off
&nbsp;
  endif
&nbsp;
endif
&nbsp;
"}}}1
&nbsp;
" AUTOCOMMANDS "{{{1
" ===========================================================================================================================================================================
"if !exists(":DiffOrig") | command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis | endif
&nbsp;
" auto load extensions for different file types
if has(&#039;autocmd&#039;)
&nbsp;
  if !exists("autocommands_loaded")
    let autocommands_loaded = 1
&nbsp;
    " JUMP TO LAST POS {{{3
    " When editing a file, always jump to the last known cursor position. Don&#039;t do it when the position is invalid or when inside an event handler
    " (happens when dropping a file on gvim). Also don&#039;t do it when the mark is in the first line, that is the default position when opening a file.
    au BufReadPost * if line("&#039;\"") &gt; 1 &amp;&amp; line("&#039;\"") &lt;= line("$") | exe "normal! g`\"" | endif
&nbsp;
    " CLEARMATCHES ON BUFWINLEAVE {{{3
    au BufWinLeave * call clearmatches()
&nbsp;
    " STRIP TRAILING WHITESPACE {{{3
    autocmd BufWritePre *.cpp,*.hpp,*.i :call StripTrailingWhitespace()
&nbsp;
    " AA_ZZZ LAST MOD {{{3
    autocmd BufWritePre,FileWritePre,TabLeave zzz_askapache-bash.sh ks|call LastModAAZZZ()|&#039;s
&nbsp;
    " SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
    autocmd BufRead /etc/ZZZ/*.sh,.bash_profile,.bash_login,.bashrc,.bash_login_user,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500 foldcolumn=7
&nbsp;
    " INSERT CURRENT DATE AND TIME IN A *.SH FILE WHEN WRITING IT {{{3
    autocmd BufWritePre,FileWritePre *.*   ks|call LastMod()|&#039;s
&nbsp;
    " IMPROVE LEGIBILITY {{{3
    autocmd BufRead quickfix setlocal nobuflisted wrap number
&nbsp;
    " SAVE BACKUPFILE AS BACKUPDIR/FILENAME-06-13-1331 {{{3
    autocmd BufWritePre * let &amp;bex = strftime("-%m-%d-%H%M")
&nbsp;
    " TMUX FILETYPE {{{3
    autocmd BufRead tmux.conf,.tmux.conf,.tmux*,*/tmux-sessions/* setlocal filetype=tmux foldmethod=marker
&nbsp;
    " APACHE2 FILETYPE {{{3
    autocmd BufRead /opt/a*/conf/*,/etc/httpd/*.conf setlocal filetype=apache
&nbsp;
    " SH FILETYPES {{{3
    autocmd BufRead *.sh,*.cron,*.bash setlocal filetype=sh
&nbsp;
    " SYSLOG-NG FILETYPE {{{3
    autocmd BufRead syslog-ng.conf setlocal filetype=syslog-ng
&nbsp;
    " COMMENTSTRING FOR VIM "{{{3
    au FileType vim setlocal commentstring="%s
&nbsp;
    " COMMENTSTRING FOR XDEFAULTS "{{{3
    au FileType xdefaults setlocal foldmethod=marker foldlevel=2 commentstring=!%s
&nbsp;
    " VIMRC {{{3
    augroup vimrc
      au BufReadPre * setlocal foldmethod=indent
      au BufWinEnter * if &amp;fdm == &#039;indent&#039; | set foldmethod=manual | endif
      au BufRead *.vim,vimrc,*.vimrc set filetype=vim ts=3 sw=3 tw=500 foldmethod=marker foldcolumn=6
    augroup END
&nbsp;
    " AUTOMKVIEWS {{{3
    " Warning - this will save your settings for each file you edit and restore those settings when opened again - can fill up quick
    au BufWinLeave *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc mkview
    au BufWinEnter *.sh,*.conf,*.vim,*.c,*.txt,.htaccess,*.cgi,*.php,*.html,*.conf,vimrc silent loadview
    " }}}3
&nbsp;
    " MAN RUNTIME - TODO REPLACE WITH TMUXES CTRL-M BINDING {{{3
    " Lets you type :Man anymanpage and it will load in vim, color-coded and searchable
    "runtime ftplugin/man.vim
&nbsp;
  endif
&nbsp;
endif
"}}}1
&nbsp;
" MAPS "{{{1
" ===========================================================================================================================================================================
&nbsp;
" FUNCTION MAPS {{{2
" ---------------------------------
" APPEND MODELINE {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;ml :call AppendModeline()&lt;CR&gt;
&nbsp;
" SHOW WHITESPACE {{{3
nnoremap &lt;LocalLeader&gt;ts :call ToggleShowWhitespace()&lt;CR&gt;
&nbsp;
" SUDO A WRITE {{{3
command! W :execute &#039;:silent w !sudo tee % &gt; /dev/null&#039; | :edit!
"cmap w!! %!sudo tee &gt; /dev/null %
" :w !sudo tee &gt; /dev/null %
&nbsp;
" SET TABLINE {{{3
" My Personal Fav, inserts last-modified manually on current line when you press &lt;F12&gt; key
" call setline(1, printf(&#039;%sUpdated: %s by %s@%s&#039;, printf(&amp;commentstring, &#039; &#039;), strftime("%c"), expand("$LOGNAME"), hostname()))
if exists("*s:LastModNow")
  map &lt;silent&gt; &lt;F12&gt; :call LastModNow()&lt;CR&gt;
endif
&nbsp;
" RELOAD VIMRC FILES {{{3
map &lt;LocalLeader&gt;. :mkview&lt;CR&gt;:unlet! AskApacheLoaded autocommands_loaded&lt;CR&gt;:mapclear&lt;CR&gt;:source /etc/vimrc&lt;CR&gt;:echoerr &#039;VIMRC RELOADED&#039;&lt;CR&gt;
&nbsp;
" SCROLLING MAPS {{{3
map &lt;PageDown&gt; :set scroll=0&lt;CR&gt;:set scroll^=2&lt;CR&gt;:set scroll-=1&lt;CR&gt;&lt;C-D&gt;:set scroll=0&lt;CR&gt;
map &lt;PageUp&gt; :set scroll=0&lt;CR&gt;:set scroll^=2&lt;CR&gt;:set scroll-=1&lt;CR&gt;&lt;C-U&gt;:set scroll=0&lt;CR&gt;
nnoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-U&gt;&lt;C-U&gt;
vnoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-U&gt;&lt;C-U&gt;
inoremap &lt;silent&gt; &lt;PageUp&gt; &lt;C-\&gt;&lt;C-O&gt;&lt;C-U&gt;&lt;C-\&gt;&lt;C-O&gt;&lt;C-U&gt;
nnoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-D&gt;&lt;C-D&gt;
vnoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-D&gt;&lt;C-D&gt;
inoremap &lt;silent&gt; &lt;PageDown&gt; &lt;C-\&gt;&lt;C-O&gt;&lt;C-D&gt;&lt;C-\&gt;&lt;C-O&gt;&lt;C-D&gt;
"}}}3
&nbsp;
" KEY MAPS {{{2
" physically map keys to produce different key, type CTRL-V in insert mode followed by any key to see how vim sees it
" ----------------------------------------
imap &lt;ESC&gt;[8~ &lt;End&gt;
map &lt;ESC&gt;[8~ &lt;End&gt;
&nbsp;
imap &lt;ESC&gt;[7~ &lt;Home&gt;
map &lt;ESC&gt;[7~ &lt;Home&gt;
&nbsp;
" Basic Maps  {{{2
" ----------------------------------------
" TOGGLE PASTE MODE {{{3
map &lt;LocalLeader&gt;pm :set nonumber! foldcolumn=0&lt;CR&gt;
&nbsp;
" REINDENT FILE {{{3
map &lt;LocalLeader&gt;ri G=gg&lt;CR&gt;
&nbsp;
" CLEAR SPACES AT END OF LINE {{{3
map &lt;LocalLeader&gt;cs :%s/\s\+$//e&lt;CR&gt;
&nbsp;
" Y YANKS FROM CURSOR TO $ {{{3
map Y y$
&nbsp;
" DON&#039;T USE EX MODE, USE Q FOR FORMATTING {{{3
map Q gq
map! ^H ^?
&nbsp;
" NEXT SEARCH RESULT {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;cn :cn&lt;CR&gt;
&nbsp;
" WRAP? {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;ww :ww
&nbsp;
" ERR INSERTION {{{3
"map &lt;silent&gt; &lt;LocalLeader&gt;e &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s&#039;, &#039;_err "$0 $FUNCNAME:$LINENO FAILED WITH ARGS= $*"&#039;)&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
&nbsp;
" CUSTOM LINES FOR CODING {{{3
map &lt;silent&gt; &lt;LocalLeader&gt;l1 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;=&#039;, 160))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l2 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;=&#039;, 80))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l3 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;-&#039;, 40))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
map &lt;silent&gt; &lt;LocalLeader&gt;l4 &lt;Home&gt;A&lt;C-R&gt;=printf(&#039;%s%s&#039;, printf(&amp;commentstring, &#039; &#039;), repeat(&#039;-&#039;, 20))&lt;CR&gt;&lt;Home&gt;&lt;Esc&gt;
&nbsp;
" CHANGE DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap &lt;LocalLeader&gt;cd :cd%:p:h&lt;CR&gt;
&nbsp;
" CHANGE LOCAL DIRECTORY TO THAT OF CURRENT FILE {{{3
nmap &lt;LocalLeader&gt;lcd :lcd%:p:h&lt;CR&gt;
&nbsp;
" TOGGLE WRAPPING {{{3
nmap &lt;LocalLeader&gt;ww :set wrap!&lt;CR&gt;
nmap &lt;LocalLeader&gt;wo :set wrap&lt;CR&gt;
&nbsp;
" TABS "{{{2
" ---------------------------------
&nbsp;
" CREATE A NEW TAB {{{3
map &lt;LocalLeader&gt;tc :tabnew %&lt;CR&gt;
&nbsp;
" LAST TAB {{{3
map &lt;LocalLeader&gt;t&lt;Space&gt; :tablast&lt;CR&gt;
&nbsp;
" CLOSE A TAB {{{3
map &lt;LocalLeader&gt;tk :tabclose&lt;CR&gt;
&nbsp;
" NEXT TAB {{{3
map &lt;LocalLeader&gt;tn :tabnext&lt;CR&gt;
&nbsp;
" PREVIOUS TAB {{{3
map &lt;LocalLeader&gt;tp :tabprev&lt;CR&gt;
&nbsp;
" FOLDS   "{{{2
" ---------------------------------
" Fold with paren begin/end matching
nmap F zf%
&nbsp;
" When I use ,sf - return to syntax folding with a big foldcolumn
nmap &lt;LocalLeader&gt;sf :set foldcolumn=6 foldmethod=syntax&lt;cr&gt;
"}}}2
&nbsp;
"}}}1
&nbsp;
" HILITE "{{{1
" ===========================================================================================================================================================================
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
"}}}
&nbsp;
</pre>


<h2>Colorscheme</h2>
<p>Here is a colorscheme file optimized for 256 colors.  It will work if saved in <code>~/.vim/colors/askapachecode.vim</code> or likewise in your runtimepath.  Additionally, you could just paste it in the bottom of the above vimrc.  The code really needs to be cleaned up, but it looks awesome.</p>
<p>Download - <a href='http://uploads.askapache.com/2012/02/askapachecode.txt'>askapachecode - 256 Colors Vim Colorscheme</a></p>
<p><code>~/.vim/colors/askapachecode.vim</code></p>
<pre>
" Vim color file -- askapachecode
" Maintainer: AskApache &lt;webmaster@askapache.com&gt;
" Updated: Wed Feb 22 14:10:54 2012 by galileo@galileo
&nbsp;
set background=dark
hi clear
&nbsp;
if exists("syntax_on")|syntax reset|endif
&nbsp;
let g:colors_name="askapachecode"
&nbsp;
" Vim &gt;= 7.0 specific colors
if version &gt;= 700
 hi CursorLine ctermbg=236
 hi CursorColumn ctermbg=236
 hi MatchParen ctermfg=157 ctermbg=237 cterm=bold
 hi Pmenu ctermfg=255 ctermbg=238
 hi PmenuSel ctermfg=0 ctermbg=148
endif
&nbsp;
" General colors
hi Cursor ctermbg=241
hi Normal ctermfg=253 ctermbg=232
hi NonText ctermfg=244 ctermbg=235
hi LineNr ctermfg=244 ctermbg=232
hi StatusLine ctermfg=253 ctermbg=238 cterm=italic
hi StatusLineNC ctermfg=246 ctermbg=238
hi VertSplit ctermfg=238 ctermbg=238
hi Folded ctermbg=4 ctermfg=248
hi Title ctermfg=254 cterm=bold
hi Visual ctermfg=254 ctermbg=4
hi SpecialKey ctermfg=244 ctermbg=236
&nbsp;
hi pythonOperator ctermfg=103
&nbsp;
hi Search cterm=NONE  
&nbsp;
" basic highlight groups (:help highlight-groups) {{{1
&nbsp;
" text {{{2
hi Normal ctermfg=white ctermbg=black cterm=NONE
hi Folded ctermfg=lightgray ctermbg=black cterm=underline
hi LineNr ctermfg=darkgray ctermbg=NONE cterm=NONE
hi Directory ctermfg=cyan ctermbg=NONE cterm=NONE
hi NonText ctermfg=yellow ctermbg=NONE cterm=NONE
hi SpecialKey ctermfg=green ctermbg=NONE cterm=NONE
&nbsp;
hi DiffAdd ctermfg=white ctermbg=darkblue cterm=NONE
hi DiffChange ctermfg=black ctermbg=darkmagenta cterm=NONE
hi DiffDelete ctermfg=black ctermbg=red cterm=bold
hi DiffText ctermfg=white ctermbg=green cterm=bold
&nbsp;
" borders / separators / menus {{{2
hi FoldColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi SignColumn ctermfg=lightgray ctermbg=darkgray cterm=NONE
hi Pmenu ctermfg=white ctermbg=darkgray cterm=NONE
hi PmenuSel ctermfg=white ctermbg=lightblue cterm=NONE
hi PmenuSbar ctermfg=black ctermbg=black cterm=NONE
hi PmenuThumb ctermfg=gray ctermbg=gray cterm=NONE
&nbsp;
hi StatusLine ctermfg=black ctermbg=white cterm=bold
hi StatusLineNC ctermfg=darkgray ctermbg=white cterm=NONE
hi WildMenu ctermfg=white ctermbg=darkblue cterm=bold
hi VertSplit ctermfg=white ctermbg=white cterm=NONE
&nbsp;
if &amp;t_Co == 256|hi TabLine ctermfg=15 ctermbg=242 term=underline|else|hi TabLine ctermfg=grey ctermbg=white term=underline|endif
"hi TabLine ctermfg=white ctermbg=white cterm=NONE
hi TabLineFill ctermfg=grey ctermbg=white cterm=NONE
"hi TabLineSel ctermfg=black ctermbg=green cterm=NONE
hi TabLineSel ctermfg=green ctermbg=black term=bold
"hi TabLineSel term=bold cterm=bold
"hi TabLineFill term=reverse cterm=reverse 
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242
&nbsp;
"hi Menu
"hi Scrollbar
"hi Tooltip
&nbsp;
" cursor / dynamic / other {{{2
hi Cursor ctermfg=black ctermbg=white cterm=NONE
hi CursorIM ctermfg=black ctermbg=white cterm=reverse
hi CursorLine ctermfg=NONE ctermbg=NONE cterm=NONE
hi CursorColumn ctermfg=NONE ctermbg=NONE cterm=NONE
&nbsp;
hi Visual ctermfg=white ctermbg=lightblue cterm=NONE
hi IncSearch ctermfg=white ctermbg=yellow cterm=NONE
hi Search ctermfg=white ctermbg=darkgreen cterm=NONE
&nbsp;
" LISTINGS / MESSAGES {{{2
hi ModeMsg ctermfg=yellow ctermbg=NONE cterm=NONE
hi Title ctermfg=red ctermbg=NONE cterm=bold
hi Question ctermfg=green ctermbg=NONE cterm=NONE
hi MoreMsg ctermfg=green ctermbg=NONE cterm=NONE
hi ErrorMsg ctermfg=white ctermbg=red cterm=bold
hi WarningMsg ctermfg=yellow ctermbg=NONE cterm=bold
&nbsp;
hi Directory term=bold ctermfg=4 "{{{
hi ErrorMsg term=standout ctermfg=15 ctermbg=1  
hi IncSearch term=reverse cterm=reverse 
hi Search term=NONE ctermfg=255 ctermbg=135
hi MoreMsg term=bold ctermfg=2  
hi ModeMsg term=bold cterm=bold 
hi LineNr term=underline ctermfg=244 ctermbg=232  
hi Question term=standout ctermfg=2  
hi StatusLine term=bold,reverse cterm=italic ctermfg=253 ctermbg=238   
hi StatusLineNC term=reverse cterm=reverse ctermfg=246 ctermbg=238  
hi VertSplit term=reverse cterm=reverse ctermfg=238 ctermbg=238  
hi Title term=bold cterm=bold ctermfg=254  
hi Visual term=reverse ctermfg=254 ctermbg=4  
hi VisualNOS term=bold,underline cterm=bold,underline
hi WarningMsg term=standout ctermfg=1 
hi WildMenu term=standout ctermfg=0 ctermbg=11  
hi Folded term=standout cterm=BOLD ctermfg=7 ctermbg=27
hi FoldColumn term=NONE cterm=NONE ctermfg=75 ctermbg=16
hi IncSearch term=bold,underline cterm=bold,underline ctermfg=7 ctermbg=9
hi DiffAdd term=bold ctermbg=12 
hi DiffChange term=bold ctermbg=13 
hi DiffDelete term=bold ctermfg=12 ctermbg=14   
hi DiffText term=reverse cterm=bold ctermbg=9  
hi SpellBad term=reverse ctermbg=9  
hi SpellCap term=reverse ctermbg=12  
hi SpellRare term=reverse ctermbg=13  
hi SpellLocal term=underline ctermbg=14  
hi Pmenu ctermfg=255 ctermbg=238  
hi PmenuSel ctermfg=0 ctermbg=148  
hi PmenuSbar ctermbg=7 
hi PmenuThumb cterm=reverse 
hi TabLine term=underline cterm=underline ctermfg=0 ctermbg=7  
hi TabLineSel term=bold cterm=bold 
hi TabLineFill term=reverse cterm=reverse 
hi CursorLine term=underline cterm=bold ctermbg=234
hi Cursor ctermbg=241 
hi MatchParen term=reverse cterm=bold ctermfg=157 ctermbg=237   
hi Error term=reverse ctermfg=15 ctermbg=9  
&nbsp;
" :hi TabLineSel|hi TabLineFill|hi TabLine
"hi TabLineSel term=bold cterm=bold 
"hi TabLineFill term=reverse cterm=reverse 
"hi TabLine term=underline cterm=underline ctermfg=15 ctermbg=242 
hi ExtraWhitespace ctermbg=red
hi Comment term=none ctermfg=darkgrey 
hi Constant term=underline ctermfg=Magenta 
hi Special term=bold ctermfg=DarkMagenta 
hi Identifier term=underline cterm=bold ctermfg=Cyan 
hi Statement term=bold ctermfg=Yellow 
hi PreProc term=underline ctermfg=LightBlue 
hi Type term=underline ctermfg=LightGreen 
hi Repeat term=underline ctermfg=White 
hi Operator ctermfg=Red 
hi Ignore ctermfg=black 
hi Error term=reverse ctermbg=Red ctermfg=White 
hi Todo term=standout ctermbg=Yellow ctermfg=Black 
&nbsp;
" COMMON GROUPS THAT LINK TO DEFAULT HIGHLIGHTING.
&nbsp;
hi Function ctermfg=85
hi String ctermfg=204
hi Statement term=bold cterm=bold ctermfg=81
hi Function term=bold cterm=bold ctermfg=32
hi Number ctermfg=129
hi Conditional term=bold cterm=bold ctermfg=47
hi Special term=underline ctermfg=191
hi Normal ctermfg=7
hi PreProc ctermfg=141
" Syntax highlighting
hi Comment ctermfg=244
hi Todo ctermfg=245
hi Boolean ctermfg=148
hi String ctermfg=148
hi Identifier ctermfg=148
hi Function ctermfg=124
hi Type ctermfg=103
hi Statement ctermfg=103
hi Keyword ctermfg=81
hi Constant ctermfg=81
hi Number ctermfg=81
hi Special ctermfg=81
hi PreProc ctermfg=230
" Code-specific colors
 
&nbsp;
" SYNTAX HIGHLIGHTING GROUPS (:HELP GROUP-NAME) {{{2
hi FoldColumn ctermbg=0 ctermfg=2
hi Folded cterm=none ctermfg=2
hi NonText cterm=NONE ctermfg=NONE 
hi StatusLine ctermfg=black ctermbg=White cterm=bold
hi StatusLineNC ctermfg=White ctermbg=green cterm=NONE
hi CursorLine cterm=bold term=bold
&nbsp;
" FINAL THOUGHTS "{{{2
"syn region myFold start="{" end="}" transparent fold
hi Search term=reverse ctermfg=0 ctermbg=11
hi LineNr term=underline ctermfg=244 ctermbg=232
hi MatchParen ctermfg=15 ctermbg=242
hi String ctermfg=10
hi Constant ctermfg=14
hi Identifier ctermfg=14
hi Operator ctermfg=13
hi NonText cterm=NONE ctermfg=NONE
hi Search cterm=bold ctermbg=99 ctermfg=17
</pre>


<h2>Additional Resources</h2>
<ol>
<li><a href="http://spf13.com/post/perfect-vimrc-vim-config-file">The perfect .vimrc vim config file</a></li>
</ol><p><a href="http://www.askapache.com/linux/fast-vimrc.html"></a><a href="http://www.askapache.com/linux/fast-vimrc.html">Optimized Vimrc with 256 Colorscheme</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/fast-vimrc.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Terminal Escape Code Zen</title>
		<link>http://www.askapache.com/linux/zen-terminal-escape-codes.html</link>
		<comments>http://www.askapache.com/linux/zen-terminal-escape-codes.html#comments</comments>
		<pubDate>Wed, 13 Apr 2011 04:00:27 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4113</guid>
		<description><![CDATA[<p><strong>An image and technicacl achievement so profound, it will touch yoour heart</strong>..        So 3D... it'll hurt you eyes!  LOL..  lol.. Man I am cracking up here.  haha  Ha definately the best intro ever, those really do look 3D for terminal though huh.. Sweet.  Here is the little function I wrote to output that grey marble.</p>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3db.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="795" height="481" class="alignnone size-full wp-image-4886" /></a></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"></a><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><cite>AskApache.com</cite></a></p><h3>Lightning Strikes Twice!</h3>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3da.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="892" height="375" class="alignnone size-full wp-image-4885" /></a></p>
<p>LOL.. </p>
<h2>3rd Dimension Broken with Bash!</h2>
<p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"><img src="http://uploads.askapache.com/2011/04/3db.png" alt="AskApache Conquers the 3rd Dimension in Bash" title="AskApache Conquers the 3rd Dimension in Bash" width="795" height="481" class="alignnone size-full wp-image-4886" /></a></p>
<p><strong>So 3D... it'll hurt you eyes!</strong>  lol.. Man I am cracking up here.   Ha but seriously those really do look 3D for terminal though..  I am actually really impressed.   Sweet.  Here is the little function I wrote to output that grey marble.</p>

<p class="cnote">Just a word to the wise, start learning and going over some of these concepts, especially the code used in functions, I will be back in a followup that details actually using this stu.


<p>This function is one of my favorites because it is so fast and useful.  Like when designing a 256color prompt.</p>
<pre>
aa_256 ()
{
    local o x=`tput op` y=`printf %$((${COLUMNS}-6))s`;
    for i in {0..256};
    do
        o=00$i;
        echo -e ${o:${#o}-3:3} `tputm "setaf $i" "setab $i"`${y// /=}$x;
    done
}</pre>



<p>Ya this is actually not very helpful or useful, but there you have it.</p>
<pre>tputm ()
{
    local a;
    for a in "$@";
    do
        echo -en "${a}\n";
    done | tput -S
}</pre>



<p>Some people call this function the grey bringer of death.  Not really.</p>
<pre>a256 ()
{
    ( x=`tput op` y=`printf %$((${COLUMNS}-6))slocal `;
    for i in {242..232} 232 232;
    do
        echo -en "`tput setaf $i;tput setab $i`${y}${x}`tput op`";
    done )
}</pre>



<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=348099">Fix screen</a>











<h2>Helpful Ncurses Programs</h2>
<table class="bordered"><tbody><tr class="header"><th>Program Name</th><th>Description</th><th>Example Usage</th></tr>
<tr><td>infotocap</td><td>convert a terminfo description into a termcap description</td><td><code></code></td></tr>
<tr><td>tic</td><td>the terminfo entry-description compiler</td><td><code></code></td></tr>
<tr><td>toe</td><td>table of (terminfo) entries</td><td><code>toe -a|sort -d</code></td></tr>
<tr><td>infocmp</td><td>compare or print out terminfo descriptions</td><td><code>infocmp -a  -L -1 -T -x</code></td></tr>
<tr><td>capconvert</td><td>automated conversion from termcap to terminfo</td><td><code></code></td></tr>
<tr><td>stty</td><td>prints or changes terminal characteristics, such as baud rate.</td><td><code></code></td></tr>
<tr><td>clear</td><td>clears the terminal's screen</td><td><code></code></td></tr>
<tr><td>capconvert</td><td>automated conversion from termcap to terminfo</td><td><code></code></td></tr>
</tbody></table>


<h3>ALWAYS check out my functions!</h3>
<p>This function will print out the terminal, show it's colors, etc..  I have some really nice ones in this article that I use for tmux, screen, and that sort of thing.</p>
<pre>c ()
{
    tput clear;
    pm "$TERM: [colors:`tput colors`/`tput pairs`]";
    RC=`tput op` L1=$(L &#039;=&#039; $(( ${COLUMNS} - 25 )));
    for i in `seq ${1:-0} ${2:-16}`;
    do
        o="  $i";
        echo -e " ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${L1}${RC}";
    done
}</pre>








<h2>Standard Capabilities</h2>
<h4>X.364 and iBCS2</h4>
<ul>
<li><code>\033c</code> - <var>RIS</var> - full reset</li>
<li><code>\0337</code> - <var>SC</var> - save cursor</li>
<li><code>\0338</code> - <var>RC</var> - restore cursor</li>
<li><code>\033[r</code> - <var>RSR</var> - not an X.364 mnemonic</li>
<li><code>\033[m</code> - <var>SGR0</var> - not an X.364 mnemonic</li>
<li><code>\033[2J</code> - <var>ED2</var> - clear page</li>
</ul>

<h4>Specified by ISO 2022</h4>
<ul>
<li><code>\033(0</code> - <var>ISO DEC G0</var> - enable DEC graphics for G0</li>
<li><code>\033(A</code> - <var>ISO UK G0</var> - enable UK chars for G0</li>
<li><code>\033(B</code> - <var>ISO US G0</var> - enable US chars for G0</li>
<li><code>\033)0</code> - <var>ISO DEC G1</var> - enable DEC graphics for G1</li>
<li><code>\033)A</code> - <var>ISO UK G1</var> - enable UK chars for G1</li>
<li><code>\033)B</code> - <var>ISO US G1</var> - enable US chars for G1</li>
</ul>


<h2>ISO 2022 charset switching:</h2>
<ul>
   <li><a href="http://www.iso.ch/cate/d22747.html">ISO/IEC 2022:1994</a> </li>
   <li>"Character code structure and extension techniques" </li>
   <li><a href="http://www.ecma.ch/stand/ECMA-035.HTM">ECMA-035</a> </li>
   <li>code structure
      <ul>
         <li>=00..=1F C0 set of <a href="iso6429.html">control characters</a> </li>
         <li>=20..=7F G0 set of 94 or 96 <a href="iso646.html">graphic characters</a> </li>
         <li>=80..=9F C1 set of control characters "C1 controls" </li>
         <li>=A0..=FF G1 set of 94 or 96 graphic characters </li>
         <li>... G2 and G3 </li>
      </ul>
   </li>
   <li><a href="http://www.iso.ch/infoe/agency/2375.htm">registration authority</a>
      <ul>
         <li><a href="http://www.iso.ch/cate/d7217.html">ISO/IEC 2375:1985</a> Procedure for registration of escape sequences </li>
         <li>"ECMA registry" </li>
         <li>ISO-IR registration number </li>
         <li><a href="ftp://dkuug.dk/i18n/iso2375reg.txt">ftp://dkuug.dk/i18n/iso2375reg.txt</a> </li>
         <li><a href="http://www.itscj.ipsj.or.jp/ISO-IR/practice/practice.html">Internaltional</a> <a href="http://www.itscj.ipsj.or.jp/ISO-IR/">register of coded character sets to be used with escape sequences</a> </li>
         <li><a href="http://www.dkuug.dk/jtc1/sc2/wg3/">ISO/IEC JTC1/SC2/WG3</a> </li>
      </ul>
   </li>
   <li>ISO-2022 terminals from Siemens </li>
   <li>recode iso-2022..<a href="http://web.archive.org/web/czyborra.com/utf/#UTF-8">utf-8</a> not yet
      implemented </li>
   <li><a href="cjk.html">CJK charsets</a>
      <ul>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1458.txt">ISO-2022-JP</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1554.txt">ISO-2022-JP-2</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1557.txt">ISO-2022-KR</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1922.txt">ISO-2022-CN</a> </li>
         <li><a href="ftp://ftp.isi.edu/in-notes/rfc1922.txt">ISO-2022-CN-EXT</a> </li>
      </ul>
   </li>
</ul>


<h4>DEC private controls widely supported by emulators</h4>
<ul>
<li><code>\033=</code> - <var>DECPAM</var> - application keypad mode</li>
<li><code>\033&gt;</code> - <var>DECPNM</var> - normal keypad mode</li>
<li><code>\033&lt;</code> - <var>DECANSI</var> - enter ANSI mode</li>
<li><code>\033[!p</code> - <var>DECSTR</var> - soft reset</li>
<li><code>\033 F</code> - <var>S7C1T</var> - 7-bit controls</li>
</ul>


<h3>ECMA modes</h3>
<h4>ISO 2022</h4>
<ul>
<li><code>2</code> - <var>AM</var> - keyboard action mode</li>
<li><code>4</code> - <var>IRM</var> - insert/replace mode</li>
<li><code>12</code> - <var>SRM</var> - send/receive mode</li>
<li><code>20</code> - <var>LNM</var> - linefeed mode</li>
</ul>

<h3>DEC modes</h3>
<ul>
<li><code>1</code> - <var>CKM</var> - application cursor keys</li>
<li><code>2</code> - <var>ANM</var> - set VT52 mode</li>
<li><code>3</code> - <var>COLM</var> - 132-column mode</li>
<li><code>4</code> - <var>SCLM</var> - smooth scroll</li>
<li><code>5</code> - <var>SCNM</var> - reverse video mode</li>
<li><code>6</code> - <var>OM</var> - origin mode</li>
<li><code>7</code> - <var>AWM</var> - wraparound mode</li>
<li><code>8</code> - <var>ARM</var> - auto-repeat mode</li>
</ul>

<h3>ECMA attribute sequences</h3>
<ul>
<li><var>0</var> - <code>NORMAL</code> - normal</li>
<li><var>1</var> - <code>+BOLD</code> - bold on</li>
<li><var>2</var> - <code>+DIM</code> - dim on</li>
<li><var>3</var> - <code>+ITALIC</code> - italic on</li>
<li><var>4</var> - <code>+UNDERLINE</code> - underline on</li>
<li><var>5</var> - <code>+BLINK</code> - blink on</li>
<li><var>6</var> - <code>+FASTBLINK</code> - fastblink on</li>
<li><var>7</var> - <code>+REVERSE</code> - reverse on</li>
<li><var>8</var> - <code>+INVISIBLE</code> - invisible on</li>
<li><var>9</var> - <code>+DELETED</code> - deleted on</li>
<li><var>10</var> - <code>MAIN-FONT</code> - select primary font</li>
<li><var>11</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>12</var> - <code>ALT-FONT-2</code> - select alternate font 2</li>
<li><var>13</var> - <code>ALT-FONT-3</code> - select alternate font 3</li>
<li><var>14</var> - <code>ALT-FONT-4</code> - select alternate font 4</li>
<li><var>15</var> - <code>ALT-FONT-5</code> - select alternate font 5</li>
<li><var>16</var> - <code>ALT-FONT-6</code> - select alternate font 6</li>
<li><var>17</var> - <code>ALT-FONT-7</code> - select alternate font 7</li>
<li><var>18</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>19</var> - <code>ALT-FONT-1</code> - select alternate font 1</li>
<li><var>20</var> - <code>FRAKTUR</code> - Fraktur font</li>
<li><var>21</var> - <code>DOUBLEUNDER</code> - double underline</li>
<li><var>22</var> - <code>-DIM</code> - dim off</li>
<li><var>23</var> - <code>-ITALIC</code> - italic off</li>
<li><var>24</var> - <code>-UNDERLINE</code> - underline off</li>
<li><var>25</var> - <code>-BLINK</code> - blink off</li>
<li><var>26</var> - <code>-FASTBLINK</code> - fastblink off</li>
<li><var>27</var> - <code>-REVERSE</code> - reverse off</li>
<li><var>28</var> - <code>-INVISIBLE</code> - invisible off</li>
<li><var>29</var> - <code>-DELETED</code> - deleted off</li>
</ul>



<h3>Init strings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>is1</var></td><td>init_1string</td></tr>
<tr><td><var>is2</var></td><td>init_2string</td></tr>
<tr><td><var>is3</var></td><td>init_3string</td></tr>
<tr><td><var>rs1</var></td><td>reset_1string</td></tr>
<tr><td><var>rs2</var></td><td>reset_2string</td></tr>
<tr><td><var>rs3</var></td><td>reset_3string</td></tr>
<tr><td><var>smcup</var></td><td>enter_ca_mode</td></tr>
<tr><td><var>rmcup</var></td><td>exit_ca_mode</td></tr>
</tbody></table>

<h3>Cap strings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>so</td><td>String of commands to enter standout mode.</td></tr>
<tr><td>se</td><td>String of commands to leave standout mode.</td></tr>
<tr><td>sg</td><td>Numeric capability, the width on the screen of the magic cookie.  This capability is absent in terminals that record appearance modes character by character.</td></tr>
<tr><td>ms</td><td>Flag whose presence means that it is safe to move the cursor while the appearance modes are not in the normal state.  If this flag is absent, programs should always reset the appearance modes to normal before moving the cursor.</td></tr>
<tr><td>xs</td><td>Flag whose presence means that the only way to reset appearance modes already on the screen is to clear to end of line.  On a per-character terminal, you must clear the area where the modes are set.  On a magic cookie terminal, you must clear an area containing the cookie. See the discussion above.</td></tr>
<tr><td>xt</td><td>Flag whose presence means that the cursor cannot be positioned right in front of a magic cookie, and that seis a command to delete the next magic cookie following the cursor.  See discussion above.</td></tr>
<tr><td>mb</td><td>String of commands to enter blinking mode.</td></tr>
<tr><td>md</td><td>String of commands to enter double-bright mode.</td></tr>
<tr><td>mh</td><td>String of commands to enter half-bright mode.</td></tr>
<tr><td>mk</td><td>String of commands to enter invisible mode.</td></tr>
<tr><td>mp</td><td>String of commands to enter protected mode.</td></tr>
<tr><td>mr</td><td>String of commands to enter reverse-video mode.</td></tr>
<tr><td>me</td><td>String of commands to turn off all appearance modes, including standout mode and underline mode.  On some terminals it also turns off alternate character set mode; on others, it may not.  This capability must be present if any of mb<small>...</small> mris present.</td></tr>
<tr><td>as</td><td>String of commands to turn on alternate character set mode.  This mode assigns some or all graphic characters an alternate picture on the screen.  There is no standard as to what the alternate pictures look like.</td></tr>
<tr><td>ae</td><td>String of commands to turn off alternate character set mode.</td></tr>
<tr><td>sa</td><td>String of commands to turn on an arbitrary combination of appearance modes.  It accepts 9 parameters, each of which controls a particular kind of appearance mode.  A parameter should be 1 to turn its appearance mode on, or zero to turn that mode off.  Most terminals do not support the sacapability, even among those that do have various appearance modes.  The nine parameters are, in order,
<ol>
<li><var>standout</var></li><li><var>underline</var> </li><li><var>reverse</var> </li><li><var>blink</var> </li><li><var>half-bright</var> </li><li><var>double-bright</var> </li><li><var>blank</var> </li><li><var>protect</var> </li><li><var>alt char set</var> </li>
</ol>
</td></tr>
</tbody></table>



<h2>Variable and Function Index</h2>
<p>For stty</p>
<ul>
<li><code>BC</code>: tgoto</li>
<li><code>ospeed</code>: Output Padding</li>
<li><code>PC</code>: Output Padding</li>
<li><code>tgetent</code>: Find</li>
<li><code>tgetflag</code>: Interrogate</li>
<li><code>tgetnum</code>: Interrogate</li>
<li><code>tgetstr</code>: Interrogate</li>
<li><code>tgoto</code>: tgoto</li>
<li><code>tparam</code>: tparam</li>
<li><code>tputs</code>: Output Padding</li>
<li><code>UP</code>: tgoto</li>
</ul>


<h2>Summary of Capability Names</h2>
<p>Here are all the terminal capability names in alphabetical order with a brief description of each.  For cross references to their definitions, see the index of capability names.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>ae</td><td>String to turn off alternate character set mode.</td></tr>
<tr><td>al</td><td>String to insert a blank line before the cursor.</td></tr>
<tr><td>AL</td><td>String to insert <var>n</var> blank lines before the cursor.</td></tr>
<tr><td>am</td><td>Flag: output to last column wraps cursor to next line.</td></tr>
<tr><td>as</td><td>String to turn on alternate character set mode.like.</td></tr>
<tr><td>bc</td><td>Very obsolete alternative name for the lecapability.</td></tr>
<tr><td>bl</td><td>String to sound the bell.</td></tr>
<tr><td>bs</td><td>Obsolete flag: ASCII backspace may be used for leftward motion.</td></tr>
<tr><td>bt</td><td>String to move the cursor left to the previous hardware tab stop column.</td></tr>
<tr><td>bw</td><td>Flag: leat left margin wraps to end of previous line.</td></tr>
<tr><td>CC</td><td>String to change terminal's command character.</td></tr>
<tr><td>cd</td><td>String to clear the line the cursor is on, and following lines.</td></tr>
<tr><td>ce</td><td>String to clear from the cursor to the end of the line.</td></tr>
<tr><td>ch</td><td>String to position the cursor at column <var>c</var> in the same line.</td></tr>
<tr><td>cl</td><td>String to clear the entire screen and put cursor at upper left corner.</td></tr>
<tr><td>cm</td><td>String to position the cursor at line <var>l</var>, column <var>c</var>.</td></tr>
<tr><td>CM</td><td>String to position the cursor at line <var>l</var>, column <var>c</var>, relative to display memory.</td></tr>
<tr><td>co</td><td>Number: width of the screen.</td></tr>
<tr><td>cr</td><td>String to move cursor sideways to left margin.</td></tr>
<tr><td>cs</td><td>String to set the scroll region.</td></tr>
<tr><td>cS</td><td>Alternate form of string to set the scroll region.</td></tr>
<tr><td>ct</td><td>String to clear all tab stops.</td></tr>
<tr><td>cv</td><td>String to position the cursor at line <var>l</var> in the same column.</td></tr>
<tr><td>da</td><td>Flag: data scrolled off top of screen may be scrolled back.</td></tr>
<tr><td>db</td><td>Flag: data scrolled off bottom of screen may be scrolled back.</td></tr>
<tr><td>dB</td><td>Obsolete number: msec of padding needed for the backspace character.</td></tr>
<tr><td>dc</td><td>String to delete one character position at the cursor.</td></tr>
<tr><td>dC</td><td>Obsolete number: msec of padding needed for the carriage-return character.</td></tr>
<tr><td>DC</td><td>String to delete <var>n</var> characters starting at the cursor.</td></tr>
<tr><td>dF</td><td>Obsolete number: msec of padding needed for the formfeed character.</td></tr>
<tr><td>dl</td><td>String to delete the line the cursor is on.</td></tr>
<tr><td>DL</td><td>String to delete <var>n</var> lines starting with the cursor's line.</td></tr>
<tr><td>dm</td><td>String to enter delete mode.</td></tr>
<tr><td>dN</td><td>Obsolete number: msec of padding needed for the newline character.</td></tr>
<tr><td>do</td><td>String to move the cursor vertically down one line.</td></tr>
<tr><td>DO</td><td>String to move cursor vertically down <var>n</var> lines.</td></tr>
<tr><td>ds</td><td>String to disable the display of the status line.</td></tr>
<tr><td>dT</td><td>Obsolete number: msec of padding needed for the tab character.</td></tr>
<tr><td>ec</td><td>String of commands to clear <var>n</var> characters at cursor.</td></tr>
<tr><td>ed</td><td>String to exit delete mode.</td></tr>
<tr><td>ei</td><td>String to leave insert mode.</td></tr>
<tr><td>eo</td><td>Flag: output of a space can erase an overstrike.</td></tr>
<tr><td>es</td><td>Flag: other display commands work while writing the status line.</td></tr>
<tr><td>ff</td><td>String to advance to the next page, for a hardcopy terminal.</td></tr>
<tr><td>fs</td><td>String to move the cursor back from the status line to its previous position (outside the status line).</td></tr>
<tr><td>gn</td><td>Flag: this terminal type is generic, not real.</td></tr>
<tr><td>hc</td><td>Flag: hardcopy terminal.</td></tr>
<tr><td>hd</td><td>String to move the cursor down half a line.</td></tr>
<tr><td>ho</td><td>String to position cursor at upper left corner.</td></tr>
<tr><td>hs</td><td>Flag: the terminal has a status line.</td></tr>
<tr><td>hu</td><td>String to move the cursor up half a line.</td></tr>
<tr><td>hz</td><td>Flag: terminal cannot accept ~as output.</td></tr>
<tr><td>i1</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>i3</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>ic</td><td>String to insert one character position at the cursor.</td></tr>
<tr><td>IC</td><td>String to insert <var>n</var> character positions at the cursor.</td></tr>
<tr><td>if</td><td>String naming a file of commands to initialize the terminal.</td></tr>
<tr><td>im</td><td>String to enter insert mode.</td></tr>
<tr><td>in</td><td>Flag: outputting a space is different from moving over empty positions.</td></tr>
<tr><td>ip</td><td>String to output following an inserted character in insert mode.</td></tr>
<tr><td>is</td><td>String to initialize the terminal for each login session.</td></tr>
<tr><td>it</td><td>Number: initial spacing between hardware tab stop columns.</td></tr>
<tr><td>k0</td><td>String of input sent by function key 0 or 10.</td></tr>
<tr><td>k1 ... k9</td><td>Strings of input sent by function keys 1 through 9.</td></tr>
<tr><td>K1 ... K5</td><td>Strings sent by the five other keys in 3-by-3 array with arrows.</td></tr>
<tr><td>ka</td><td>String of input sent by the “clear all tabs” key.</td></tr>
<tr><td>kA</td><td>String of input sent by the “insert line” key.</td></tr>
<tr><td>kb</td><td>String of input sent by the “backspace” key.</td></tr>
<tr><td>kC</td><td>String of input sent by the “clear screen” key.</td></tr>
<tr><td>kd</td><td>String of input sent by typing the down-arrow key.</td></tr>
<tr><td>kD</td><td>String of input sent by the “delete character” key.</td></tr>
<tr><td>ke</td><td>String to make the function keys work locally.</td></tr>
<tr><td>kE</td><td>String of input sent by the “clear to end of line” key.</td></tr>
<tr><td>kF</td><td>String of input sent by the “scroll forward” key.</td></tr>
<tr><td>kh</td><td>String of input sent by typing the “home-position” key.</td></tr>
<tr><td>kH</td><td>String of input sent by the “home down” key.</td></tr>
<tr><td>kI</td><td>String of input sent by the “insert character” or “enter insert mode” key.</td></tr>
<tr><td>kl</td><td>String of input sent by typing the left-arrow key.</td></tr>
<tr><td>kL</td><td>String of input sent by the “delete line” key.</td></tr>
<tr><td>km</td><td>Flag: the terminal has a Meta key.</td></tr>
<tr><td>kM</td><td>String of input sent by the “exit insert mode” key.</td></tr>
<tr><td>kn</td><td>Numeric value, the number of numbered function keys.</td></tr>
<tr><td>kN</td><td>String of input sent by the “next page” key.</td></tr>
<tr><td>ko</td><td>Very obsolete string listing the terminal's named function keys.</td></tr>
<tr><td>kP</td><td>String of input sent by the “previous page” key.</td></tr>
<tr><td>kr</td><td>String of input sent by typing the right-arrow key.</td></tr>
<tr><td>kR</td><td>String of input sent by the “scroll reverse” key.</td></tr>
<tr><td>ks</td><td>String to make the function keys transmit.</td></tr>
<tr><td>kS</td><td>String of input sent by the “clear to end of screen” key.</td></tr>
<tr><td>kt</td><td>String of input sent by the “clear tab stop this column” key.</td></tr>
<tr><td>kT</td><td>String of input sent by the “set tab stop in this column” key.</td></tr>
<tr><td>ku</td><td>String of input sent by typing the up-arrow key.</td></tr>
<tr><td>l0</td><td>String on keyboard labelling function key 0 or 10.</td></tr>
<tr><td>l1 ... l9</td><td>Strings on keyboard labelling function keys 1 through 9.</td></tr>
<tr><td>le</td><td>String to move the cursor left one column.</td></tr>
<tr><td>LE</td><td>String to move cursor left <var>n</var> columns.</td></tr>
<tr><td>li</td><td>Number: height of the screen.</td></tr>
<tr><td>ll</td><td>String to position cursor at lower left corner.</td></tr>
<tr><td>lm</td><td>Number: lines of display memory.</td></tr>
<tr><td>LP</td><td>Flag: writing to last column of last line will not scroll.</td></tr>
<tr><td>mb</td><td>String to enter blinking mode.</td></tr>
<tr><td>md</td><td>String to enter double-bright mode.</td></tr>
<tr><td>me</td><td>String to turn off all appearance modes</td></tr>
<tr><td>mh</td><td>String to enter half-bright mode.</td></tr>
<tr><td>mi</td><td>Flag: cursor motion in insert mode is safe.</td></tr>
<tr><td>mk</td><td>String to enter invisible mode.</td></tr>
<tr><td>mm</td><td>String to enable the functioning of the Meta key.</td></tr>
<tr><td>mo</td><td>String to disable the functioning of the Meta key.</td></tr>
<tr><td>mp</td><td>String to enter protected mode.</td></tr>
<tr><td>mr</td><td>String to enter reverse-video mode.</td></tr>
<tr><td>ms</td><td>Flag: cursor motion in standout mode is safe.</td></tr>
<tr><td>nc</td><td>Obsolete flag: do not use ASCII carriage-return on this terminal.</td></tr>
<tr><td>nd</td><td>String to move the cursor right one column.</td></tr>
<tr><td>NF</td><td>Flag: do not use XON/XOFF flow control.</td></tr>
<tr><td>nl</td><td>Obsolete alternative name for the doand sfcapabilities.</td></tr>
<tr><td>ns</td><td>Flag: the terminal does not normally scroll for sequential output.</td></tr>
<tr><td>nw</td><td>String to move to start of next line, possibly clearing rest of old line.</td></tr>
<tr><td>os</td><td>Flag: terminal can overstrike.</td></tr>
<tr><td>pb</td><td>Number: the lowest baud rate at which padding is actually needed.</td></tr>
<tr><td>pc</td><td>String containing character for padding.</td></tr>
<tr><td>pf</td><td>String to terminate redirection of output to the printer.</td></tr>
<tr><td>po</td><td>String to redirect further output to the printer.</td></tr>
<tr><td>pO</td><td>String to redirect <var>n</var> characters ofoutput to the printer.</td></tr>
<tr><td>ps</td><td>String to print the screen on the attached printer.</td></tr>
<tr><td>rc</td><td>String to move to last saved cursor position.</td></tr>
<tr><td>RI</td><td>String to move cursor right <var>n</var> columns.</td></tr>
<tr><td>rp</td><td>String to output character <var>c</var> repeated <var>n</var> times.</td></tr>
<tr><td>rs</td><td>String to reset the terminal from any strange modes.</td></tr>
<tr><td>sa</td><td>String to turn on an arbitrary combination of appearance modes.</td></tr>
<tr><td>sc</td><td>String to save the current cursor position.</td></tr>
<tr><td>se</td><td>String to leave standout mode.</td></tr>
<tr><td>sf</td><td>String to scroll the screen one line up.</td></tr>
<tr><td>SF</td><td>String to scroll the screen <var>n</var> lines up.</td></tr>
<tr><td>sg</td><td>Number: width of magic standout cookie.  Absent if magic cookies are not used.</td></tr>
<tr><td>so</td><td>String to enter standout mode.</td></tr>
<tr><td>sr</td><td>String to scroll the screen one line down.</td></tr>
<tr><td>SR</td><td>String to scroll the screen <var>n</var> line down.</td></tr>
<tr><td>st</td><td>String to set tab stop at current cursor column on all lines. programs.</td></tr>
<tr><td>ta</td><td>String to move the cursor right to the next hardware tab stop column.</td></tr>
<tr><td>te</td><td>String to return terminal to settings for sequential output.</td></tr>
<tr><td>ti</td><td>String to initialize terminal for random cursor motion.</td></tr>
<tr><td>ts</td><td>String to move the terminal cursor into the status line.</td></tr>
<tr><td>uc</td><td>String to underline one character and move cursor right.</td></tr>
<tr><td>ue</td><td>String to turn off underline mode</td></tr>
<tr><td>ug</td><td>Number: width of underlining magic cookie.  Absent if underlining doesn't use magic cookies.</td></tr>
<tr><td>ul</td><td>Flag: underline by overstriking with an underscore.</td></tr>
<tr><td>up</td><td>String to move the cursor vertically up one line.</td></tr>
<tr><td>UP</td><td>String to move cursor vertically up <var>n</var> lines.</td></tr>
<tr><td>us</td><td>String to turn on underline mode</td></tr>
<tr><td>vb</td><td>String to make the screen flash.</td></tr>
<tr><td>ve</td><td>String to return the cursor to normal.</td></tr>
<tr><td>vi</td><td>String to make the cursor invisible.</td></tr>
<tr><td>vs</td><td>String to enhance the cursor.</td></tr>
<tr><td>wi</td><td>String to set the terminal output screen window.</td></tr>
<tr><td>ws</td><td>Number: the width of the status line.</td></tr>
<tr><td>xb</td><td>Flag: superbee terminal.</td></tr>
<tr><td>xn</td><td>Flag: cursor wraps in a strange way.</td></tr>
<tr><td>xs</td><td>Flag: clearing a line is the only way to clear the appearance modes of positions in that line (or, only way to remove magic cookies on that line).</td></tr>
<tr><td>xt</td><td>Flag: Teleray 1061; several strange characteristics.</td></tr>
</tbody></table>

<h2>Variable and Function Index</h2>
<ul>
<li><code>BC</code>: tgoto</li>
<li><code>ospeed</code>: Output Padding</li>
<li><code>PC</code>: Output Padding</li>
<li><code>tgetent</code>: Find</li>
<li><code>tgetflag</code>: Interrogate</li>
<li><code>tgetnum</code>: Interrogate</li>
<li><code>tgetstr</code>: Interrogate</li>
<li><code>tgoto</code>: tgoto</li>
<li><code>tparam</code>: tparam</li>
<li><code>tputs</code>: Output Padding</li>
<li><code>UP</code>: tgoto</li>
</ul>

<hr class="HR" />

<ul>
<li><code>ae</code>: Standout</li>
<li><code>AL</code>: Insdel Line</li>
<li><code>al</code>: Insdel Line</li>
<li><code>am</code>: Wrapping</li>
<li><code>as</code>: Standout</li>
<li><code>bc</code>: Cursor Motion</li>
<li><code>bl</code>: Bell</li>
<li><code>bs</code>: Cursor Motion</li>
<li><code>bt</code>: Cursor Motion</li>
<li><code>bw</code>: Cursor Motion</li>
<li><code>CC</code>: Basic</li>
<li><code>cd</code>: Clearing</li>
<li><code>ce</code>: Clearing</li>
<li><code>ch</code>: Cursor Motion</li>
<li><code>cl</code>: Clearing</li>
<li><code>CM</code>: Cursor Motion</li>
<li><code>cm</code>: Cursor Motion</li>
<li><code>co</code>: Screen Size</li>
<li><code>cr</code>: Cursor Motion</li>
<li><code>cS</code>: Scrolling</li>
<li><code>cs</code>: Scrolling</li>
<li><code>ct</code>: Initialization</li>
<li><code>cv</code>: Cursor Motion</li>
<li><code>da</code>: Scrolling</li>
<li><code>dB</code>: Pad Specs</li>
<li><code>db</code>: Scrolling</li>
<li><code>dC</code>: Pad Specs</li>
<li><code>DC</code>: Insdel Char</li>
<li><code>dc</code>: Insdel Char</li>
<li><code>dF</code>: Pad Specs</li>
<li><code>DL</code>: Insdel Line</li>
<li><code>dl</code>: Insdel Line</li>
<li><code>dm</code>: Insdel Char</li>
<li><code>dN</code>: Pad Specs</li>
<li><code>DO</code>: Cursor Motion</li>
<li><code>do</code>: Cursor Motion</li>
<li><code>ds</code>: Status Line</li>
<li><code>dT</code>: Pad Specs</li>
<li><code>ec</code>: Clearing</li>
<li><code>ed</code>: Insdel Char</li>
<li><code>ei</code>: Insdel Char</li>
<li><code>eo</code>: Basic</li>
<li><code>es</code>: Status Line</li>
<li><code>ff</code>: Cursor Motion</li>
<li><code>fs</code>: Status Line</li>
<li><code>gn</code>: Basic</li>
<li><code>hc</code>: Basic</li>
<li><code>hd</code>: Half-Line</li>
<li><code>ho</code>: Cursor Motion</li>
<li><code>hs</code>: Status Line</li>
<li><code>hu</code>: Half-Line</li>
<li><code>hz</code>: Basic</li>
<li><code>i1</code>: Initialization</li>
<li><code>i3</code>: Initialization</li>
<li><code>IC</code>: Insdel Char</li>
<li><code>ic</code>: Insdel Char</li>
<li><code>if</code>: Initialization</li>
<li><code>im</code>: Insdel Char</li>
<li><code>in</code>: Insdel Char</li>
<li><code>ip</code>: Insdel Char</li>
<li><code>is</code>: Initialization</li>
<li><code>it</code>: Initialization</li>
<li><code>K1...K5</code>: Keypad</li>
<li><code>k1...k9</code>: Keypad</li>
<li><code>kA...kT</code>: Keypad</li>
<li><code>ka...ku</code>: Keypad</li>
<li><code>km</code>: Meta Key</li>
<li><code>l0...l9</code>: Keypad</li>
<li><code>LE</code>: Cursor Motion</li>
<li><code>le</code>: Cursor Motion</li>
<li><code>li</code>: Screen Size</li>
<li><code>ll</code>: Cursor Motion</li>
<li><code>lm</code>: Scrolling</li>
<li><code>LP</code>: Wrapping</li>
<li><code>mb</code>: Standout</li>
<li><code>md</code>: Standout</li>
<li><code>me</code>: Standout</li>
<li><code>mh</code>: Standout</li>
<li><code>mi</code>: Insdel Char</li>
<li><code>mk</code>: Standout</li>
<li><code>mm</code>: Meta Key</li>
<li><code>mo</code>: Meta Key</li>
<li><code>mp</code>: Standout</li>
<li><code>mr</code>: Standout</li>
<li><code>ms</code>: Underlining</li>
<li><code>ms</code>: Standout</li>
<li><code>nc</code>: Cursor Motion</li>
<li><code>nd</code>: Cursor Motion</li>
<li><code>NF</code>: Initialization</li>
<li><code>nl</code>: Cursor Motion</li>
<li><code>ns</code>: Scrolling</li>
<li><code>nw</code>: Cursor Motion</li>
<li><code>os</code>: Basic</li>
<li><code>pb</code>: Pad Specs</li>
<li><code>pc</code>: Pad Specs</li>
<li><code>pf</code>: Printer</li>
<li><code>pO</code>: Printer</li>
<li><code>po</code>: Printer</li>
<li><code>ps</code>: Printer</li>
<li><code>rc</code>: Cursor Motion</li>
<li><code>RI</code>: Cursor Motion</li>
<li><code>rp</code>: Basic</li>
<li><code>rs</code>: Initialization</li>
<li><code>sa</code>: Standout</li>
<li><code>sc</code>: Cursor Motion</li>
<li><code>se</code>: Standout</li>
<li><code>SF</code>: Scrolling</li>
<li><code>sf</code>: Scrolling</li>
<li><code>sg</code>: Standout</li>
<li><code>so</code>: Standout</li>
<li><code>SR</code>: Scrolling</li>
<li><code>sr</code>: Scrolling</li>
<li><code>st</code>: Initialization</li>
<li><code>ta</code>: Cursor Motion</li>
<li><code>te</code>: Initialization</li>
<li><code>ti</code>: Initialization</li>
<li><code>ts</code>: Status Line</li>
<li><code>uc</code>: Underlining</li>
<li><code>ue</code>: Underlining</li>
<li><code>ug</code>: Underlining</li>
<li><code>ul</code>: Underlining</li>
<li><code>UP</code>: Cursor Motion</li>
<li><code>up</code>: Cursor Motion</li>
<li><code>us</code>: Underlining</li>
<li><code>vb</code>: Bell</li>
<li><code>ve</code>: Cursor Visibility</li>
<li><code>vi</code>: Cursor Visibility</li>
<li><code>vs</code>: Cursor Visibility</li>
<li><code>wi</code>: Windows</li>
<li><code>ws</code>: Status Line</li>
<li><code>xb</code>: Basic</li>
<li><code>xn</code>: Wrapping</li>
<li><code>xs</code>: Standout</li>
<li><code>xt</code>: Standout</li>
<li><code>xt</code>: Cursor Motion</li>
</ul>





<hr class="HR" />

<ul>
<li>Basic:        Basic characteristics.</li>
<li>Screen Size:   Screen size, and what happens when it changes.</li>
<li>Cursor Motion:   Various ways to move the cursor.</li>
<li>Wrapping:     What happens if you write a character in the last column.</li>
<li>Scrolling:    Pushing text up and down on the screen.</li>
<li>Windows:      Limiting the part of the window that output affects.</li>
<li>Clearing:     Erasing one or many lines.</li>
<li>Insdel Line:   Making new blank lines in mid-screen; deleting lines.</li>
<li>Insdel Char:   Inserting and deleting characters within a line.</li>
<li>Standout:     Highlighting some of the text.</li>
<li>Underlining:   Underlining some of the text.</li>
<li>Cursor Visibility:   Making the cursor more or less easy to spot.</li>
<li>Bell:         Attracts user's attention; not localized on the screen.</li>
<li>Keypad:  Recognizing when function keys or arrows are typed.</li>
<li>Meta Key:     META acts like an extra shift key.</li>
<li>Initialization:   Commands used to initialize or reset the terminal.</li>
<li>Pad Specs:    Info for the kernel on how much padding is needed.</li>
<li>Status Line:   A status line displays <code>background</code> information.</li>
<li>Half-Line:    Moving by half-lines, for superscripts and subscripts.</li>
<li>Printer:      Controlling auxiliary printers of display terminals.</li>
</ul>
<hr class="HR" />





<h2>Translated Term Capabilities</h2>
<pre></pre>
<p>This is helpful so you can understand what a term cap does, by looking at the long name.</p>
<table class="bordered"><tbody><tr class="header"><th>Tput Name</th><th>Terminfo Long Name</th></tr>
<tr><td>@7</td><td>key_end</td></tr><tr><td>AB</td><td>set_a_background</td></tr><tr><td>AF</td><td>set_a_foreground</td></tr><tr><td>AL</td><td>parm_insert_line</td></tr><tr><td>AX</td><td>AX</td></tr><tr><td>Co</td><td>max_colors</td></tr><tr><td>DC</td><td>parm_dch</td></tr><tr><td>DL</td><td>parm_delete_line</td></tr><tr><td>DO</td><td>parm_down_cursor</td></tr><tr><td>E0</td><td>E0</td></tr><tr><td>F1</td><td>key_f11</td></tr><tr><td>F2</td><td>key_f12</td></tr><tr><td>G0</td><td>G0</td></tr><tr><td>HC</td><td>5i</td></tr><tr><td>IC</td><td>parm_ich</td></tr><tr><td>Ic</td><td>initialize_color</td></tr><tr><td>Km</td><td>delete_line</td></tr><tr><td>LE</td><td>parm_left_cursor</td></tr><tr><td>NC</td><td>no_color_video</td></tr><tr><td>ND</td><td>MT</td></tr><tr><td>NP</td><td>NL</td></tr><tr><td>RI</td><td>parm_right_cursor</td></tr><tr><td>S0</td><td>S0</td></tr><tr><td>UP</td><td>parm_up_cursor</td></tr><tr><td>YA</td><td>NR</td></tr><tr><td>YC</td><td>YB</td></tr><tr><td>YE</td><td>YD</td></tr><tr><td>YG</td><td>YF</td></tr><tr><td>ac</td><td>acs_chars</td></tr><tr><td>ae</td><td>exit_alt_charset_mode</td></tr><tr><td>al</td><td>insert_line</td></tr><tr><td>am</td><td>auto_right_margin</td></tr><tr><td>as</td><td>enter_alt_charset_mode</td></tr><tr><td>back_color_erase</td><td>backspaces_with_bs</td></tr><tr><td>bl</td><td>bell</td></tr><tr><td>bs</td><td>eat_newline_glitch</td></tr><tr><td>bt</td><td>back_tab</td></tr><tr><td>bw</td><td>auto_left_margin</td></tr><tr><td>cb</td><td>clr_bol</td></tr><tr><td>cc</td><td>can_change</td></tr><tr><td>cd</td><td>clr_eos</td></tr><tr><td>ce</td><td>clr_eol</td></tr><tr><td>cl</td><td>clear_screen</td></tr><tr><td>cm</td><td>cursor_address</td></tr><tr><td>co</td><td>columns</td></tr><tr><td>col_addr_glitch</td><td>ceol_standout_glitch</td></tr><tr><td>cpi_changes_res</td><td>cr_cancels_micro_mode</td></tr><tr><td>cr</td><td>carriage_return</td></tr><tr><td>cs</td><td>change_scroll_region</td></tr><tr><td>ct</td><td>clear_all_tabs</td></tr><tr><td>cursor_up</td><td>scroll_reverse</td></tr><tr><td>da</td><td>crt_no_scrolling</td></tr><tr><td>db</td><td>dest_tabs_magic_smso</td></tr><tr><td>dc</td><td>delete_character</td></tr><tr><td>dl</td><td>key_mouse</td></tr><tr><td>do</td><td>cursor_down</td></tr><tr><td>eA</td><td>ena_acs</td></tr><tr><td>ei</td><td>exit_insert_mode</td></tr><tr><td>eo</td><td>erase_overstrike</td></tr><tr><td>es</td><td>generic_type</td></tr><tr><td>gn</td><td>gnu_has_meta_key</td></tr><tr><td>hard_copy</td><td>hard_cursor</td></tr><tr><td>has_meta_key</td><td>has_hardware_tabs</td></tr><tr><td>has_status_line</td><td>has_print_wheel</td></tr><tr><td>hl</td><td>hc</td></tr><tr><td>ho</td><td>cursor_home</td></tr><tr><td>hs</td><td>hue_lightness_saturation</td></tr><tr><td>im</td><td>enter_insert_mode</td></tr><tr><td>in</td><td>hz</td></tr><tr><td>insert_null_glitch</td><td>linefeed_is_newline</td></tr><tr><td>is</td><td>init_2string</td></tr><tr><td>it</td><td>init_tabs</td></tr><tr><td>k1</td><td>key_f1</td></tr><tr><td>k2</td><td>key_f2</td></tr><tr><td>k3</td><td>key_f3</td></tr><tr><td>k4</td><td>key_f4</td></tr><tr><td>k5</td><td>key_f5</td></tr><tr><td>k6</td><td>key_f6</td></tr><tr><td>k7</td><td>key_f7</td></tr><tr><td>k8</td><td>key_f8</td></tr><tr><td>k9</td><td>key_f9</td></tr><tr><td>k;</td><td>key_f10</td></tr><tr><td>kB</td><td>key_btab</td></tr><tr><td>kD</td><td>key_dc</td></tr><tr><td>kI</td><td>key_ic</td></tr><tr><td>kN</td><td>key_npage</td></tr><tr><td>kP</td><td>key_ppage</td></tr><tr><td>kb</td><td>cursor_left</td></tr><tr><td>kd</td><td>key_down</td></tr><tr><td>ke</td><td>keypad_local</td></tr><tr><td>kh</td><td>key_home</td></tr><tr><td>kl</td><td>key_left</td></tr><tr><td>kr</td><td>key_right</td></tr><tr><td>ks</td><td>keypad_xmit</td></tr><tr><td>ku</td><td>key_up</td></tr><tr><td>le</td><td>key_backspace</td></tr><tr><td>li</td><td>lines</td></tr><tr><td>mb</td><td>enter_blink_mode</td></tr><tr><td>md</td><td>enter_bold_mode</td></tr><tr><td>me</td><td>exit_attribute_mode</td></tr><tr><td>memory_above</td><td>lpi_changes_res</td></tr><tr><td>mi</td><td>km</td></tr><tr><td>move_insert_mode</td><td>move_standout_mode</td></tr><tr><td>mr</td><td>enter_reverse_mode</td></tr><tr><td>nc</td><td>memory_below</td></tr><tr><td>nd</td><td>cursor_right</td></tr><tr><td>needs_xon_xoff</td><td>no_correctly_working_cr</td></tr><tr><td>no_pad_char</td><td>no_esc_ctlc</td></tr><tr><td>non_rev_rmcup</td><td>non_dest_scroll_region</td></tr><tr><td>nw</td><td>newline</td></tr><tr><td>nx</td><td>ns</td></tr><tr><td>op</td><td>orig_pair</td></tr><tr><td>os</td><td>over_strike</td></tr><tr><td>pa</td><td>max_pairs</td></tr><tr><td>prtr_silent</td><td>return_does_clr_eol</td></tr><tr><td>pt</td><td>ms</td></tr><tr><td>r2</td><td>reset_2string</td></tr><tr><td>rc</td><td>restore_cursor</td></tr><tr><td>row_addr_glitch</td><td>semi_auto_right_margin</td></tr><tr><td>sa</td><td>set_attributes</td></tr><tr><td>sc</td><td>save_cursor</td></tr><tr><td>se</td><td>exit_standout_mode</td></tr><tr><td>sf</td><td>scroll_forward</td></tr><tr><td>so</td><td>enter_standout_mode</td></tr><tr><td>st</td><td>set_tab</td></tr><tr><td>ta</td><td>tab</td></tr><tr><td>te</td><td>exit_ca_mode</td></tr><tr><td>ti</td><td>enter_ca_mode</td></tr><tr><td>tilde_glitch</td><td>status_line_esc_ok</td></tr><tr><td>ue</td><td>exit_underline_mode</td></tr><tr><td>ul</td><td>transparent_underline</td></tr><tr><td>up</td><td>sr</td></tr><tr><td>us</td><td>enter_underline_mode</td></tr><tr><td>vb</td><td>flash_screen</td></tr><tr><td>ve</td><td>cursor_normal</td></tr><tr><td>vi</td><td>cursor_invisible</td></tr><tr><td>vs</td><td>cursor_visible</td></tr><tr><td>xn</td><td>ut</td></tr><tr><td>xo</td><td>xb</td></tr><tr><td>xr</td><td>xon_xoff</td></tr><tr><td>xt</td><td>xs</td></tr></tbody></table>


<h2>List of All Terminals</h2>
<p>You can view this list with the following command:</p>
<pre>$ toe -a|sort -d</pre>





<h2><a href="http://vt100.net/docs/vt100-ug/chapter3.html#S3.3.2">VT100 keypad Diagram</a></h2>
<p><a href="http://vt100.net/docs/vt100-ug/chapter3.html#S3.3.2">VT100 LINK</a></p>
<p>Here's a diagram of the VT100 keypad keys with their bindings.  The top line is the name of the key (some DEC keyboards have the keys labelled somewhat differently, like GOLD instead of PF1, but this is the most "official" name).  The second line is the escape sequence it generates in Application Keypad mode (where "$" means the ESC character).  The third line contains two items, first the mapping of the key in terminfo, and then in termcap.</p>
<pre>   _______________________________________
  |   PF1   |   PF2   |   PF3   |   PF4   |
  |   $OP   |   $OQ   |   $OR   |   $OS   |
  |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_|
  |    7         8         9         -    |
  |   $Ow   |   $Ox   |   $Oy   |   $Om   |
  |_kf9__k9_|_kf10_k;_|_kf0__k0_|_________|
  |    4    |    5    |    6    |    ,    |
  |   $Ot   |   $Ou   |   $Ov   |   $Ol   |
  |_kf5__k5_|_kf6__k6_|_kf7__k7_|_kf8__k8_|
  |    1    |    2    |    3    |         |
  |   $Oq   |   $Or   |   $Os   |  enter  |
  |_ka1__K1_|_kb2__K2_|_ka3__K3_|  $OM    |
  |         0         |   .     |         |
  |        $Op        |  $On    |         |
  |___kc1_______K4____|_kc3__K5_|_kent_@8_|</pre>

<p>A better adaptation to modern keyboards such as the PC's, which have a dozen function keys and the keypad 2,4,6,8 keys are labeled with arrows keys, is to use the 5-key arrangement to model the arrow keys as suggested in the terminfo guidelines:</p>
<pre>   _______________________________________
  |   PF1   |   PF2   |   PF3   |   PF4   |
  |   $OP   |   $OQ   |   $OR   |   $OS   |
  |_kf1__k1_|_kf2__k2_|_kf3__k3_|_kf4__k4_|
  |    7         8         9         -    |
  |   $Ow   |   $Ox   |   $Oy   |   $Om   |
  |_ka1__K1_|_________|_ka3__K3_|_________|
  |    4    |    5    |    6    |    ,    |
  |   $Ot   |   $Ou   |   $Ov   |   $Ol   |
  |_________|_kb2__K2_|_________|_________|
  |    1    |    2    |    3    |         |
  |   $Oq   |   $Or   |   $Os   |  enter  |
  |_kc1__K4_|_________|_kc3__K5_|  $OM    |
  |         0         |   .     |         |
  |        $Op        |  $On    |         |
  |___________________|_________|_kent_@8_|</pre>





<h2>SGR parameter values</h2>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>0</var></td><td>default mode (attributes off)</td></tr>
<tr><td><var>1</var></td><td>bold</td></tr>
<tr><td><var>2</var></td><td>dim</td></tr>
<tr><td><var>3</var></td><td>italicized</td></tr>
<tr><td><var>4</var></td><td>underlined</td></tr>
<tr><td><var>5</var></td><td>slow blink</td></tr>
<tr><td><var>6</var></td><td>fast blink</td></tr>
<tr><td><var>7</var></td><td>reverse video</td></tr>
<tr><td><var>8</var></td><td>invisible</td></tr>
<tr><td><var>9</var></td><td>crossed-out (marked for deletion)</td></tr>
<tr><td><var>10</var></td><td>primary font [10 + n (n in 1..9) = nth alternative font]</td></tr>
<tr><td><var>20</var></td><td>Fraktur</td></tr>
<tr><td><var>21</var></td><td>double underline</td></tr>
<tr><td><var>22</var></td><td>turn off 2</td></tr>
<tr><td><var>23</var></td><td>turn off 3</td></tr>
<tr><td><var>24</var></td><td>turn off 4</td></tr>
<tr><td><var>25</var></td><td>turn off 5</td></tr>
<tr><td><var>26</var></td><td>proportional spacing</td></tr>
<tr><td><var>27</var></td><td>turn off 7</td></tr>
<tr><td><var>28</var></td><td>turn off 8</td></tr>
<tr><td><var>29</var></td><td>turn off 9</td></tr>
<tr><td><var>30</var></td><td>black fg</td></tr>
<tr><td><var>31</var></td><td>red fg</td></tr>
<tr><td><var>32</var></td><td>green fg</td></tr>
<tr><td><var>33</var></td><td>yellow fg</td></tr>
<tr><td><var>34</var></td><td>blue fg</td></tr>
<tr><td><var>35</var></td><td>magenta fg</td></tr>
<tr><td><var>36</var></td><td>cyan fg</td></tr>
<tr><td><var>37</var></td><td>white fg</td></tr>
<tr><td><var>38</var></td><td>set fg color as in CCIT T.416</td></tr>
<tr><td><var>39</var></td><td>set default fg color</td></tr>
<tr><td><var>40</var></td><td>black bg</td></tr>
<tr><td><var>41</var></td><td>red bg</td></tr>
<tr><td><var>42</var></td><td>green bg</td></tr>
<tr><td><var>43</var></td><td>yellow bg</td></tr>
<tr><td><var>44</var></td><td>blue bg</td></tr>
<tr><td><var>45</var></td><td>magenta bg</td></tr>
<tr><td><var>46</var></td><td>cyan bg</td></tr>
<tr><td><var>47</var></td><td>white bg</td></tr>
<tr><td><var>48</var></td><td>set bg color as in CCIT T.416</td></tr>
<tr><td><var>39</var></td><td>set default bg color</td></tr>
<tr><td><var>50</var></td><td>turn off 26</td></tr>
<tr><td><var>51</var></td><td>framed</td></tr>
<tr><td><var>52</var></td><td>encircled</td></tr>
<tr><td><var>53</var></td><td>overlined</td></tr>
<tr><td><var>54</var></td><td>turn off 51 &amp; 52</td></tr>
<tr><td><var>55</var></td><td>not overlined</td></tr>
<tr><td><var>56-59</var></td><td>reserved</td></tr>
<tr><td><var>61-65</var></td><td>variable highlights for ideograms.</td></tr>
</tbody></table>






<pre>Sequence     Sequence                             Parameter   or
Mnemonic     Name              Sequence           Value      Mode   terminfo
-----------------------------------------------------------------------------
APC  Applicatn Program Command \E _                -         Delim  -
BEL  Bell *                    ^G                  -         -      bel
BPH  Break Permitted Here *    \E B                -         *      -
BS   Backpace *                ^H                  -         EF     -
CAN  Cancel *                  ^X                  -         -      -   (A)
CBT  Cursor Backward Tab       \E [ Pn Z           1         eF     cbt
CCH  Cancel Previous Character \E T                -         -      -
CHA  Cursor Horizntal Absolute \E [ Pn G           1         eF     hpa (B)
CHT  Cursor Horizontal Tab     \E [ Pn I           1         eF     tab (C)
CMD  Coding Method Delimiter * \E
CNL  Cursor Next Line          \E [ Pn E           1         eF     nel (D)
CPL  Cursor Preceding Line     \E [ Pn F           1         eF     -
CPR  Cursor Position Report    \E [ Pn ; Pn R      1, 1      -      -   (E)
CSI  Control Sequence Intro    \E [                -         Intro  -
CTC  Cursor Tabulation Control \E [ Ps W           0         eF     -   (F)
CUB  Cursor Backward           \E [ Pn D           1         eF     cub
CUD  Cursor Down               \E [ Pn B           1         eF     cud
CUF  Cursor Forward            \E [ Pn C           1         eF     cuf
CUP  Cursor Position           \E [ Pn ; Pn H      1, 1      eF     cup (G)
CUU  Cursor Up                 \E [ Pn A           1         eF     cuu
CVT  Cursor Vertical Tab       \E [ Pn Y           -         eF     -   (H)
DA   Device Attributes         \E [ Pn c           0         -      -
DAQ  Define Area Qualification \E [ Ps o           0         -      -
DCH  Delete Character          \E [ Pn P           1         eF     dch
DCS  Device Control String     \E P                -         Delim  -
DL   Delete Line               \E [ Pn M           1         eF     dl
DLE  Data Link Escape *        ^P                  -         -      -
DMI  Disable Manual Input      \E \                -         Fs     -
DSR  Device Status Report      \E [ Ps n           0         -      -   (I)
DTA  Dimension Text Area *     \E [ Pn ; Pn SPC T  -         PC     -
EA   Erase in Area             \E [ Ps O           0         eF     -   (J)
ECH  Erase Character           \E [ Pn X           1         eF     ech
ED   Erase in Display          \E [ Ps J           0         eF     ed  (J)
EF   Erase in Field            \E [ Ps N           0         eF     -
EL   Erase in Line             \E [ Ps K           0         eF     el  (J)
EM   End of Medium *           ^Y                  -         -      -
EMI  Enable Manual Input       \E b                          Fs     -
ENQ  Enquire                   ^E                  -         -      -
EOT  End Of Transmission       ^D                  -         *      -
EPA  End of Protected Area     \E W                -         -      -   (K)
ESA  End of Selected Area      \E G                -         -      -
ESC  Escape                    ^[                  -         -      -
ETB  End Transmission Block    ^W                  -         -      -
ETX  End of Text               ^C                  -         -      -
FF   Form Feed                 ^L                  -         -      -
FNK  Function Key *            \E [ Pn SPC W       -         -      -
GCC  Graphic Char Combination* \E [ Pn ; Pn SPC B  -         -      -
FNT  Font Selection            \E [ Pn ; Pn SPC D  0, 0      FE     -
GSM  Graphic Size Modify       \E [ Pn ; Pn SPC B  100, 100  FE     -   (L)
GSS  Graphic Size Selection    \E [ Pn SPC C       none      FE     -
HPA  Horz Position Absolute    \E [ Pn `           1         FE     -   (B)
HPB  Char Position Backward    \E [ j              1         FE     -
HPR  Horz Position Relative    \E [ Pn a           1         FE     -   (M)
HT   Horizontal Tab *          ^I                  -         FE     -   (N)
HTJ  Horz Tab w/Justification  \E I                -         FE     -
HTS  Horizontal Tab Set        \E H                -         FE     hts
HVP  Horz &amp;amp; Vertical Position  \E [ Pn ; Pn f      1, 1      FE     -   (G)
ICH  Insert Character          \E [ Pn @           1         eF     ich
IDCS ID Device Control String  \E [ SPC O          -         *      -
IGS  ID Graphic Subrepertoire  \E [ SPC M          -         *      -
IL   Insert Line               \E [ Pn L           1         eF     il
IND  Index                     \E D                -         FE     -
INT  Interrupt                 \E a                -         Fs     -
JFY  Justify                   \E [ Ps SPC F       0         FE     -
IS1  Info Separator #1 *       ^_                  -         *      -
IS2  Info Separator #1 *       ^^                  -         *      -
IS3  Info Separator #1 *       ^]                  -         *      -
IS4  Info Separator #1 *       ^\                  -         *      -
LF   Line Feed                 ^J                  -         -      -
LS1R Locking Shift Right 1 *   \E ~                -         -      -
LS2  Locking Shift 2 *         \E n                -         -      -
LS2R Locking Shift Right 2 *   \E }                -         -      -
LS3  Locking Shift 3 *         \E o                -         -      -
LS3R Locking Shift Right 3 *   \E |                -         -      -
MC   Media Copy                \E [ Ps i           0         -      -   (S)
MW   Message Waiting           \E U                -         -      -
NAK  Negative Acknowledge *    ^U                  -         *      -
NBH  No Break Here *           \E C                -         -      -
NEL  Next Line                 \E E                -         FE     nel (D)
NP   Next Page                 \E [ Pn U           1         eF     -
NUL  Null *                    ^@                  -         -      -
OSC  Operating System Command  \E ]                -         Delim  -
PEC  Pres. Expand/Contract *   \E Pn SPC Z         0         -      -
PFS  Page Format Selection *   \E Pn SPC J         0         -      -
PLD  Partial Line Down         \E K                -         FE     -   (T)
PLU  Partial Line Up           \E L                -         FE     -   (U)
PM   Privacy Message           \E ^                -         Delim  -
PP   Preceding Page            \E [ Pn V           1         eF     -
PPA  Page Position Absolute *  \E [ Pn SPC P       1         FE     -
PPB  Page Position Backward *  \E [ Pn SPC R       1         FE     -
PPR  Page Position Forward *   \E [ Pn SPC Q       1         FE     -
PTX  Parallel Texts *          \E [ \              -         -      -
PU1  Private Use 1             \E Q                -         -      -
PU2  Private Use 2             \E R                -         -      -
QUAD Typographic Quadding      \E [ Ps SPC H       0         FE     -
REP  Repeat Char or Control    \E [ Pn b           1         -      rep
RI   Reverse Index             \E M                -         FE     -   (V)
RIS  Reset to Initial State    \E c                -         Fs     -
RM   Reset Mode *              \E [ Ps l           -         -      -   (W)
SACS Set Add. Char. Sep. *     \E [ Pn SPC /       0         -      -
SAPV Sel. Alt. Present. Var. * \E [ Ps SPC ]       0         -      -   (X)
SCI  Single-Char Introducer    \E Z                -         -      -
SCO  Sel. Char. Orientation *  \E [ Pn ; Pn SPC k  -         -      -
SCS  Set Char. Spacing *       \E [ Pn SPC g       -         -      -
SD   Scroll Down               \E [ Pn T           1         eF     rin
SDS  Start Directed String *   \E [ Pn ]           1         -      -
SEE  Select Editing Extent     \E [ Ps Q           0         -      -   (Y)
SEF  Sheet Eject &amp;amp; Feed *  \E [ Ps ; Ps SPC Y  0,0       -      -
SGR  Select Graphic Rendition  \E [ Ps m           0         FE     sgr (O)
SHS  Select Char. Spacing *    \E [ Ps SPC K       0         -      -
SI   Shift In                  ^O                  -         -      -   (P)
SIMD Sel. Imp. Move Direct. *  \E [ Ps ^           -         -      -
SL   Scroll Left               \E [ Pn SPC @       1         eF     -
SLH  Set Line Home *           \E [ Pn SPC U       -         -      -
SLL  Set Line Limit *          \E [ Pn SPC V       -         -      -
SLS  Set Line Spacing *        \E [ Pn SPC h       -         -      -
SM   Select Mode               \E [ Ps h           none      -      -   (W)
SO   Shift Out                 ^N                  -         -      -   (Q)
SOH  Start Of Heading *        ^A                  -         -      -
SOS  Start of String *         \E X                -         -      -
SPA  Start of Protected Area   \E V                -         -      -   (Z)
SPD  Select Pres. Direction *  \E [ Ps ; Ps SPC S  0,0       -      -
SPH  Set Page Home *           \E [ Ps SPC G       -         -      -
SPI  Spacing Increment         \E [ Pn ; Pn SPC G  none      FE     -
SPL  Set Page Limit *          \E [ Ps SPC j       -         -      -
SPQR Set Pr. Qual. &amp;amp; Rapid. *  \E [ Ps SPC X       0         -      -
SR   Scroll Right              \E [ Pn SPC A       1         eF     -
SRCS Set Reduced Char. Sep. *  \E [ Pn SPC f       0         -      -
SRS  Start Reversed String *   \E [ Ps [           0         -      -
SSA  Start of Selected Area    \E F                -         -      -
SSU  Select Size Unit *        \E [ Pn SPC I       0         -      -
SSW  Set Space Width *         \E [ Pn SPC [       none      -      -
SS2  Single Shift 2 (G2 set)   \E N                -         Intro  -
SS3  Single Shift 3 (G3 set)   \E O                -         Intro  -
ST   String Terminator         \E \                -         Delim  -
STAB Selective Tabulation *    \E [ Pn SPC ^       -         -      -
STS  Set Transmit State        \E S                -         -      -
STX  Start pf Text *           ^B                  -         -      -
SU   Scroll Up                 \E [ Pn S           1         eF     indn
SUB  Substitute *              ^Z                  -         -      -
SVS  Select Line Spacing *     \E [ Pn SPC \       1         -      -
SYN  Synchronous Idle *        ^F                  -         -      -
TAC  Tabul. Aligned Centered * \E [ Pn SPC b       -         -      -
TALE Tabul. Al. Leading Edge * \E [ Pn SPC a       -         -      -
TATE Tabul. Al. Trailing Edge* \E [ Pn SPC `       -         -      -
TBC  Tab Clear                 \E [ Ps g           0         FE     tbc
TCC  Tabul. Centered on Char * \E [ Pn SPC c       -         -      -
TSR  Tabulation Stop Remove  * \E [ Pn SPC d       -         FE     -
TSS  Thin Space Specification  \E [ Pn SC E        none      FE     -
VPA  Vert. Position Absolute   \E [ Pn d           1         FE     vpa
VPB  Line Position Backward *  \E [ Pn k           1         FE     -
VPR  Vert. Position Relative   \E [ Pn e           1         FE     -   (R)
VPR  Vert. Position Relative   \E [ Pn e           1         FE     -   (R)
VT   Vertical Tabulation *     ^K                  -         FE     -
VTS  Vertical Tabulation Set   \E J                -         FE     -</pre>









<h3>Basic Characteristics</h3>
<p>This section documents the capabilities that describe the basic and nature of the terminal, and also those that are relevant to the output of graphic characters.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>os</td><td>Flag whose presence means that the terminal can overstrike.  This means that outputting a graphic character does not erase whatever was present in the same character position before.  The terminals that can overstrike include printing terminals, storage tubes (all obsolete nowadays), and many bit-map displays.</td></tr>
<tr><td>eo</td><td>Flag whose presence means that outputting a space erases a character position even if the terminal supports overstriking.  If this flag is not present and overstriking is supported, output of a space has no effect except to move the cursor.  (On terminals that do not support overstriking, you can always assume that outputting a space at a position erases whatever character was previously displayed there.)</td></tr>
<tr><td>gn</td><td>Flag whose presence means that this terminal type is a generic type which does not really describe any particular terminal.  Generic types are intended for use as the default type assigned when the user connects to the system, with the intention that the user should specify what type he really has.  One example of a generic type is the type <code>network</code>.  Since the generic type cannot say how to do anything interesting with the terminal, termcap-using programs will always find that the terminal is too weak to be supported if the user has failed to specify a real terminal type in place of the generic one.  The gnflag directs these programs to use a different error message: “You have not specified your real terminal type”, rather than “Your terminal is not powerful enough to be used”.</td></tr>
<tr><td>hc</td><td>Flag whose presence means this is a hardcopy terminal.</td></tr>
<tr><td>rp</td><td>String of commands to output a graphic character <var>c</var>, repeated <var>n</var> times.  The first parameter value is the ASCII code for the desired character, and the second parameter is the number of times to repeat the character.  Often this command requires padding proportional to the number of times the character is repeated.  This effect can be had by using parameter arithmetic with <code>&lt;samp&gt;%&lt;/samp&gt;</code>-sequences to compute the amount of padding, then generating the result as a number at the front of the string so that <code>tputs</code> will treat it as padding.</td></tr>
<tr><td>hz</td><td>Flag whose presence means that the ASCII character cannot be output on this terminal because it is used for display commands.  Programs handle this flag by checking all text to be output and replacing each ~with some other character(s).  If this is not done, the screen will be thoroughly garbled.  The old Hazeltine terminals that required such treatment are probably very rare today, so you might as well not bother to support this flag.</td></tr>
<tr><td>CC</td><td>String whose presence means the terminal has a settable command character.  The value of the string is the default command character (which is usually &lt;ESC&gt;).  All the strings of commands in the terminal description should be written to use the default command character.  If you are writing an application program that changes the command character, use the CCcapability to figure out how to translate all the display commands to work with the new command character.  Most programs have no reason to look at the CCcapability.</td></tr>
<tr><td>xb</td><td>Flag whose presence identifies Superbee terminals which are unable to transmit the characters &lt;ESC&gt; and <kbd>Control-C</kbd>.  Programs which support this flag are supposed to check the input for the code sequences sent by the &lt;F1&gt; and &lt;F2&gt; keys, and pretend that &lt;ESC&gt; or <kbd>Control-C</kbd> (respectively) had been read.  But this flag is obsolete, and not worth supporting.</td></tr>
</tbody></table>

<h2>7bit vs. 8bit</h2>
<p>These recommendations are optional.  IBCS2 allows the leading escape to # be either the 7-bit <code>\E[</code> or 8-bit <code>\0233</code> introducer, in accordance with # the ANSI X.364/ISO 6429/ECMA-48 standard.</p>
<blockquote><cite>1.6.1 Describing the Encoding</cite> <p>For example, the <code>cm</code> string for a standard ANSI terminal is written as <code>\E[%i%d;%dH</code>.  (<code>\E</code> stands for .)  <code>cm</code> by convention always requires two parameters, the vertical and horizontal goal positions, so this string specifies the encoding of two parameters.  Here <code>%i</code> increments the two values supplied, and each <code>%d</code> encodes one of the values in decimal.  If the cursor position values 20,58 are encoded with this string, the result is <code>\E[21;59H</code>.</p></blockquote>
<p>First, here are the <code>%</code>-sequences that generate output.  Except for <code>%%</code>, each of them encodes one parameter and advances the pointer to the following parameter.</p>
<ul>
<li><code>%%</code> Output a single <code>%</code>.  This is the only way to represent a literal <code>%</code> in a terminal command with parameters.  <code>%%</code> does not use up a parameter.</li>
<li><code>%d</code> As in <code>printf</code>, output the next parameter in decimal.</li>
<li><code>%2</code> Like <code>%02d</code> in <code>printf</code>: output the next parameter in decimal, and always use at least two digits.</li>
<li><code>%3</code> Like <code>%03d</code> in <code>printf</code>: output the next parameter in decimal, and always use at least three digits.  Note that <code>%4</code> and so on are _not_ defined.</li>
<li><code>%.</code> Output the next parameter as a single character whose ASCII code is the parameter value.  Like <code>%c</code> in <code>printf</code>.</li>
<li><code>%+CHAR</code> Add the next parameter to the character CHAR, and output the resulting character.  For example, <code>%+ </code> represents 0 as a space, 1 as <code>!</code>, etc.</li>
</ul>

<p>The following <code>%</code>-sequences specify alteration of the parameters (their values, or their order) rather than encoding a parameter for output.  They generate no output; they are used only for their side effects on the parameters.  Also, they do not advance the "next parameter" pointer except as explicitly stated.  Only <code>%i</code>, <code>%r</code> and <code>%&gt;</code> are defined in standard Unix termcap.  The others are GNU extensions.</p>
<ul>
<li><code>%i</code> Increment the next two parameters.  This is used for terminals that expect cursor positions in origin 1.  For example, <code>%i%d,%d</code> would output two parameters with <code>1</code> for 0, <code>2</code> for 1, etc.</li>
<li><code>%r</code> Interchange the next two parameters.  This is used for terminals whose cursor positioning command expects the horizontal position first.</li>
<li><code>%s</code> Skip the next parameter.  Do not output anything.</li>
<li><code>%b</code> Back up one parameter.  The last parameter used will become once again the next parameter to be output, and the next output command will use it.  Using <code>%b</code> more than once, you can back up any number of parameters, and you can refer to each parameter any number of times.</li>
<li><code>%&gt;C1C2</code> Conditionally increment the next parameter.  Here C1 and C2 are characters which stand for their ASCII codes as numbers.  If the next parameter is greater than the ASCII code of C1, the ASCII code of C2 is added to it.</li>
<li><code>%a OP TYPE POS</code> Perform arithmetic on the next parameter, do not use it up, and do not output anything.  Here OP specifies the arithmetic operation, while TYPE and POS together specify the other operand.</li>
</ul>


<p>Spaces are used above to separate the operands for clarity; the spaces don't appear in the data base, where this sequence is exactly five characters long.  The character OP says what kind of arithmetic operation to perform.  It can be any of these characters:</p>
<ul>
<li><var>=</var> - assign a value to the next parameter, ignoring its old value.   The new value comes from the other operand.</li>
<li><var>+</var> - add the other operand to the next parameter.</li>
<li><var>-</var> - subtract the other operand from the next parameter.</li>
<li><var>*</var> - multiply the next parameter by the other operand.</li>
<li><var>/</var> - divide the next parameter by the other operand.</li>
</ul>

<p>The "other operand" may be another parameter's value or a constant; the character TYPE says which.  It can be:</p>
<ul>
<li><var>p</var> - Use another parameter.  The character POS says which   parameter to use.  Subtract 64 from its ASCII code to get the   position of the desired parameter relative to this one.  Thus,   the character <code>A</code> as POS means the parameter after the next   one; the character <code>?</code> means the parameter before the next   one.</li>
<li><var>c</var> - Use a constant value.  The character POS specifies the value   of the constant.  The 0200 bit is cleared out, so that 0200   can be used to represent zero.</li>
</ul>

<p>The following <code>%</code>-sequences are special purpose hacks to compensate for the weird designs of obscure terminals.  They modify the next parameter or the next two parameters but do not generate output and do not use up any parameters.  <code>%m</code> is a GNU extension; the others are defined in standard Unix termcap.</p>
<ul>
<li><var>%n</var> - Exclusive-or the next parameter with 0140, and likewise the parameter after next.</li>
<li><var>%m</var> - Complement all the bits of the next parameter and the parameter after next.</li>
<li><var>%B</var> - Encode the next parameter in BCD.  It alters the value of the parameter by adding six times the quotient of the parameter by ten. Here is a C statement that shows how the new value is computed:  <code>PARM = (PARM / 10) * 16 + PARM % 10;</code></li>
<li><var>%D</var> - Transform the next parameter as needed by Delta Data terminals. This involves subtracting twice the remainder of the parameter by 16.  <code>PARM -= 2 * (PARM % 16);</code></li>
</ul>

<h2>Terminal Type Name Conventions</h2>
<p>Here is a list of standard suffixes and their conventional meanings:</p>
<ul>
<li><var>-w</var> - Short for "wide".  This is a mode that gives the terminal more columns than usual.  This is normally a user option.</li>
<li><var>-am</var> - "Automatic margins".  This is an alternate description for use when the terminal's margin-wrap switch is on; it contains the <code>am</code> flag.  The implication is that normally the switch is off and the usual description for the terminal says that the switch is off.</li>
<li><var>-nam</var> - "No automatic margins".  The opposite of <code>-am</code>, this names an alternative description which lacks the <code>am</code> flag.  This implies that the terminal is normally operated with the margin-wrap switch turned on, and the normal description of the terminal says so.</li>
<li><var>-na</var> - "No arrows".  This terminal description initializes the terminal to keep its arrow keys in local mode.  This is a user option.</li>
<li><var>-rv</var> - "Reverse video".  This terminal description causes text output for normal video to appear as reverse, and text output for reverse video to come out as normal.  Often this description differs from the usual one by interchanging the two strings which turn reverse video on and off.</li>
</ul>

<p>This is a user option; you can choose either the "reverse video" variant terminal type or the normal terminal type, and termcap will obey.</p>
<ul>
<li><var>-s</var> - "Status".  Says to enable use of a status line which ordinary output does not touch (*note Status Line::).</li>
</ul>

<p>Some terminals have a special line that is used only as a status line.  For these terminals, there is no need for an <code>-s</code> variant; the status line commands should be defined by default.  On other terminals, enabling a status line means removing one screen line from ordinary use and reducing the effective screen height.  For these terminals, the user can choose the <code>-s</code> variant type to request use of a status line.</p>
<ul>
<li><var>-NLINES</var> - Says to operate with NLINES lines on the screen, for terminals such as the Ambassador which provide this as an option.  Normally this is a user option; by choosing the terminal type, you control how many lines termcap will use.</li>
<li><var>-NPAGESp</var> - Says that the terminal has NPAGES pages worth of screen memory, for terminals where this is a hardware option.</li>
<li><var>-unk</var> - Says that description is not for direct use, but only for reference in <code>tc</code> capabilities.  Such a description is a kind of subroutine, because it describes the common characteristics of several variant descriptions that would use other suffixes in place of <code>-unk</code>.</li>
</ul>

<h2>MS-DOS ANSI.SYS</h2>
<p>Here is a description of the color and attribute controls supported in the ANSI.SYS driver under MS-DOS.  Most console drivers and ANSI terminal emulators for Intel boxes obey these.  They are a proper subset of the ECMA-48 escapes.</p>
<p>Bright black becomes gray, bright brown becomes yellow. These coincide with the prescriptions of the ISO 6429/ECMA-48 standard.  * If the 5 attribute is on and you set a background color (40-47) it is supposed to enable bright background.</p>
<pre>0        all attributes off
1        foreground bright
4        underscore on
5        blink on/background bright (not reliable with brown)
7        reverse-video
8        set blank (non-display)
10       set primary font
11       set first alternate font (on PCs, display ROM characters 1-31)
12       set second alternate font (on PCs, display IBM high-half chars)
3n       set foreground color       / 0=black, 1=red,     2=green, 3=brown,
4n       set background color       \ 4=blue,  5=magenta, 6=cyan,  7=white</pre>

<h2>STTY</h2>
<h3>Stty Control Settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>parenb</td><td><code>parenb</code> Generate parity bit in output and expect parity bit in input.  May be negated.</td></tr>
<tr><td>parodd</td><td>Set odd parity (even if negated).  May be negated.</td></tr>
<tr><td>cs5, cs6, cs7, cs8</td><td>Set character size to 5, 6, 7, or 8 bits.</td></tr>
<tr><td>hup, hupcl</td><td>Send a hangup signal when the last process closes the tty.  May be negated.</td></tr>
<tr><td>cstopb</td><td>Use two stop bits per character (one if negated).  May be negated.</td></tr>
<tr><td>cread</td><td>Allow input to be received.  May be negated.</td></tr>
<tr><td>clocal</td><td>Disable modem control signals.  May be negated.</td></tr>
<tr><td>crtscts</td><td>Enable RTS/CTS flow control. Disables DTR/DSR flow control. Non-POSIX.  May be negated.</td></tr>
<tr><td>cdtrdsr</td><td>Enable DTR/DSR flow control. Disables RTS/CTS flow control. Non-POSIX.  May be negated.  No stty-readable form available.  It needs to be supported by device.  Usage on device without DTR/DSR support could lead to an error and failure of <code>stty</code>.</td></tr>
</tbody></table><h3>Stty Input settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>ignbrk</td><td>Ignore break characters.  May be negated.</td></tr>
<tr><td>brkint</td><td>Make breaks cause an interrupt signal.  May be negated.</td></tr>
<tr><td>ignpar</td><td>Ignore characters with parity errors.  May be negated.</td></tr>
<tr><td>parmrk</td><td>Mark parity errors (with a 255-0-character sequence).  May be negated.</td></tr>
<tr><td>inpck</td><td>Enable input parity checking.  May be negated.</td></tr>
<tr><td>istrip</td><td>Clear high (8th) bit of input characters.  May be negated.</td></tr>
<tr><td>inlcr</td><td>Translate newline to carriage return.  May be negated.</td></tr>
<tr><td>igncr</td><td>Ignore carriage return.  May be negated.</td></tr>
<tr><td>icrnl</td><td>Translate carriage return to newline.  May be negated.</td></tr>
<tr><td>iutf8</td><td>Assume input characters are UTF-8 encoded.  May be negated.</td></tr>
<tr><td>ixon</td><td>Enable XON/XOFF flow control (that is, <code>CTRL-S</code>/<code>CTRL-Q</code>).  May be negated.</td></tr>
<tr><td>ixoff, tandem</td><td>Enable sending of <code>stop</code> character when the system input buffer is almost full, and <code>start</code> character when it becomes almost empty again.  May be negated.</td></tr>
<tr><td>iuclc</td><td>Translate uppercase characters to lowercase.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ixany</td><td>Allow any character to restart output (only the start character if negated).  Non-POSIX.  May be negated.</td></tr>
<tr><td>imaxbel</td><td>Enable beeping and not flushing input buffer if a character arrives when the input buffer is full.  Non-POSIX.  May be negated.</td></tr>
</tbody></table>
<h3>Stty Output settings</h3>
<p>These arguments specify output-related operations.</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>opost</td><td>Postprocess output.  May be negated.</td></tr>
<tr><td>olcuc</td><td>Translate lowercase characters to uppercase.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ocrnl</td><td>Translate carriage return to newline.  Non-POSIX.  May be negated.</td></tr>
<tr><td>onlcr</td><td>Translate newline to carriage return-newline.  Non-POSIX.  May be negated.</td></tr>
<tr><td>onocr</td><td>Do not print carriage returns in the first column.  Non-POSIX. May be negated.</td></tr>
<tr><td>onlret</td><td>Newline performs a carriage return.  Non-POSIX.  May be negated.</td></tr>
<tr><td>ofill</td><td>Use fill (padding) characters instead of timing for delays. Non-POSIX.  May be negated.</td></tr>
<tr><td>ofdel</td><td>Use delete characters for fill instead of null characters. Non-POSIX.  May be negated.</td></tr>
<tr><td>nl1, nl0</td><td>Newline delay style.  Non-POSIX.</td></tr>
<tr><td>cr3, cr2, cr1, cr0</td><td>Carriage return delay style.  Non-POSIX.</td></tr>
<tr><td>tab3, tab2, tab1, tab0</td><td>Horizontal tab delay style.  Non-POSIX.</td></tr>
<tr><td>bs1, bs0</td><td>Backspace delay style.  Non-POSIX.</td></tr>
<tr><td>vt1, vt0</td><td>Vertical tab delay style.  Non-POSIX.</td></tr>
<tr><td>ff1, ff0</td><td>Form feed delay style.  Non-POSIX.</td></tr>
</tbody></table>
<h3>Stty Local settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>isig</td><td>Enable <code>interrupt</code>, <code>quit</code>, and <code>suspend</code> special characters.  May be negated.</td></tr>
<tr><td>icanon</td><td>Enable <code>erase</code>, <code>kill</code>, <code>werase</code>, and <code>rprnt</code> special characters. May be negated.</td></tr>
<tr><td>iexten</td><td>Enable non-POSIX special characters.  May be negated.</td></tr>
<tr><td>echo</td><td>Echo input characters.  May be negated.</td></tr>
<tr><td>echoe, crterase</td><td>Echo <code>erase</code> characters as backspace-space-backspace.  May be negated.</td></tr>
<tr><td>echok</td><td>Echo a newline after a <code>kill</code> character.  May be negated.</td></tr>
<tr><td>echonl</td><td>Echo newline even if not echoing other characters.  May be negated.</td></tr>
<tr><td>noflsh</td><td>Disable flushing after <code>interrupt</code> and <code>quit</code> special characters. May be negated.</td></tr>
<tr><td>xcase</td><td>Enable input and output of uppercase characters by preceding their lowercase equivalents with <code>\</code>, when <code>icanon</code> is set.  Non-POSIX. May be negated.</td></tr>
<tr><td>tostop</td><td>Stop background jobs that try to write to the terminal.  Non-POSIX. May be negated.</td></tr>
<tr><td>echoprt, prterase</td><td>Echo erased characters backward, between <code>\</code> and <code>/</code>.  Non-POSIX. May be negated.</td></tr>
<tr><td>echoctl, ctlecho</td><td>Echo control characters in hat notation (<code>^C</code>) instead of literally.  Non-POSIX.  May be negated.</td></tr>
<tr><td>echoke, crtkill</td><td>Echo the <code>kill</code> special character by erasing each character on the line as indicated by the <code>echoprt</code> and <code>echoe</code> settings, instead of by the <code>echoctl</code> and <code>echok</code> settings.  Non-POSIX.  May be negated.</td></tr>
</tbody></table>
<h3>Stty Combination settings</h3>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td>evenp, parity</td><td>Same as <code>parenb -parodd cs7</code>.  May be negated.  If negated, same as <code>-parenb cs8</code>.</td></tr>
<tr><td>oddp</td><td>Same as <code>parenb parodd cs7</code>.  May be negated.  If negated, same as <code>-parenb cs8</code>.</td></tr>
<tr><td>nl</td><td>Same as <code>-icrnl -onlcr</code>.  May be negated.  If negated, same as <code>icrnl -inlcr -igncr onlcr -ocrnl -onlret</code>.</td></tr>
<tr><td>ek</td><td>Reset the <code>erase</code> and <code>kill</code> special characters to their default values.</td></tr>
<tr><td>sane</td><td>Sets all special characters to their default values and: <pre>cread -ignbrk brkint -inlcr -igncr icrnl -ixoff -iuclc -ixany imaxbel opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke</pre></td></tr>
<tr><td>cooked</td><td>Same as <code>brkint ignpar istrip icrnl ixon opost isig icanon</code>, plus sets the <code>eof</code> and <code>eol</code> characters to their default values if they are the same as the <code>min</code> and <code>time</code> characters.  May be negated.  If negated, same as <code>raw</code>.</td></tr>
<tr><td>raw</td><td>Same as: <pre>-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -opost -isig -icanon -xcase min 1 time 0</pre> May be negated.  If negated, same as <code>cooked</code>.</td></tr>
<tr><td>cbreak</td><td>Same as <code>-icanon</code>.  May be negated.  If negated, same as <code>icanon</code>.</td></tr>
<tr><td>pass8</td><td>Same as <code>-parenb -istrip cs8</code>.  May be negated.  If negated, same as <code>parenb istrip cs7</code>.</td></tr>
<tr><td>litout</td><td>Same as <code>-parenb -istrip -opost cs8</code>.  May be negated.  If negated, same as <code>parenb istrip opost cs7</code>.</td></tr>
<tr><td>decctlq</td><td>Same as <code>-ixany</code>.  Non-POSIX.  May be negated.</td></tr>
<tr><td>tabs</td><td>Same as <code>tab0</code>.  Non-POSIX.  May be negated.  If negated, same as <code>tab3</code>.</td></tr>
<tr><td>lcase, LCASE</td><td>Same as <code>xcase iuclc olcuc</code>.  Non-POSIX.  May be negated.</td></tr>
<tr><td>crt</td><td>Same as <code>echoe echoctl echoke</code>.</td></tr>
<tr><td>dec</td><td>Same as <code>echoe echoctl echoke -ixany intr ^C erase ^? kill C-u</code>.</td></tr>
</tbody></table>

<h3>Special characters</h3>
<p>The special characters' default values vary from system to system. They are set with the syntax <code>name value</code>, where the names are listed below and the value can be given either literally, in hat notation (<code>^C</code>), or as an integer which may start with <code>0x</code> to indicate hexadecimal, <code>0</code> to indicate octal, or any other digit to indicate decimal.</p>
<p>For GNU stty, giving a value of <code>^-</code> or <code>undef</code> disables that special character.  (This is incompatible with Ultrix <code>stty</code>, which uses  a value of <code>u</code> to disable a special character.  GNU <code>stty</code> treats a value <code>u</code> like any other, namely to set that special character to .)</p>
<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><var>intr</var></td><td>Send an interrupt signal.</td></tr>
<tr><td><var>quit</var></td><td>Send a quit signal.</td></tr>
<tr><td><var>erase</var></td><td>Erase the last character typed.</td></tr>
<tr><td><var>kill</var></td><td>Erase the current line.</td></tr>
<tr><td><var>eof</var></td><td>Send an end of file (terminate the input).</td></tr>
<tr><td><var>eol</var></td><td>End the line.</td></tr>
<tr><td><var>eol2</var></td><td>Alternate character to end the line.  Non-POSIX.</td></tr>
<tr><td><var>swtch</var></td><td>Switch to a different shell layer.  Non-POSIX.</td></tr>
<tr><td><var>start</var></td><td>Restart the output after stopping it.</td></tr>
<tr><td><var>stop</var></td><td>Stop the output.</td></tr>
<tr><td><var>susp</var></td><td>Send a terminal stop signal.</td></tr>
<tr><td><var>dsusp</var></td><td>Send a terminal stop signal after flushing the input.  Non-POSIX.</td></tr>
<tr><td><var>rprnt</var></td><td>Redraw the current line.  Non-POSIX.</td></tr>
<tr><td><var>werase</var></td><td>Erase the last word typed.  Non-POSIX.</td></tr>
<tr><td><var>lnext</var></td><td>Enter the next character typed literally, even if it is a special character.  Non-POSIX.</td></tr>
</tbody></table>


<h3>Special settings</h3>
<ul>
<li><var>min N</var> - Set the minimum number of characters that will satisfy a read until the time value has expired, when <code>-icanon</code> is set.</li>
<li><var>time N</var> - Set the number of tenths of a second before reads time out if the minimum number of characters have not been read, when <code>-icanon</code> is set.</li>
<li><var>ispeed N</var> - Set the input speed to N.</li>
<li><var>ospeed N</var> - Set the output speed to N.</li>
<li><var>rows N</var> - Tell the tty kernel driver that the terminal has N rows. Non-POSIX.</li>
<li><var>cols N</var>, <var>columns N</var> - Tell the kernel that the terminal has N columns.  Non-POSIX.</li>
<li><var>size</var> - Print the number of rows and columns that the kernel thinks the terminal has.  (Systems that don't support rows and columns in the kernel typically use the environment variables <code>LINES</code> and <code>COLUMNS</code> instead; however, GNU <code>stty</code> does not know anything about them.)  Non-POSIX.</li>
<li><var>line N</var> - Use line discipline N.  Non-POSIX.</li>
<li><var>speed</var> - Print the terminal speed.</li>
<li><var>N</var> - Set the input and output speeds to N.  N can be one of: 0 50 75 110 134 134.5 150 200 300 600 1200 1800 2400 4800 9600 19200 38400 <code>exta</code> <code>extb</code>.  <code>exta</code> is the same as 19200; <code>extb</code> is the same as 38400.  0 hangs up the line if <code>-clocal</code> is set.</li>
</ul>


<h2>Color Terminals</h2>
<pre>color256 ()
{
    local L=$(sed &#039;s/[0-9]//g; s/./#/g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS - 10))`);
    for i in `seq 0 $(tput colors)`;
    do printf " %.3d `tput setab $i`${L}${R} %.3d `tput setab 0;tput setaf 7`\n" $i $i | tr &#039;#&#039; &#039; &#039;;
    done
}</pre>

<pre>for F in `find ~/.terminfo/ -type f | sed &#039;s/^.*\///&#039; | xargs -P0 -I&#039;TT&#039; sh -c &#039;echo "$(tput -T TT colors): TT"&#039;|sed &#039;/^-/d&#039;| grep ^16:|cut -d: -f2`; do
echo -e "\n\n";
pm $F; export TERM=$F; tput -T $F initc; color256; done</pre>

<pre>find ~/.terminfo/ -type f | sed &#039;s/^.*\///&#039; | xargs -I&#039;TT&#039; sh -c &#039;echo "$(tput -T TT colors): TT"&#039;|sed &#039;/^-/d&#039;</pre>

<h3>Terminals with 16 Colors</h3>
<ul>
<li><var>aixterm-16color</var></li>
<li><var>amiga-vnc</var></li>
<li><var>hp2397</var></li>
<li><var>hp2397a</var></li>
<li><var>hp+color</var></li>
<li><var>ibm+16color</var></li>
<li><var>konsole-16color</var></li>
<li><var>nsterm-16color</var></li>
<li><var>nsterm-7-c</var></li>
<li><var>nsterm-7-c-s</var></li>
<li><var>nsterm-acs-c</var></li>
<li><var>nsterm-acs-c-s</var></li>
<li><var>nsterm-c</var></li>
<li><var>nsterm+c</var></li>
<li><var>nsterm-c-7</var></li>
<li><var>nsterm-c-acs</var></li>
<li><var>nsterm-c-s</var></li>
<li><var>nsterm-c-s-7</var></li>
<li><var>nsterm-c-s-acs</var></li>
<li><var>rxvt-16color</var></li>
<li><var>screen-16color</var></li>
<li><var>screen-16color-bce</var></li>
<li><var>screen-16color-bce-s</var></li>
<li><var>screen-16color-s</var></li>
<li><var>xterm-16color</var></li>
</ul>

<h3>Terminals with 52 Colors</h3>
<ul>
<li><var>d430c-dg-ccc</var></li>
<li><var>d430c-unix-25-ccc</var></li>
<li><var>d430c-unix-ccc</var></li>
<li><var>d430c-unix-s-ccc</var></li>
<li><var>d430c-unix-sr-ccc</var></li>
<li><var>d430c-unix-w-ccc</var></li>
<li><var>d430-dg-ccc</var></li>
<li><var>d430-unix-25-ccc</var></li>
<li><var>d430-unix-ccc</var></li>
<li><var>d430-unix-s-ccc</var></li>
<li><var>d430-unix-sr-ccc</var></li>
<li><var>d430-unix-w-ccc</var></li>
<li><var>dg+ccc</var></li>
<li><var>dgunix+ccc</var></li>
</ul>

<h3>Terminals with 64 Colors</h3>
<ul>
<li><var>hpterm-color</var></li>
<li><var>wy370</var></li>
<li><var>wy370-101k</var></li>
<li><var>wy370-105k</var></li>
<li><var>wy370-EPC</var></li>
<li><var>wy370-nk</var></li>
<li><var>wy370-rv</var></li>
<li><var>wy370-vb</var></li>
<li><var>wy370-w</var></li>
<li><var>wy370-wvb</var></li>
<li><var>wyse370</var></li>
<li><var>Eterm-88color</var></li>
<li><var>rxvt-88color</var></li>
<li><var>xterm-88color</var></li>
<li><var>xterm+88color</var></li>
</ul>

<h3>Terminals with 256 colors</h3>
<ul>
<li><var>Eterm-256color</var></li>
<li><var>gnome-256color</var></li>
<li><var>konsole-256color</var></li>
<li><var>putty-256color</var></li>
<li><var>rxvt-256color</var></li>
<li><var>screen-256color</var></li>
<li><var>screen-256color-bce</var></li>
<li><var>screen-256color-bce-s</var></li>
<li><var>screen-256color-s</var></li>
<li><var>xterm-256color</var></li>
<li><var>xterm+256color</var></li>
</ul>


<h3>View All tput capabilities</h3>
<p><a href="http://blogs.msdn.com/adioltean/articles/271063.aspx">http://blogs.msdn.com/adioltean/articles/271063.aspx</a></p>
<pre>function tputs(){ infocmp -1|sed &#039;s/^[   ]*//; /=/!d; s/=.*//g; /[#\|]/d&#039;; }</pre>

<p>Some  common  terminfo  parameter sequences, their termcap equivalents, and some terminal types which commonly have such sequences, are:</p>
<pre>terminfo                    termcap   Representative Terminals
---------------------------------------------------------------
%p1%c                       %.        adm
%p1%d                       %d        hp, ANSI standard, vt100
%p1%+%c                 %+x       concept
%i                          %iq       ANSI standard, vt100
%p1%?%&gt;%t%p1%+%;    %&gt;xy      concept
%p2 is printed before %p1   %r        hp</pre>



<h2>Installing your Own Terminfo</h2>
<p><a href="http://nion.modprobe.de/mostlike.txt">MostLike</a>, or if that is offline I uploaded a copy: <a href="http://uploads.askapache.com/2010/03/mostlike.txt">mostlike - manpages with color looking like most</a></p>
<pre>rm -rvf ~/.terminfo
mkdir -pv ~/.terminfo
curl -o terminfo.master http://nion.modprobe.de/mostlike.txt; curl -Ss ftp://invisible-island.net/ncurses/terminfo.src.gz
export TERMINFO=~/.terminfo;
sudo tic -e screen-256color,screen-256color-s,screen-256color-bce,screen-256color-bce-s,xterm+256color,xterm,xterm-pcolor terminfo.src</pre>


<h2>256 Colors in Terminal</h2>
<h3>256 Colors (Background)</h3>
<pre>W=`tput setaf 7` RC="\E[0;0;0m" L=$(sed &#039;s/[0-9]//g; s/./ /g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS/2))`);
&nbsp;
for i in `seq 0 256`;
do
  printf "${W}\n%.3d `tput setab $i`${L}${RC}" $i;
done</pre>



<h3>256 Colors (Foreground)</h3>
<pre>W=`tput setaf 7` WB=`tput setab 0` RC="\E[0;0;0m" L=$(sed &#039;s/[0-9]//g; s/./#/g&#039; &lt;&lt;&lt;`seq -s+0 $(($COLUMNS/2))`);
for i in `seq 0 256`;
do
  printf "${WB}\n%.3d `tput setaf $i`${L}${RC}" $i;
done</pre>



<h2>Terminal Capabilities - Infocmp</h2>
<pre>infocmp -1Lq|grep -v "$TERM\|#"|tr -d &#039;  &#039;</pre>

<h3>DEC/ANSI special sequences</h3>
<p>List of the DEC/ANSI special sequences recognized:</p>
<table class="bordered">
<tbody>
<tr class="header">
<th>Action</th>
<th>Meaning</th>
</tr>
<tr><td><code>%%</code></td>
        <td>The percent sign</td></tr>
<tr class="odd"><td><code>%t</code></td>
        <td>The time the request was received in Universal Coordinated Time
        since the epoch (Jan. 1, 1970) measured in microseconds. The value
        is preceded by <code>t=</code>.</td></tr>
<tr><td><code>%D</code></td>
        <td>The time from when the request was received to the time the
        headers are sent on the wire. This is a measure of the duration
        of the request. The value is preceded by <code>D=</code>.
        The value is measured in microseconds.</td></tr>
<tr class="odd"><td><code>%{VARNAME}e</code></td>
        <td>The contents of the <a href="../env.html">environment
        variable</a> <code>VARNAME</code>.</td></tr>
<tr><td><code>%{VARNAME}s</code></td>
        <td>The contents of the <a href="mod_ssl.html#envvars">SSL environment
        variable</a> <code>VARNAME</code>, if <code>&lt;a href="../mod/mod_ssl.html"&gt;mod_ssl&lt;/a&gt;</code> is enabled.</td></tr>

-----------------------------------------
<tr><td><code>RIS         </code></td><td>full reset</td></tr>
<tr><td><code>SC          </code></td><td>save cursor</td></tr>
<tr><td><code>RC          </code></td><td>restore cursor</td></tr>
<tr><td><code>LL          </code></td><td>home-down</td></tr>
<tr><td><code>RSR         </code></td><td>reset scroll region</td></tr>
-----------------------------------------
<tr><td><code>DECSTR      </code></td><td>soft reset (VT320)</td></tr>
<tr><td><code>S7C1T       </code></td><td>7-bit controls (VT220)</td></tr>
-----------------------------------------
<tr><td><code>ISO DEC G0  </code></td><td>enable DEC graphics for G0</td></tr>
<tr><td><code>ISO UK G0   </code></td><td>enable UK chars for G0</td></tr>
<tr><td><code>ISO US G0   </code></td><td>enable US chars for G0</td></tr>
<tr><td><code>ISO DEC G1  </code></td><td>enable DEC graphics for G1</td></tr>
<tr><td><code>ISO UK G1   </code></td><td>enable UK chars for G1</td></tr>
<tr><td><code>ISO US G1   </code></td><td>enable US chars for G1</td></tr>
-----------------------------------------
<tr><td><code>DECPAM      </code></td><td>application keypad mode</td></tr>
<tr><td><code>DECPNM      </code></td><td>normal keypad mode</td></tr>
<tr><td><code>DECANSI     </code></td><td>enter ANSI mode</td></tr>
-----------------------------------------
<tr><td><code>ECMA[+-]AM  </code></td><td>keyboard action mode</td></tr>
<tr><td><code>ECMA[+-]IRM </code></td><td>insert replace mode</td></tr>
<tr><td><code>ECMA[+-]SRM </code></td><td>send receive mode</td></tr>
<tr><td><code>ECMA[+-]LNM </code></td><td>linefeed mode</td></tr>
-----------------------------------------
<tr><td><code>DEC[+-]CKM  </code></td><td>application cursor keys</td></tr>
<tr><td><code>DEC[+-]ANM  </code></td><td>set VT52 mode</td></tr>
<tr><td><code>DEC[+-]COLM </code></td><td>132-column mode</td></tr>
<tr><td><code>DEC[+-]SCLM </code></td><td>smooth scroll</td></tr>
<tr><td><code>DEC[+-]SCNM </code></td><td>reverse video mode</td></tr>
<tr><td><code>DEC[+-]OM   </code></td><td>origin mode</td></tr>
<tr><td><code>DEC[+-]AWM  </code></td><td>wraparound mode</td></tr>
<tr><td><code>DEC[+-]ARM  </code></td><td>auto-repeat mode</td></tr>
</tbody>
</table>




<table class="bordered"><tbody><tr class="header"><th>Name</th><th>Description</th></tr>
<tr><td><a id="acs_chars">acs_chars</a></td><td><code>``aaffggiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,</code></td></tr>
<tr><td><a id="back_tab">back_tab</a></td><td><code>\E[Z,</code></td></tr>
<tr><td><a id="bell">bell</a></td><td><code>^G,</code></td></tr>
<tr><td><a id="carriage_return">carriage_return</a></td><td><code>^M,</code></td></tr>
<tr><td><a id="change_scroll_region">change_scroll_region</a></td><td><code>\E[%i%p1%d;%p2%dr,</code></td></tr>
<tr><td><a id="clear_all_tabs">clear_all_tabs</a></td><td><code>\E[3g,</code></td></tr>
<tr><td><a id="clear_screen">clear_screen</a></td><td><code>\E[H\E[2J,</code></td></tr>
<tr><td><a id="clr_bol">clr_bol</a></td><td><code>\E[1K,</code></td></tr>
<tr><td><a id="clr_eol">clr_eol</a></td><td><code>\E[K,</code></td></tr>
<tr><td><a id="clr_eos">clr_eos</a></td><td><code>\E[J,</code></td></tr>
<tr><td><a id="column_address">column_address</a></td><td><code>\E[%i%p1%dG,</code></td></tr>
<tr><td><a id="cursor_address">cursor_address</a></td><td><code>\E[%i%p1%d;%p2%dH,</code></td></tr>
<tr><td><a id="cursor_down">cursor_down</a></td><td><code>^J,</code></td></tr>
<tr><td><a id="cursor_home">cursor_home</a></td><td><code>\E[H,</code></td></tr>
<tr><td><a id="cursor_invisible">cursor_invisible</a></td><td><code>\E[?25l,</code></td></tr>
<tr><td><a id="cursor_left">cursor_left</a></td><td><code>^H,</code></td></tr>
<tr><td><a id="cursor_normal">cursor_normal</a></td><td><code>\E[?12l\E[?25h,</code></td></tr>
<tr><td><a id="cursor_right">cursor_right</a></td><td><code>\E[C,</code></td></tr>
<tr><td><a id="cursor_up">cursor_up</a></td><td><code>\E[A,</code></td></tr>
<tr><td><a id="cursor_visible">cursor_visible</a></td><td><code>\E[?12;25h,</code></td></tr>
<tr><td><a id="delete_character">delete_character</a></td><td><code>\E[P,</code></td></tr>
<tr><td><a id="delete_line">delete_line</a></td><td><code>\E[M,</code></td></tr>
<tr><td><a id="enter_alt_charset_mode">enter_alt_charset_mode</a></td><td><code>\E(0,</code></td></tr>
<tr><td><a id="enter_am_mode">enter_am_mode</a></td><td><code>\E[?7h,</code></td></tr>
<tr><td><a id="enter_blink_mode">enter_blink_mode</a></td><td><code>\E[5m,</code></td></tr>
<tr><td><a id="enter_bold_mode">enter_bold_mode</a></td><td><code>\E[1m,</code></td></tr>
<tr><td><a id="enter_ca_mode">enter_ca_mode</a></td><td><code>\E[?1049h,</code></td></tr>
<tr><td><a id="enter_insert_mode">enter_insert_mode</a></td><td><code>\E[4h,</code></td></tr>
<tr><td><a id="enter_reverse_mode">enter_reverse_mode</a></td><td><code>\E[7m,</code></td></tr>
<tr><td><a id="enter_secure_mode">enter_secure_mode</a></td><td><code>\E[8m,</code></td></tr>
<tr><td><a id="enter_standout_mode">enter_standout_mode</a></td><td><code>\E[7m,</code></td></tr>
<tr><td><a id="enter_underline_mode">enter_underline_mode</a></td><td><code>\E[4m,</code></td></tr>
<tr><td><a id="erase_chars">erase_chars</a></td><td><code>\E[%p1%dX,</code></td></tr>
<tr><td><a id="exit_alt_charset_mode">exit_alt_charset_mode</a></td><td><code>\E(B,</code></td></tr>
<tr><td><a id="exit_am_mode">exit_am_mode</a></td><td><code>\E[?7l,</code></td></tr>
<tr><td><a id="exit_attribute_mode">exit_attribute_mode</a></td><td><code>\E(B\E[m,</code></td></tr>
<tr><td><a id="exit_ca_mode">exit_ca_mode</a></td><td><code>\E[?1049l,</code></td></tr>
<tr><td><a id="exit_insert_mode">exit_insert_mode</a></td><td><code>\E[4l,</code></td></tr>
<tr><td><a id="exit_standout_mode">exit_standout_mode</a></td><td><code>\E[27m,</code></td></tr>
<tr><td><a id="exit_underline_mode">exit_underline_mode</a></td><td><code>\E[24m,</code></td></tr>
<tr><td><a id="flash_screen">flash_screen</a></td><td><code>\E[?5h$&lt;100/&gt;\E[?5l,</code></td></tr>
<tr><td><a id="init_2string">init_2string</a></td><td><code>\E[\041p\E[?3;4l\E[4l\E&gt;,</code></td></tr>
<tr><td><a id="initialize_color">initialize_color</a></td><td><code>\E]4;%p1%d;rgb\072%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\,</code></td></tr>
<tr><td><a id="insert_line">insert_line</a></td><td><code>\E[L,</code></td></tr>
<tr><td><a id="key_b2">key_b2</a></td><td><code>\EOE,</code></td></tr>
<tr><td><a id="key_backspace">key_backspace</a></td><td><code>\177,</code></td></tr>
<tr><td><a id="key_btab">key_btab</a></td><td><code>\E[Z,</code></td></tr>
<tr><td><a id="key_dc">key_dc</a></td><td><code>\E[3~,</code></td></tr>
<tr><td><a id="key_down">key_down</a></td><td><code>\EOB,</code></td></tr>
<tr><td><a id="key_end">key_end</a></td><td><code>\EOF,</code></td></tr>
<tr><td><a id="key_enter">key_enter</a></td><td><code>\EOM,</code></td></tr>
<tr><td><a id="key_f1">key_f1</a></td><td><code>\EOP,</code></td></tr>
<tr><td><a id="key_f10">key_f10</a></td><td><code>\E[21~,</code></td></tr>
<tr><td><a id="key_f11">key_f11</a></td><td><code>\E[23~,</code></td></tr>
<tr><td><a id="key_f12">key_f12</a></td><td><code>\E[24~,</code></td></tr>
<tr><td><a id="key_f13">key_f13</a></td><td><code>\EO2P,</code></td></tr>
<tr><td><a id="key_f14">key_f14</a></td><td><code>\EO2Q,</code></td></tr>
<tr><td><a id="key_f15">key_f15</a></td><td><code>\EO2R,</code></td></tr>
<tr><td><a id="key_f16">key_f16</a></td><td><code>\EO2S,</code></td></tr>
<tr><td><a id="key_f17">key_f17</a></td><td><code>\E[15;2~,</code></td></tr>
<tr><td><a id="key_f18">key_f18</a></td><td><code>\E[17;2~,</code></td></tr>
<tr><td><a id="key_f19">key_f19</a></td><td><code>\E[18;2~,</code></td></tr>
<tr><td><a id="key_f2">key_f2</a></td><td><code>\EOQ,</code></td></tr>
<tr><td><a id="key_f20">key_f20</a></td><td><code>\E[19;2~,</code></td></tr>
<tr><td><a id="key_f21">key_f21</a></td><td><code>\E[20;2~,</code></td></tr>
<tr><td><a id="key_f22">key_f22</a></td><td><code>\E[21;2~,</code></td></tr>
<tr><td><a id="key_f23">key_f23</a></td><td><code>\E[23;2~,</code></td></tr>
<tr><td><a id="key_f24">key_f24</a></td><td><code>\E[24;2~,</code></td></tr>
<tr><td><a id="key_f25">key_f25</a></td><td><code>\EO5P,</code></td></tr>
<tr><td><a id="key_f26">key_f26</a></td><td><code>\EO5Q,</code></td></tr>
<tr><td><a id="key_f27">key_f27</a></td><td><code>\EO5R,</code></td></tr>
<tr><td><a id="key_f28">key_f28</a></td><td><code>\EO5S,</code></td></tr>
<tr><td><a id="key_f29">key_f29</a></td><td><code>\E[15;5~,</code></td></tr>
<tr><td><a id="key_f3">key_f3</a></td><td><code>\EOR,</code></td></tr>
<tr><td><a id="key_f30">key_f30</a></td><td><code>\E[17;5~,</code></td></tr>
<tr><td><a id="key_f31">key_f31</a></td><td><code>\E[18;5~,</code></td></tr>
<tr><td><a id="key_f32">key_f32</a></td><td><code>\E[19;5~,</code></td></tr>
<tr><td><a id="key_f33">key_f33</a></td><td><code>\E[20;5~,</code></td></tr>
<tr><td><a id="key_f34">key_f34</a></td><td><code>\E[21;5~,</code></td></tr>
<tr><td><a id="key_f35">key_f35</a></td><td><code>\E[23;5~,</code></td></tr>
<tr><td><a id="key_f36">key_f36</a></td><td><code>\E[24;5~,</code></td></tr>
<tr><td><a id="key_f37">key_f37</a></td><td><code>\EO6P,</code></td></tr>
<tr><td><a id="key_f38">key_f38</a></td><td><code>\EO6Q,</code></td></tr>
<tr><td><a id="key_f39">key_f39</a></td><td><code>\EO6R,</code></td></tr>
<tr><td><a id="key_f4">key_f4</a></td><td><code>\EOS,</code></td></tr>
<tr><td><a id="key_f40">key_f40</a></td><td><code>\EO6S,</code></td></tr>
<tr><td><a id="key_f41">key_f41</a></td><td><code>\E[15;6~,</code></td></tr>
<tr><td><a id="key_f42">key_f42</a></td><td><code>\E[17;6~,</code></td></tr>
<tr><td><a id="key_f43">key_f43</a></td><td><code>\E[18;6~,</code></td></tr>
<tr><td><a id="key_f44">key_f44</a></td><td><code>\E[19;6~,</code></td></tr>
<tr><td><a id="key_f45">key_f45</a></td><td><code>\E[20;6~,</code></td></tr>
<tr><td><a id="key_f46">key_f46</a></td><td><code>\E[21;6~,</code></td></tr>
<tr><td><a id="key_f47">key_f47</a></td><td><code>\E[23;6~,</code></td></tr>
<tr><td><a id="key_f48">key_f48</a></td><td><code>\E[24;6~,</code></td></tr>
<tr><td><a id="key_f49">key_f49</a></td><td><code>\EO3P,</code></td></tr>
<tr><td><a id="key_f5">key_f5</a></td><td><code>\E[15~,</code></td></tr>
<tr><td><a id="key_f50">key_f50</a></td><td><code>\EO3Q,</code></td></tr>
<tr><td><a id="key_f51">key_f51</a></td><td><code>\EO3R,</code></td></tr>
<tr><td><a id="key_f52">key_f52</a></td><td><code>\EO3S,</code></td></tr>
<tr><td><a id="key_f53">key_f53</a></td><td><code>\E[15;3~,</code></td></tr>
<tr><td><a id="key_f54">key_f54</a></td><td><code>\E[17;3~,</code></td></tr>
<tr><td><a id="key_f55">key_f55</a></td><td><code>\E[18;3~,</code></td></tr>
<tr><td><a id="key_f56">key_f56</a></td><td><code>\E[19;3~,</code></td></tr>
<tr><td><a id="key_f57">key_f57</a></td><td><code>\E[20;3~,</code></td></tr>
<tr><td><a id="key_f58">key_f58</a></td><td><code>\E[21;3~,</code></td></tr>
<tr><td><a id="key_f59">key_f59</a></td><td><code>\E[23;3~,</code></td></tr>
<tr><td><a id="key_f6">key_f6</a></td><td><code>\E[17~,</code></td></tr>
<tr><td><a id="key_f60">key_f60</a></td><td><code>\E[24;3~,</code></td></tr>
<tr><td><a id="key_f61">key_f61</a></td><td><code>\EO4P,</code></td></tr>
<tr><td><a id="key_f62">key_f62</a></td><td><code>\EO4Q,</code></td></tr>
<tr><td><a id="key_f63">key_f63</a></td><td><code>\EO4R,</code></td></tr>
<tr><td><a id="key_f7">key_f7</a></td><td><code>\E[18~,</code></td></tr>
<tr><td><a id="key_f8">key_f8</a></td><td><code>\E[19~,</code></td></tr>
<tr><td><a id="key_f9">key_f9</a></td><td><code>\E[20~,</code></td></tr>
<tr><td><a id="key_home">key_home</a></td><td><code>\EOH,</code></td></tr>
<tr><td><a id="key_ic">key_ic</a></td><td><code>\E[2~,</code></td></tr>
<tr><td><a id="key_left">key_left</a></td><td><code>\EOD,</code></td></tr>
<tr><td><a id="key_mouse">key_mouse</a></td><td><code>\E[M,</code></td></tr>
<tr><td><a id="key_npage">key_npage</a></td><td><code>\E[6~,</code></td></tr>
<tr><td><a id="key_ppage">key_ppage</a></td><td><code>\E[5~,</code></td></tr>
<tr><td><a id="key_right">key_right</a></td><td><code>\EOC,</code></td></tr>
<tr><td><a id="key_sdc">key_sdc</a></td><td><code>\E[3;2~,</code></td></tr>
<tr><td><a id="key_send">key_send</a></td><td><code>\E[1;2F,</code></td></tr>
<tr><td><a id="key_sf">key_sf</a></td><td><code>\E[1;2B,</code></td></tr>
<tr><td><a id="key_shome">key_shome</a></td><td><code>\E[1;2H,</code></td></tr>
<tr><td><a id="key_sic">key_sic</a></td><td><code>\E[2;2~,</code></td></tr>
<tr><td><a id="key_sleft">key_sleft</a></td><td><code>\E[1;2D,</code></td></tr>
<tr><td><a id="key_snext">key_snext</a></td><td><code>\E[6;2~,</code></td></tr>
<tr><td><a id="key_sprevious">key_sprevious</a></td><td><code>\E[5;2~,</code></td></tr>
<tr><td><a id="key_sr">key_sr</a></td><td><code>\E[1;2A,</code></td></tr>
<tr><td><a id="key_sright">key_sright</a></td><td><code>\E[1;2C,</code></td></tr>
<tr><td><a id="key_up">key_up</a></td><td><code>\EOA,</code></td></tr>
<tr><td><a id="keypad_local">keypad_local</a></td><td><code>\E[?1l\E&gt;,</code></td></tr>
<tr><td><a id="keypad_xmit">\E[?1h\E</a></td><td><code>,</code></td></tr>
<tr><td><a id="memory_lock">memory_lock</a></td><td><code>\El,</code></td></tr>
<tr><td><a id="memory_unlock">memory_unlock</a></td><td><code>\Em,</code></td></tr>
<tr><td><a id="orig_pair">orig_pair</a></td><td><code>\E[39;49m,</code></td></tr>
<tr><td><a id="parm_dch">parm_dch</a></td><td><code>\E[%p1%dP,</code></td></tr>
<tr><td><a id="parm_delete_line">parm_delete_line</a></td><td><code>\E[%p1%dM,</code></td></tr>
<tr><td><a id="parm_down_cursor">parm_down_cursor</a></td><td><code>\E[%p1%dB,</code></td></tr>
<tr><td><a id="parm_ich">parm_ich</a></td><td><code>\E[%p1%d@,</code></td></tr>
<tr><td><a id="parm_index">parm_index</a></td><td><code>\E[%p1%dS,</code></td></tr>
<tr><td><a id="parm_insert_line">parm_insert_line</a></td><td><code>\E[%p1%dL,</code></td></tr>
<tr><td><a id="parm_left_cursor">parm_left_cursor</a></td><td><code>\E[%p1%dD,</code></td></tr>
<tr><td><a id="parm_right_cursor">parm_right_cursor</a></td><td><code>\E[%p1%dC,</code></td></tr>
<tr><td><a id="parm_rindex">parm_rindex</a></td><td><code>\E[%p1%dT,</code></td></tr>
<tr><td><a id="parm_up_cursor">parm_up_cursor</a></td><td><code>\E[%p1%dA,</code></td></tr>
<tr><td><a id="print_screen">print_screen</a></td><td><code>\E[i,</code></td></tr>
<tr><td><a id="prtr_off">prtr_off</a></td><td><code>\E[4i,</code></td></tr>
<tr><td><a id="prtr_on">prtr_on</a></td><td><code>\E[5i,</code></td></tr>
<tr><td><a id="reset_1string">reset_1string</a></td><td><code>\Ec,</code></td></tr>
<tr><td><a id="reset_2string">reset_2string</a></td><td><code>\E[\041p\E[?3;4l\E[4l\E&gt;,</code></td></tr>
<tr><td><a id="restore_cursor">restore_cursor</a></td><td><code>\E8,</code></td></tr>
<tr><td><a id="row_address">row_address</a></td><td><code>\E[%i%p1%dd,</code></td></tr>
<tr><td><a id="save_cursor">save_cursor</a></td><td><code>\E7,</code></td></tr>
<tr><td><a id="scroll_forward">scroll_forward</a></td><td><code>^J,</code></td></tr>
<tr><td><a id="scroll_reverse">scroll_reverse</a></td><td><code>\EM,</code></td></tr>
<tr><td><a id="set_a_background">set_a_background</a></td><td><code>\E[%?%p1%{8}%</code></td></tr>
</tbody></table>




<h2>Term Sorted</h2>
<pre>./MKtermsort.sh |sed &#039;s/.*\/\*  \(.*\)  \*\//\1/g&#039;|sort -u|grep ^[a-zA-Z]|sortwc|grep -v ^static|sort -d|tr " " &#039;,&#039;|sed &#039;s/\([^,]\{1,\}\),/&lt;var&gt;\1&lt;\/var&gt;,/g&#039;</pre>
<p><var>AB</var>,<var>ac</var>,<var>acs_btee</var>,<var>acsc</var>,<var>acs_chars</var>,<var>acs_hline</var>,<var>acs_llcorner</var>,<var>acs_lrcorner</var>,<var>acs_ltee</var>,<var>acs_plus</var>,<var>acs_rtee</var>,<var>acs_ttee</var>,<var>acs_ulcorner</var>,<var>acs_urcorner</var>,<var>acs_vline</var>,<var>ae</var>,<var>AF</var>,<var>al</var>,<var>AL</var>,<var>alt_scancode_esc</var>,<var>am</var>,<var>apstr</var>,<var>arrow_key_map</var>,<var>as</var>,<var>auto_left_margin</var>,<var>auto_right_margin</var>,<var>back_color_erase</var>,<var>backspace_delay</var>,<var>backspace_if_not_bs</var>,<var>backspaces_with_bs</var>,<var>back_tab</var>,<var>batt1</var>,<var>batt2</var>,<var>bc</var>,<var>bce</var>,<var>bel</var>,<var>bell</var>,<var>bicr</var>,<var>binel</var>,<var>birep</var>,<var>bit_image_carriage_return</var>,<var>bit_image_entwining</var>,<var>bit_image_newline</var>,<var>bit_image_repeat</var>,<var>bit_image_type</var>,<var>bitwin</var>,<var>bitype</var>,<var>bl</var>,<var>blink</var>,<var>bold</var>,<var>box1</var>,<var>box2</var>,<var>box_chars_1</var>,<var>bs</var>,<var>bt</var>,<var>BT</var>,<var>btml</var>,<var>btns</var>,<var>buffer_capacity</var>,<var>bufsz</var>,<var>buttons</var>,<var>bw</var>,<var>bx</var>,<var>can_change</var>,<var>carriage_return</var>,<var>carriage_return_delay</var>,<var>cb</var>,<var>cbt</var>,<var>cc</var>,<var>CC</var>,<var>ccc</var>,<var>cd</var>,<var>ce</var>,<var>ceol_standout_glitch</var>,<var>ch</var>,<var>change_char_pitch</var>,<var>change_line_pitch</var>,<var>change_res_horz</var>,<var>change_res_vert</var>,<var>change_scroll_region</var>,<var>char_padding</var>,<var>char_set_names</var>,<var>chr</var>,<var>chts</var>,<var>ci</var>,<var>civis</var>,<var>cl</var>,<var>clear</var>,<var>clear_all_tabs</var>,<var>clear_margins</var>,<var>clear_screen</var>,<var>clr_bol</var>,<var>clr_eol</var>,<var>clr_eos</var>,<var>cm</var>,<var>CM</var>,<var>cmdch</var>,<var>cnorm</var>,<var>co</var>,<var>Co</var>,<var>code_set_init</var>,<var>col_addr_glitch</var>,<var>colb0</var>,<var>colb1</var>,<var>colb2</var>,<var>colb3</var>,<var>colb4</var>,<var>colb5</var>,<var>colb6</var>,<var>colb7</var>,<var>colf0</var>,<var>colf1</var>,<var>colf2</var>,<var>colf3</var>,<var>colf4</var>,<var>colf5</var>,<var>colf6</var>,<var>colf7</var>,<var>color_names</var>,<var>colornm</var>,<var>colors</var>,<var>cols</var>,<var>column_address</var>,<var>columns</var>,<var>command_character</var>,<var>cpi</var>,<var>cpi_changes_res</var>,<var>cpix</var>,<var>cps</var>,<var>cr</var>,<var>cr_cancels_micro_mode</var>,<var>create_window</var>,<var>crt_no_scrolling</var>,<var>crxm</var>,<var>cs</var>,<var>csin</var>,<var>csnm</var>,<var>csr</var>,<var>ct</var>,<var>cub</var>,<var>cub1</var>,<var>cud</var>,<var>cud1</var>,<var>cuf</var>,<var>cuf1</var>,<var>cup</var>,<var>cursor_address</var>,<var>cursor_down</var>,<var>cursor_home</var>,<var>cursor_invisible</var>,<var>cursor_left</var>,<var>cursor_mem_address</var>,<var>cursor_normal</var>,<var>cursor_right</var>,<var>cursor_to_ll</var>,<var>cursor_up</var>,<var>cursor_visible</var>,<var>cuu</var>,<var>cuu1</var>,<var>cv</var>,<var>cvr</var>,<var>cvvis</var>,<var>CW</var>,<var>cwin</var>,<var>da</var>,<var>daisy</var>,<var>db</var>,<var>dB</var>,<var>dc</var>,<var>dC</var>,<var>DC</var>,<var>dch</var>,<var>dch1</var>,<var>dclk</var>,<var>defbi</var>,<var>defc</var>,<var>define_bit_image_region</var>,<var>define_char</var>,<var>delete_character</var>,<var>delete_line</var>,<var>dest_tabs_magic_smso</var>,<var>device_type</var>,<var>devt</var>,<var>DI</var>,<var>dial</var>,<var>dial_phone</var>,<var>dim</var>,<var>dispc</var>,<var>display_clock</var>,<var>display_pc_char</var>,<var>dis_status_line</var>,<var>DK</var>,<var>dl</var>,<var>DL</var>,<var>dl1</var>,<var>dm</var>,<var>dN</var>,<var>do</var>,<var>DO</var>,<var>docr</var>,<var>dot_horz_spacing</var>,<var>dot_vert_spacing</var>,<var>down_half_line</var>,<var>ds</var>,<var>dsl</var>,<var>dT</var>,<var>dv</var>,<var>eA</var>,<var>eat_newline_glitch</var>,<var>ec</var>,<var>ech</var>,<var>ed</var>,<var>ehhlm</var>,<var>ei</var>,<var>el</var>,<var>el1</var>,<var>elhlm</var>,<var>elohlm</var>,<var>ena_acs</var>,<var>enacs</var>,<var>endbi</var>,<var>end_bit_image_region</var>,<var>enter_alt_charset_mode</var>,<var>enter_am_mode</var>,<var>enter_blink_mode</var>,<var>enter_bold_mode</var>,<var>enter_ca_mode</var>,<var>enter_delete_mode</var>,<var>enter_dim_mode</var>,<var>enter_doublewide_mode</var>,<var>enter_draft_quality</var>,<var>enter_horizontal_hl_mode</var>,<var>enter_insert_mode</var>,<var>enter_italics_mode</var>,<var>enter_left_hl_mode</var>,<var>enter_leftward_mode</var>,<var>enter_low_hl_mode</var>,<var>enter_micro_mode</var>,<var>enter_near_letter_quality</var>,<var>enter_normal_quality</var>,<var>enter_pc_charset_mode</var>,<var>enter_protected_mode</var>,<var>enter_reverse_mode</var>,<var>enter_right_hl_mode</var>,<var>enter_scancode_mode</var>,<var>enter_secure_mode</var>,<var>enter_shadow_mode</var>,<var>enter_standout_mode</var>,<var>enter_subscript_mode</var>,<var>enter_superscript_mode</var>,<var>enter_top_hl_mode</var>,<var>enter_underline_mode</var>,<var>enter_upward_mode</var>,<var>enter_vertical_hl_mode</var>,<var>enter_xon_mode</var>,<var>eo</var>,<var>erase_chars</var>,<var>erase_overstrike</var>,<var>erhlm</var>,<var>es</var>,<var>eslok</var>,<var>ethlm</var>,<var>evhlm</var>,<var>exit_alt_charset_mode</var>,<var>exit_am_mode</var>,<var>exit_attribute_mode</var>,<var>exit_ca_mode</var>,<var>exit_delete_mode</var>,<var>exit_doublewide_mode</var>,<var>exit_insert_mode</var>,<var>exit_italics_mode</var>,<var>exit_leftward_mode</var>,<var>exit_micro_mode</var>,<var>exit_pc_charset_mode</var>,<var>exit_scancode_mode</var>,<var>exit_shadow_mode</var>,<var>exit_standout_mode</var>,<var>exit_subscript_mode</var>,<var>exit_superscript_mode</var>,<var>exit_underline_mode</var>,<var>exit_upward_mode</var>,<var>exit_xon_mode</var>,<var>F1</var>,<var>F2</var>,<var>F3</var>,<var>F4</var>,<var>F5</var>,<var>F6</var>,<var>F7</var>,<var>F8</var>,<var>F9</var>,<var>Fa</var>,<var>FA</var>,<var>Fb</var>,<var>FB</var>,<var>Fc</var>,<var>FC</var>,<var>Fd</var>,<var>FD</var>,<var>Fe</var>,<var>FE</var>,<var>ff</var>,<var>Ff</var>,<var>FF</var>,<var>Fg</var>,<var>FG</var>,<var>fh</var>,<var>Fh</var>,<var>FH</var>,<var>Fi</var>,<var>FI</var>,<var>fixed_pause</var>,<var>Fj</var>,<var>FJ</var>,<var>Fk</var>,<var>FK</var>,<var>Fl</var>,<var>FL</var>,<var>flash</var>,<var>flash_hook</var>,<var>flash_screen</var>,<var>fln</var>,<var>Fm</var>,<var>FM</var>,<var>Fn</var>,<var>FN</var>,<var>Fo</var>,<var>FO</var>,<var>font0</var>,<var>font1</var>,<var>font2</var>,<var>font3</var>,<var>font4</var>,<var>font5</var>,<var>font6</var>,<var>font7</var>,<var>form_feed</var>,<var>Fp</var>,<var>FP</var>,<var>Fq</var>,<var>FQ</var>,<var>Fr</var>,<var>FR</var>,<var>from_status_line</var>,<var>fs</var>,<var>FS</var>,<var>fsl</var>,<var>FT</var>,<var>FU</var>,<var>FV</var>,<var>FW</var>,<var>FX</var>,<var>FY</var>,<var>FZ</var>,<var>G1</var>,<var>G2</var>,<var>G3</var>,<var>G4</var>,<var>GC</var>,<var>GD</var>,<var>generic_type</var>,<var>getm</var>,<var>get_mouse</var>,<var>GH</var>,<var>GL</var>,<var>Gm</var>,<var>gn</var>,<var>gnu_has_meta_key</var>,<var>goto_window</var>,<var>GR</var>,<var>GU</var>,<var>GV</var>,<var>hangup</var>,<var>hard_copy</var>,<var>hard_cursor</var>,<var>has_hardware_tabs</var>,<var>has_meta_key</var>,<var>has_print_wheel</var>,<var>has_status_line</var>,<var>hc</var>,<var>HC</var>,<var>hd</var>,<var>hl</var>,<var>hls</var>,<var>ho</var>,<var>home</var>,<var>hook</var>,<var>horizontal_tab_delay</var>,<var>hpa</var>,<var>hs</var>,<var>ht</var>,<var>hts</var>,<var>hu</var>,<var>HU</var>,<var>hue_lightness_saturation</var>,<var>hup</var>,<var>hz</var>,<var>i1</var>,<var>i2</var>,<var>i3</var>,<var>ic</var>,<var>Ic</var>,<var>IC</var>,<var>ich</var>,<var>ich1</var>,<var>if</var>,<var>il</var>,<var>il1</var>,<var>im</var>,<var>in</var>,<var>ind</var>,<var>indn</var>,<var>init_1string</var>,<var>init_2string</var>,<var>init_3string</var>,<var>initc</var>,<var>init_file</var>,<var>initialize_color</var>,<var>initial
ize_pair</var>,<var>initp</var>,<var>init_prog</var>,<var>init_tabs</var>,<var>insert_character</var>,<var>insert_line</var>,<var>insert_null_glitch</var>,<var>insert_padding</var>,<var>invis</var>,<var>ip</var>,<var>iP</var>,<var>Ip</var>,<var>iprog</var>,<var>is</var>,<var>is1</var>,<var>is2</var>,<var>is3</var>,<var>it</var>,<var>k;</var>,<var>k0</var>,<var>k1</var>,<var>K1</var>,<var>k2</var>,<var>K2</var>,<var>k3</var>,<var>K3</var>,<var>k4</var>,<var>K4</var>,<var>k5</var>,<var>K5</var>,<var>k6</var>,<var>k7</var>,<var>k8</var>,<var>k9</var>,<var>ka</var>,<var>kA</var>,<var>ka1</var>,<var>ka3</var>,<var>kact</var>,<var>kb</var>,<var>kB</var>,<var>kb2</var>,<var>kbeg</var>,<var>kBEG</var>,<var>kbs</var>,<var>kbtab</var>,<var>kC</var>,<var>kc1</var>,<var>kc3</var>,<var>kcan</var>,<var>kCAN</var>,<var>kcbt</var>,<var>kclo</var>,<var>kclr</var>,<var>kcmd</var>,<var>kCMD</var>,<var>kcpn</var>,<var>kcpy</var>,<var>kCPY</var>,<var>kcrt</var>,<var>kCRT</var>,<var>kctab</var>,<var>kcub1</var>,<var>kcud1</var>,<var>kcuf1</var>,<var>kcuu1</var>,<var>kd</var>,<var>kD</var>,<var>kDC</var>,<var>kdch1</var>,<var>kDL</var>,<var>kdl1</var>,<var>kdo</var>,<var>ke</var>,<var>kE</var>,<var>ked</var>,<var>kel</var>,<var>kend</var>,<var>kEND</var>,<var>kent</var>,<var>kEOL</var>,<var>kext</var>,<var>kEXT</var>,<var>key_a1</var>,<var>key_a3</var>,<var>key_b2</var>,<var>key_backspace</var>,<var>key_beg</var>,<var>key_btab</var>,<var>key_c1</var>,<var>key_c3</var>,<var>key_cancel</var>,<var>key_catab</var>,<var>key_clear</var>,<var>key_close</var>,<var>key_command</var>,<var>key_copy</var>,<var>key_create</var>,<var>key_ctab</var>,<var>key_dc</var>,<var>key_dl</var>,<var>key_down</var>,<var>key_eic</var>,<var>key_end</var>,<var>key_enter</var>,<var>key_eol</var>,<var>key_eos</var>,<var>key_exit</var>,<var>key_f0</var>,<var>key_f1</var>,<var>key_f10</var>,<var>key_f11</var>,<var>key_f12</var>,<var>key_f13</var>,<var>key_f14</var>,<var>key_f15</var>,<var>key_f16</var>,<var>key_f17</var>,<var>key_f18</var>,<var>key_f19</var>,<var>key_f2</var>,<var>key_f20</var>,<var>key_f21</var>,<var>key_f22</var>,<var>key_f23</var>,<var>key_f24</var>,<var>key_f25</var>,<var>key_f26</var>,<var>key_f27</var>,<var>key_f28</var>,<var>key_f29</var>,<var>key_f3</var>,<var>key_f30</var>,<var>key_f31</var>,<var>key_f32</var>,<var>key_f33</var>,<var>key_f34</var>,<var>key_f35</var>,<var>key_f36</var>,<var>key_f37</var>,<var>key_f38</var>,<var>key_f39</var>,<var>key_f4</var>,<var>key_f40</var>,<var>key_f41</var>,<var>key_f42</var>,<var>key_f43</var>,<var>key_f44</var>,<var>key_f45</var>,<var>key_f46</var>,<var>key_f47</var>,<var>key_f48</var>,<var>key_f49</var>,<var>key_f5</var>,<var>key_f50</var>,<var>key_f51</var>,<var>key_f52</var>,<var>key_f53</var>,<var>key_f54</var>,<var>key_f55</var>,<var>key_f56</var>,<var>key_f57</var>,<var>key_f58</var>,<var>key_f59</var>,<var>key_f6</var>,<var>key_f60</var>,<var>key_f61</var>,<var>key_f62</var>,<var>key_f63</var>,<var>key_f7</var>,<var>key_f8</var>,<var>key_f9</var>,<var>key_find</var>,<var>key_help</var>,<var>key_home</var>,<var>key_ic</var>,<var>key_il</var>,<var>key_left</var>,<var>key_ll</var>,<var>key_mark</var>,<var>key_message</var>,<var>key_mouse</var>,<var>key_move</var>,<var>key_next</var>,<var>key_npage</var>,<var>key_open</var>,<var>key_options</var>,<var>keypad_local</var>,<var>keypad_xmit</var>,<var>key_ppage</var>,<var>key_previous</var>,<var>key_print</var>,<var>key_redo</var>,<var>key_reference</var>,<var>key_refresh</var>,<var>key_replace</var>,<var>key_restart</var>,<var>key_resume</var>,<var>key_right</var>,<var>key_save</var>,<var>key_sbeg</var>,<var>key_scancel</var>,<var>key_scommand</var>,<var>key_scopy</var>,<var>key_screate</var>,<var>key_sdc</var>,<var>key_sdl</var>,<var>key_select</var>,<var>key_send</var>,<var>key_seol</var>,<var>key_sexit</var>,<var>key_sf</var>,<var>key_sfind</var>,<var>key_shelp</var>,<var>key_shome</var>,<var>key_sic</var>,<var>key_sleft</var>,<var>key_smessage</var>,<var>key_smove</var>,<var>key_snext</var>,<var>key_soptions</var>,<var>key_sprevious</var>,<var>key_sprint</var>,<var>key_sr</var>,<var>key_sredo</var>,<var>key_sreplace</var>,<var>key_sright</var>,<var>key_srsume</var>,<var>key_ssave</var>,<var>key_ssuspend</var>,<var>key_stab</var>,<var>key_sundo</var>,<var>key_suspend</var>,<var>key_undo</var>,<var>key_up</var>,<var>kF</var>,<var>kf0</var>,<var>kf1</var>,<var>kf10</var>,<var>kf11</var>,<var>kf12</var>,<var>kf13</var>,<var>kf14</var>,<var>kf15</var>,<var>kf16</var>,<var>kf17</var>,<var>kf18</var>,<var>kf19</var>,<var>kf2</var>,<var>kf20</var>,<var>kf21</var>,<var>kf22</var>,<var>kf23</var>,<var>kf24</var>,<var>kf25</var>,<var>kf26</var>,<var>kf27</var>,<var>kf28</var>,<var>kf29</var>,<var>kf3</var>,<var>kf30</var>,<var>kf31</var>,<var>kf32</var>,<var>kf33</var>,<var>kf34</var>,<var>kf35</var>,<var>kf36</var>,<var>kf37</var>,<var>kf38</var>,<var>kf39</var>,<var>kf4</var>,<var>kf40</var>,<var>kf41</var>,<var>kf42</var>,<var>kf43</var>,<var>kf44</var>,<var>kf45</var>,<var>kf46</var>,<var>kf47</var>,<var>kf48</var>,<var>kf49</var>,<var>kf5</var>,<var>kf50</var>,<var>kf51</var>,<var>kf52</var>,<var>kf53</var>,<var>kf54</var>,<var>kf55</var>,<var>kf56</var>,<var>kf57</var>,<var>kf58</var>,<var>kf59</var>,<var>kf6</var>,<var>kf60</var>,<var>kf61</var>,<var>kf62</var>,<var>kf63</var>,<var>kf7</var>,<var>kf8</var>,<var>kf9</var>,<var>kfnd</var>,<var>kFND</var>,<var>kh</var>,<var>kH</var>,<var>khlp</var>,<var>kHLP</var>,<var>kHOM</var>,<var>khome</var>,<var>khts</var>,<var>kI</var>,<var>kIC</var>,<var>kich1</var>,<var>kil1</var>,<var>kind</var>,<var>kl</var>,<var>kL</var>,<var>kLFT</var>,<var>kll</var>,<var>km</var>,<var>kM</var>,<var>Km</var>,<var>kmous</var>,<var>kmov</var>,<var>kMOV</var>,<var>kmpf1</var>,<var>kmpf2</var>,<var>kmpf3</var>,<var>kmpf4</var>,<var>kmpf5</var>,<var>kmpf6</var>,<var>kmpf7</var>,<var>kmpf8</var>,<var>kmpf9</var>,<var>kmpt1</var>,<var>kmpt2</var>,<var>kmpt3</var>,<var>kmpt4</var>,<var>kmpt5</var>,<var>kmpt6</var>,<var>kmpt7</var>,<var>kmpt8</var>,<var>kmpt9</var>,<var>kmrk</var>,<var>kmsg</var>,<var>kMSG</var>,<var>kn</var>,<var>kN</var>,<var>knl</var>,<var>knp</var>,<var>knpn</var>,<var>knxt</var>,<var>kNXT</var>,<var>ko</var>,<var>kopn</var>,<var>kopt</var>,<var>kOPT</var>,<var>kP</var>,<var>kpp</var>,<var>kppn</var>,<var>kprt</var>,<var>kPRT</var>,<var>kprv</var>,<var>kPRV</var>,<var>kquit</var>,<var>kr</var>,<var>kR</var>,<var>krdo</var>,<var>kRDO</var>,<var>kref</var>,<var>kres</var>,<var>kRES</var>,<var>krfr</var>,<var>kri</var>,<var>kRIT</var>,<var>krmir</var>,<var>krpl</var>,<var>kRPL</var>,<var>krst</var>,<var>ks</var>,<var>kS</var>,<var>ksav</var>,<var>kSAV</var>,<var>kscl</var>,<var>kscr</var>,<var>ksel</var>,<var>ksf1</var>,<var>ksf10</var>,<var>ksf2</var>,<var>ksf3</var>,<var>ksf4</var>,<var>ksf5</var>,<var>ksf6</var>,<var>ksf7</var>,<var>ksf8</var>,<var>ksf9</var>,<var>kslt</var>,<var>kspd</var>,<var>kSPD</var>,<var>kt</var>,<var>kT</var>,<var>ktab</var>,<var>ktbc</var>,<var>ku</var>,<var>kund</var>,<var>kUND</var>,<var>l0</var>,<var>l1</var>,<var>l2</var>,<var>l3</var>,<var>l4</var>,<var>l5</var>,<var>l6</var>,<var>l7</var>,<var>l8</var>,<var>l9</var>,<var>la</var>,<var>label_format</var>,<var>label_height</var>,<var>label_off</var>,<var>label_on</var>,<var>label_width</var>,<var>lab_f0</var>,<var>lab_f1</var>,<var>lab_f10</var>,<var>lab_f2</var>,<var>lab_f3</var>,<var>lab_f4</var>,<var>lab_f5</var>,<var>lab_f6</var>,<var>lab_f7</var>,<var>lab_f8</var>,<var>lab_f9</var>,<var>le</var>,<var>LE</var>,<var>Lf</var>,<var>LF</var>,<var>lf0</var>,<var>lf1</var>,<var>lf10</var>,<var>lf2</var>,<var>lf3</var>,<var>lf4</var>,<var>lf5</var>,<var>lf6</var>,<var>lf7</var>,<var>lf8</var>,<var>lf9</var>,<var>lh</var>,<var>li</var>,<var>linefeed_if_not_lf</var>,<var>linefeed_is_newline</var>,<var>lines</var>,<var>lines_of_memory</var>,<var>ll</var>,<var>lm</var>,<var>LO</var>,<var>lpi</var>,<var>lpi_changes_res</var>,<var>lpix</var>,<var>lvert</var>,<var>lw</var>,<var>ma</var>,<var>maddr</var>,<var>magic_cookie_glitch</var>,<var>magic_cookie_glitch_ul</var>,<var>max_attributes</var>,<var>max_colors</var>,<var>maximum_windows</var>,<var>max_micro_address</va
r>,<var>max_micro_jump</var>,<var>max_pairs</var>,<var>mb</var>,<var>MC</var>,<var>mc0</var>,<var>mc4</var>,<var>mc5</var>,<var>mc5i</var>,<var>mc5p</var>,<var>mcs</var>,<var>mcub</var>,<var>mcub1</var>,<var>mcud</var>,<var>mcud1</var>,<var>mcuf</var>,<var>mcuf1</var>,<var>mcuu</var>,<var>mcuu1</var>,<var>md</var>,<var>me</var>,<var>meml</var>,<var>memory_above</var>,<var>memory_below</var>,<var>memory_lock</var>,<var>memory_unlock</var>,<var>memu</var>,<var>meta_off</var>,<var>meta_on</var>,<var>mgc</var>,<var>mh</var>,<var>mhpa</var>,<var>mi</var>,<var>Mi</var>,<var>micro_col_size</var>,<var>micro_column_address</var>,<var>micro_down</var>,<var>micro_left</var>,<var>micro_line_size</var>,<var>micro_right</var>,<var>micro_row_address</var>,<var>micro_up</var>,<var>minfo</var>,<var>mir</var>,<var>mjump</var>,<var>mk</var>,<var>ml</var>,<var>ML</var>,<var>mls</var>,<var>mm</var>,<var>mo</var>,<var>mouse_info</var>,<var>move_insert_mode</var>,<var>move_standout_mode</var>,<var>mp</var>,<var>mr</var>,<var>MR</var>,<var>mrcup</var>,<var>ms</var>,<var>msgr</var>,<var>MT</var>,<var>mu</var>,<var>mvpa</var>,<var>MW</var>,<var>nc</var>,<var>NC</var>,<var>ncv</var>,<var>nd</var>,<var>ND</var>,<var>ndscr</var>,<var>needs_xon_xoff</var>,<var>nel</var>,<var>newline</var>,<var>new_line_delay</var>,<var>nl</var>,<var>Nl</var>,<var>NL</var>,<var>nlab</var>,<var>no_color_video</var>,<var>no_correctly_working_cr</var>,<var>no_esc_ctlc</var>,<var>non_dest_scroll_region</var>,<var>non_rev_rmcup</var>,<var>no_pad_char</var>,<var>NP</var>,<var>npc</var>,<var>npins</var>,<var>NR</var>,<var>nrrmc</var>,<var>ns</var>,<var>number_of_function_keys</var>,<var>number_of_pins</var>,<var>num_labels</var>,<var>nw</var>,<var>nx</var>,<var>nxon</var>,<var>oc</var>,<var>op</var>,<var>orc</var>,<var>order_of_pins</var>,<var>orhi</var>,<var>orig_colors</var>,<var>orig_pair</var>,<var>orl</var>,<var>orvi</var>,<var>os</var>,<var>OTbc</var>,<var>OTbs</var>,<var>OTdB</var>,<var>OTdC</var>,<var>OTdN</var>,<var>OTdT</var>,<var>OTG1</var>,<var>OTG2</var>,<var>OTG3</var>,<var>OTG4</var>,<var>OTGC</var>,<var>OTGD</var>,<var>OTGH</var>,<var>OTGL</var>,<var>OTGR</var>,<var>OTGU</var>,<var>OTGV</var>,<var>other_non_function_keys</var>,<var>OTi2</var>,<var>OTkn</var>,<var>OTko</var>,<var>OTma</var>,<var>OTMT</var>,<var>OTnc</var>,<var>OTnl</var>,<var>OTNL</var>,<var>OTns</var>,<var>OTpt</var>,<var>OTrs</var>,<var>OTug</var>,<var>OTxr</var>,<var>output_res_char</var>,<var>output_res_horz_inch</var>,<var>output_res_line</var>,<var>output_res_vert_inch</var>,<var>over_strike</var>,<var>pa</var>,<var>PA</var>,<var>pad</var>,<var>pad_char</var>,<var>padding_baud_rate</var>,<var>pairs</var>,<var>parm_dch</var>,<var>parm_delete_line</var>,<var>parm_down_cursor</var>,<var>parm_down_micro</var>,<var>parm_ich</var>,<var>parm_index</var>,<var>parm_insert_line</var>,<var>parm_left_cursor</var>,<var>parm_left_micro</var>,<var>parm_right_cursor</var>,<var>parm_right_micro</var>,<var>parm_rindex</var>,<var>parm_up_cursor</var>,<var>parm_up_micro</var>,<var>pause</var>,<var>pb</var>,<var>pc</var>,<var>pc_term_options</var>,<var>pctrm</var>,<var>pf</var>,<var>pfkey</var>,<var>pfloc</var>,<var>pfx</var>,<var>pfxl</var>,<var>pk</var>,<var>pkey_key</var>,<var>pkey_local</var>,<var>pkey_plab</var>,<var>pkey_xmit</var>,<var>pl</var>,<var>plab_norm</var>,<var>pln</var>,<var>pn</var>,<var>po</var>,<var>pO</var>,<var>porder</var>,<var>print_rate</var>,<var>print_screen</var>,<var>prot</var>,<var>prtr_non</var>,<var>prtr_off</var>,<var>prtr_on</var>,<var>prtr_silent</var>,<var>ps</var>,<var>pt</var>,<var>PU</var>,<var>pulse</var>,<var>px</var>,<var>QD</var>,<var>qdial</var>,<var>quick_dial</var>,<var>r1</var>,<var>r2</var>,<var>r3</var>,<var>RA</var>,<var>rbim</var>,<var>rc</var>,<var>RC</var>,<var>rcsd</var>,<var>remove_clock</var>,<var>rep</var>,<var>repeat_char</var>,<var>req_for_input</var>,<var>req_mouse_pos</var>,<var>reqmp</var>,<var>reset_1string</var>,<var>reset_2string</var>,<var>reset_3string</var>,<var>reset_file</var>,<var>restore_cursor</var>,<var>return_does_clr_eol</var>,<var>rev</var>,<var>rf</var>,<var>RF</var>,<var>rfi</var>,<var>ri</var>,<var>RI</var>,<var>rin</var>,<var>ritm</var>,<var>rlm</var>,<var>rmacs</var>,<var>rmam</var>,<var>rmclk</var>,<var>rmcup</var>,<var>rmdc</var>,<var>rmicm</var>,<var>rmir</var>,<var>rmkx</var>,<var>rmln</var>,<var>rmm</var>,<var>rmp</var>,<var>rmpch</var>,<var>rmsc</var>,<var>rmso</var>,<var>rmul</var>,<var>rmxon</var>,<var>row_address</var>,<var>row_addr_glitch</var>,<var>rp</var>,<var>rP</var>,<var>RQ</var>,<var>rs</var>,<var>rs1</var>,<var>rs2</var>,<var>rs3</var>,<var>rshm</var>,<var>rsubm</var>,<var>rsupm</var>,<var>rum</var>,<var>rvert</var>,<var>rwidm</var>,<var>RX</var>,<var>s0</var>,<var>s0ds</var>,<var>s1</var>,<var>S1</var>,<var>s1ds</var>,<var>s2</var>,<var>S2</var>,<var>s2ds</var>,<var>s3</var>,<var>S3</var>,<var>s3ds</var>,<var>S4</var>,<var>S5</var>,<var>S6</var>,<var>S7</var>,<var>S8</var>,<var>sa</var>,<var>sA</var>,<var>SA</var>,<var>sam</var>,<var>save_cursor</var>,<var>Sb</var>,<var>sbim</var>,<var>sc</var>,<var>SC</var>,<var>scancode_escape</var>,<var>scesa</var>,<var>scesc</var>,<var>sclk</var>,<var>scp</var>,<var>scroll_forward</var>,<var>scroll_reverse</var>,<var>scs</var>,<var>scsd</var>,<var>sdrfq</var>,<var>se</var>,<var>select_char_set</var>,<var>semi_auto_right_margin</var>,<var>set0_des_seq</var>,<var>set1_des_seq</var>,<var>set2_des_seq</var>,<var>set3_des_seq</var>,<var>set_a_attributes</var>,<var>setab</var>,<var>set_a_background</var>,<var>setaf</var>,<var>set_a_foreground</var>,<var>set_attributes</var>,<var>setb</var>,<var>set_background</var>,<var>set_bottom_margin</var>,<var>set_bottom_margin_parm</var>,<var>set_clock</var>,<var>setcolor</var>,<var>set_color_band</var>,<var>set_color_pair</var>,<var>setf</var>,<var>set_foreground</var>,<var>set_left_margin</var>,<var>set_left_margin_parm</var>,<var>set_lr_margin</var>,<var>set_page_length</var>,<var>set_pglen_inch</var>,<var>set_right_margin</var>,<var>set_right_margin_parm</var>,<var>set_tab</var>,<var>set_tb_margin</var>,<var>set_top_margin</var>,<var>set_top_margin_parm</var>,<var>set_window</var>,<var>sf</var>,<var>Sf</var>,<var>SF</var>,<var>sg</var>,<var>sgr</var>,<var>sgr0</var>,<var>sgr1</var>,<var>sitm</var>,<var>sL</var>,<var>slength</var>,<var>slines</var>,<var>slm</var>,<var>smacs</var>,<var>smam</var>,<var>smcup</var>,<var>smdc</var>,<var>smgb</var>,<var>smgbp</var>,<var>smgl</var>,<var>smglp</var>,<var>smglr</var>,<var>smgr</var>,<var>smgrp</var>,<var>smgt</var>,<var>smgtb</var>,<var>smgtp</var>,<var>smicm</var>,<var>smir</var>,<var>smkx</var>,<var>smln</var>,<var>smm</var>,<var>smpch</var>,<var>smsc</var>,<var>smso</var>,<var>smul</var>,<var>smxon</var>,<var>snlq</var>,<var>snrmq</var>,<var>so</var>,<var>sp</var>,<var>spinh</var>,<var>spinv</var>,<var>sr</var>,<var>SR</var>,<var>sshm</var>,<var>ssubm</var>,<var>ssupm</var>,<var>st</var>,<var>start_bit_image</var>,<var>start_char_set_def</var>,<var>status_line_esc_ok</var>,<var>stop_bit_image</var>,<var>stop_char_set_def</var>,<var>subcs</var>,<var>subscript_characters</var>,<var>sum</var>,<var>supcs</var>,<var>superscript_characters</var>,<var>swidm</var>,<var>SX</var>,<var>ta</var>,<var>tab</var>,<var>tbc</var>,<var>te</var>,<var>termcap_init2</var>,<var>termcap_reset</var>,<var>these_cause_cr</var>,<var>ti</var>,<var>tilde_glitch</var>,<var>TO</var>,<var>tone</var>,<var>topl</var>,<var>to_status_line</var>,<var>transparent_underline</var>,<var>ts</var>,<var>tsl</var>,<var>u0</var>,<var>u1</var>,<var>u2</var>,<var>u3</var>,<var>u4</var>,<var>u5</var>,<var>u6</var>,<var>u7</var>,<var>u8</var>,<var>u9</var>,<var>uc</var>,<var>ue</var>,<var>ug</var>,<var>ul</var>,<var>underline_char</var>,<var>up</var>,<var>UP</var>,<var>up_half_line</var>,<var>us</var>,<var>user0</var>,<var>user1</var>,<var>user2</var>,<var>user3</var>,<var>user4</var>,<var>user5</var>,<var>user6</var>,<var>user7</var>,<var>user8</var>,<var>user9</var>,<var>ut</var>,<var>vb</var>,<var>ve</var>,<var>vi</var>,<var>virtual_terminal</var>,<var>vpa</var>,<var>vs</var>,<var>vt</var>,<var>WA</var>,<var>wait</var>,<var>wait_tone</var>,<var>WG</va
r>,<var>wi</var>,<var>widcs</var>,<var>wide_char_size</var>,<var>width_status_line</var>,<var>wind</var>,<var>wingo</var>,<var>wnum</var>,<var>ws</var>,<var>wsl</var>,<var>xb</var>,<var>xenl</var>,<var>XF</var>,<var>Xh</var>,<var>xhp</var>,<var>xhpa</var>,<var>xl</var>,<var>Xl</var>,<var>xmc</var>,<var>xn</var>,<var>XN</var>,<var>xo</var>,<var>Xo</var>,<var>xoffc</var>,<var>xoff_character</var>,<var>xon</var>,<var>xonc</var>,<var>xon_character</var>,<var>xon_xoff</var>,<var>xr</var>,<var>Xr</var>,<var>xs</var>,<var>xsb</var>,<var>xt</var>,<var>Xt</var>,<var>Xv</var>,<var>xvpa</var>,<var>Xy</var>,<var>Ya</var>,<var>YA</var>,<var>Yb</var>,<var>YB</var>,<var>Yc</var>,<var>YC</var>,<var>Yd</var>,<var>YD</var>,<var>Ye</var>,<var>YE</var>,<var>Yf</var>,<var>YF</var>,<var>Yg</var>,<var>YG</var>,<var>Yh</var>,<var>Yi</var>,<var>Yj</var>,<var>Yk</var>,<var>Yl</var>,<var>Ym</var>,<var>Yn</var>,<var>Yo</var>,<var>Yp</var>,<var>Yv</var>,<var>Yw</var>,<var>Yx</var>,<var>Yy</var>,<var>Yz</var>,<var>YZ</var>,<var>Za</var>,<var>ZA</var>,<var>Zb</var>,<var>ZB</var>,<var>Zc</var>,<var>ZC</var>,<var>Zd</var>,<var>ZD</var>,<var>Ze</var>,<var>ZE</var>,<var>zerom</var>,<var>zero_motion</var>,<var>Zf</var>,<var>ZF</var>,<var>Zg</var>,<var>ZG</var>,<var>Zh</var>,<var>ZH</var>,<var>Zi</var>,<var>ZI</var>,<var>Zj</var>,<var>ZJ</var>,<var>Zk</var>,<var>ZK</var>,<var>Zl</var>,<var>ZL</var>,<var>Zm</var>,<var>ZM</var>,<var>Zn</var>,<var>ZN</var>,<var>Zo</var>,<var>ZO</var>,<var>Zp</var>,<var>ZP</var>,<var>Zq</var>,<var>ZQ</var>,<var>Zr</var>,<var>ZR</var>,<var>Zs</var>,<var>ZS</var>,<var>Zt</var>,<var>ZT</var>,<var>Zu</var>,<var>ZU</var>,<var>Zv</var>,<var>ZV</var>,<var>Zw</var>,<var>ZW</var>,<var>Zx</var>,<var>ZX</var>,<var>Zy</var>,<var>ZY</var>,<var>Zz</var>,<var>ZZ</var></p>


<h2>TERMINAL TYPE DESCRIPTIONS SOURCE FILE</h2>
<pre>ANSI, UNIX CONSOLE, AND SPECIAL TYPES
Specials
ANSI.SYS/ISO 6429/ECMA-48 Capabilities
ANSI/ECMA-48 terminals and terminal emulators
DOS ANSI.SYS variants
ANSI console types
BeOS
Linux consoles
Mach
OSF Unix
QNX
NetBSD consoles
FreeBSD console entries
386BSD and BSD/OS Consoles
DEC VT52
DEC VT100 and compatibles
VT100 emulations
X terminal emulators
MGR
UNIX VIRTUAL TERMINALS, VIRTUAL CONSOLES, AND TELNET CLIENTS
Pilot Pro Palm-Top
COMMERCIAL WORKSTATION CONSOLES
Alpha consoles
Sun consoles
Iris consoles
NeWS consoles
NeXT consoles
Sony NEWS workstations
Common Desktop Environment
Non-Unix Consoles
COMMON TERMINAL TYPES
Altos
Hewlett-Packard (hp)
Honeywell-Bull
Lear-Siegler (adm)
Prime
Qume (qvt)
Televideo (tvi)
Visual (vi)
Wyse (wy)
Kermit terminal emulations
NON-ANSI TERMINAL EMULATIONS
Avatar
RBcomm
LCD DISPLAYS
Matrix Orbital
OLDER TERMINAL TYPES
AT&amp;amp;T (att, tty)
Ampex (Dialogue)
Ann Arbor (aa)
Applied Digital Data Systems (adds)
C. Itoh Electronics
Control Data (cdc)
Getronics
Human Designed Systems (Concept)
Contel Business Systems.
Data General (dg)
Datamedia (dm)
Falco</pre>






<p>Just something sorta cool for you to check out</p>
<pre>{
 local t=`tputm &#039;clear&#039; &#039;setaf 75&#039;` l a b f=/tmp/ps IFS=&#039; &#039;;
exec 6&lt;&gt;$f;ps L|tr -s &#039; &#039; &amp;&gt;$f;
while read -u6 l;do a=${l/% */} b=${l/* /};
figlet -rtw $((${COLUMNS} /2 )) -f big "$l";
tput sgr0;
command ps wwo pid:6,user:8,vsize:8,comm:20,$a:50 k -$a -A;cont;
done;
};</pre><p><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html"></a><a href="http://www.askapache.com/linux/zen-terminal-escape-codes.html">Terminal Escape Code Zen</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/zen-terminal-escape-codes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Windows Batch File Scripting</title>
		<link>http://www.askapache.com/windows/advanced-batch-scripting.html</link>
		<comments>http://www.askapache.com/windows/advanced-batch-scripting.html#comments</comments>
		<pubDate>Fri, 03 Sep 2010 18:14:02 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4577</guid>
		<description><![CDATA[<p><a class="IFL" href="http://www.askapache.com/windows/advanced-batch-scripting.html"><img src="http://uploads.askapache.com/2010/09/windows-batch-file-example-116x45.png" alt="Windows Batch Programming Example" title="Windows Batch Programming Example" width="116" height="45" /></a>If for some reason you need to use windows .bat batch file scripting to do some task, or you just want to learn the most universal batch programming language on Windows machines, you lucked out and found the AskApache example.  My expertise is the shell, in this article the shell is Windows <code>cmd.exe</code>.  It has some pretty advanced windows shell usage, including pipes and redirection, but it's the modular linux-like coding approach that earns this script it's "advanced" title.</p>
<pre>:SETPROMPT
set PROMPT=$_[%USERNAME%@%USERDOMAIN%]$S[$P]$_$M$G &#38;&#38; EXIT /B</pre>

<p><a class="IFL" href="http://uploads.askapache.com/2010/09/Untitled-1.png"><img src="http://uploads.askapache.com/2010/09/Untitled-1-116x38.png" alt="Create an AT job to run as system in Notepad++ IDE" title="Create an AT job to run as system in Notepad++ IDE" width="116" height="38" class="size-thumbnail wp-image-4618" /></a>My favorite tool (and I've tried sooo many) for editing most Windows files and especially .bat files is the free and open-source <a href="http://notepad-plus-plus.org/">Notepad++</a>.  Set that up and you will have a color-syntax-highlighted editor for Batch Scripting that works very very well.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/windows/advanced-batch-scripting.html"></a><a href="http://www.askapache.com/windows/advanced-batch-scripting.html"><cite>AskApache.com</cite></a></p><p><a href="http://www.askapache.com/windows/advanced-batch-scripting.html/untitled-1/" rel="attachment wp-att-4618"><img src="http://uploads.askapache.com/2010/09/Untitled-1.png" alt="Create an AT job to run as system in Notepad++ IDE" title="Create an AT job to run as system in Notepad++ IDE" width="993" height="326" class="size-full wp-image-4618" /></a></p>
<p><a class="IFL" href="http://uploads.askapache.com/2010/09/windows-batch-file-example.png"><img src="http://uploads.askapache.com/2010/09/windows-batch-file-example-116x45.png" alt="Windows Batch Programming Example" title="Windows Batch Programming Example" width="116" height="45" /></a>First off, this is a single windows <code>.bat</code> file that I have written to do advanced batch scripting the easy way, meaning it's mostly a series of functions you can call from the script or within other functions for extremely modular code.  Before you get all bent out of shape by my choice of words ("easy, modular"), when I say this is advanced I mean for Windows .bat files, one of the worlds worst scripting languages, but it works on all windows versions so it's ideal for things like autorun, autoplay, custom startups, usb drives, etc..  If you are looking for information on how to use and program windows .bat files to do anything cool, this is the right place!  I tried my best to mimic linux shell-scripting, so it's likely different than other batch files you have seen.<br class="C" /></p>



<h2>Batch File IDE and Script Source</h2>
<p><a class="IFL" href="http://uploads.askapache.com/2010/09/Untitled-1.png"><img src="http://uploads.askapache.com/2010/09/Untitled-1-116x38.png" alt="Create an AT job to run as system in Notepad++ IDE" title="Create an AT job to run as system in Notepad++ IDE" width="116" height="38" class="size-thumbnail wp-image-4618" /></a>My favorite tool (and I've tried sooo many) for editing most Windows files and especially .bat files is the free and open-source <a href="http://notepad-plus-plus.org/">Notepad++</a>.  Set that up and you will have a color-syntax-highlighted editor for Batch Scripting that works very very well.<br class="C" /></p>
<p><a class="IFL" href='http://uploads.askapache.com/2010/09/advanced-batch-askapache.txt'><img src="http://uploads.askapache.com/2010/09/windows-batch-file.png" width="46" height="60" title="windows batch file windows" alt="Advanced Windows Batch File Scripting" /></a>The next thing to do is <a href='http://uploads.askapache.com/2010/09/advanced-batch-askapache.txt'>download the source code</a>, which includes comments and formatting I had to remove for this online article.  Then rename from <code>.txt</code> to <code>.bat</code> and open in your IDE/text-editor of choice.<br class="C" /></p>


<h2>Quick Batch File Example</h2>
<p>This is a simple batch file named ping-check.bat that I use when rebooting remote servers.  The reboot is issued from an SSH session and causes the server to go down and then come back up.  When the server goes down the network goes down too so I fire this script up to continually ping the remote server until it responds, at which point I can ssh back in.</p>
<p>One of the first hacks for batch files is line 1, the PUSHD command cd's the scripts working environment to the directory of the script itself.</p>
<pre>@ECHO OFF &amp;&amp; PUSHD "%~dp0" &amp;&amp; SETLOCAL
&nbsp;
CALL :PINGCHECK "%~1"
&nbsp;
nircmd.exe speak text "PING RECEIVED.  HOST BACK ONLINE" 7 60
ENDLOCAL &amp;&amp; POPD &amp;&amp; GOTO :EOF
&nbsp;
:PINGCHECK
ECHO CHECKING %~1
ping.exe -n 1 %~1 -w 5000 | FIND /C "Reply from %~1" | FIND "1" &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 CALL :PINGCHECK "%~1" ELSE EXIT /B</pre>


<h2>Super-hero like even</h2>
<p>Just added this as an after thought, moving the main example further down this page.  This is an easier file to understand the scope of.  It effectively creates SSH-encrypted SOCK5 tunnels that stay connected and auto-reconnect if the link goes down.  I wanted to try and write a pure batch method to do that.   I wrote this to run automatically from a USB key so that I could keep my tools with me portably.  The thing of this script that is the most revolutionary is the method it uses to create auto-reconnecting <em>SSH-encrypted SOCKS5 tunnels</em> using the windows SYSTEM account to do it all in the background with plink.exe.  The hack to run it as a system account is by using the built-in <strong>AT</strong> command to run interactively, which lets you interactively do whatever you want as the builtin <code>NT AUTHORITY/SYSTEM</code> account.  The other part I am proud of with this is how lean I got the code, specifically how lean the function is that creates the at job to run every 5 minutes, while still doing connection-testing, all by parsing the cmd.exe processors builtin in DATE and TIME variables.  Do a google search for "windows batch file date and time" and you will appreciate just how lean this sucker is.</p>
<p>Almost forgot, check out the ways to keep a plink.exe (putty.exe for cmd.exe) SOCKS5 tunnel hidden and safe and continuously connected to a remote server in minimal lines od code.  This was a fun one to work on!  Enjoy (and remember this is just the warm-up example to glance at).</p>
<pre>@ECHO OFF &amp;&amp; PUSHD "%~dp0" &amp;&amp; SETLOCAL &amp;&amp; SETLOCAL ENABLEDELAYEDEXPANSION &amp;&amp; SETLOCAL ENABLEEXTENSIONS
&nbsp;
SET _CRYPTDRIVE=%~d0\
SET PATH=%_CRYPTDRIVE%PP;%_CRYPTDRIVE%PP\bin;%PATH%
SET _PUTTYBIN=%_CRYPTDRIVE%P\PP\putty.exe
&nbsp;
SET _PSERVER=solar.power.com
SET _PPORT=22
SET _PSESSION=newclean-tunnel
&nbsp;
SET _ADMINUSER=admin
SET _RUNUSER=life
&nbsp;
REM SAY CHECKING PLINK OUT LOUD
CALL :SPEAK "Checking Putty"
ECHO "CHECKING PUTTY"
&nbsp;
REM
IF NOT EXIST "%_CRYPTDRIVE%" (
  CALL :SPEAK "Crypt Not Mounted"
  AT|FOR /F "tokens=1" %%i IN (&#039;FIND /I "%~f0"&#039;) DO AT %%i /delete /yes &gt;nul 2&gt;&amp;1
  pskill.exe -t putty &gt;nul 2&gt;&amp;1
  pskill.exe -t thunderbird &gt;nul 2&gt;&amp;1
  pskill.exe -t ThunderbirdPortable &gt;nul 2&gt;&amp;1
  pskill.exe -t Firefox &gt;nul 2&gt;&amp;1
  pskill.exe -t FirefoxPortable &gt;nul 2&gt;&amp;1
  pskill.exe -t GC &gt;nul 2&gt;&amp;1
  EXIT
)
&nbsp;
REM CREATE AT JOB TO RUN THIS SCRIPT EVERY 5 MINUTES
CALL :CREATEATJOB
&nbsp;
pslist putty &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 psexec.exe -i 0 -e -d -u %_RUNUSER% %_PUTTYBIN% -load %_PSESSION%
&nbsp;
REM KILL MULTIPLE PSEXEC&#039;s
CALL :KILLDUPES "psexec.exe"
&nbsp;
REM KILL MULTIPLE CMD.EXE&#039;s
CALL :KILLDUPES "cmd.exe"
&nbsp;
REM REACHABLE SERVER CHECK
CALL :PINGCHECK %_PSERVER%
&nbsp;
REM CHECK FOR INACTIVE PUTTY
CALL :PUTTYCHECK
&nbsp;
REM CHECK PORT IS LISTENING (FOR SOCKISFIED TUNNEL)
CALL :PORTCHECK %_PPORT%
&nbsp;
REM CALL :SPEAK "OK"
SLEEP 100 &amp;&amp; ECHO "OK" &amp;&amp; SLEEP 1 &amp;&amp; ENDLOCAL &amp;&amp; POPD &amp;&amp; EXIT
&nbsp;
REM =======================================================================================
REM =   SPEAK - Speak text
REM =======================================================================================
:SPEAK
nircmd.exe speak text "%~1" 5 60
ECHO "%~1"
EXIT /B
&nbsp;
REM =======================================================================================
REM =   RESTARTPLINK - Sleeps for %1 number of seconds
REM =======================================================================================
:RESTARTPLINK
CALL :SPEAK "%~1 ReSTARTing Plink"
REM runas /savecred /user:admin "%_PUTTYBIN% -load %_PSESSION%"
psexec.exe -i 0 -e -d -u %_RUNUSER% %_PUTTYBIN% -load %_PSESSION%
EXIT
EXIT /B
&nbsp;
REM =======================================================================================
REM =   PORTCHECK - Check that Port is being used (for tunnels)
REM =======================================================================================
:PORTCHECK
netstat.exe -n -v -a -p TCP | FIND "ESTABLISHED" | FIND ":%~1" &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 CALL :RESTARTPLINK "PORT CHECK FAILED"
EXIT /B
&nbsp;
REM =======================================================================================
REM =   INACTIVEPUTTYCHECK - Check for inactive putty windows
REM =======================================================================================
:PUTTYCHECK
tasklist.exe /V /NH /FI "WINDOWTITLE eq PuTTY (inactive)" 2&gt;nul|FIND "INFO: " &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 taskkill.exe /T /F /FI "WINDOWTITLE eq PuTTY (inactive)" &gt;nul 2&gt;&amp;1
&nbsp;
:: MAKE SURE ONLY 1 putty is running that is connected to the remote server
netstat.exe -n -a -o -p TCP | FIND ":%_PPORT%" | FIND /C ":%_PPORT%" | FIND "1" &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 (
  tasklist.exe /V /FO TABLE /NH /FI "IMAGENAME eq putty.exe" 2&gt;nul | FIND /C "Running" | FIND "1" &gt;nul 2&gt;&amp;1
  IF ERRORLEVEL 1 (
    REM kill all running puttys (owned by system)
    FOR /F "usebackq tokens=2 skip=2" %%p IN (`tasklist.exe /V /FO TABLE /NH /FI "IMAGENAME eq putty.exe"`) DO taskkill.exe /F /PID %%p /T &gt;nul 2&gt;&amp;1
    CALL :RESTARTPLINK "EXTRA PUTTY FOUND"
  )
)
EXIT /B
&nbsp;
REM =======================================================================================
REM =   PINGCHECK - PING address to make sure it is reachable
REM =======================================================================================
:PINGCHECK
PING %~1 -n 1 -w 5000 | FIND "TTL=" &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 (
  PING google.com -n 1 -w 500 | FIND "TTL=" &gt;nul 2&gt;&amp;1
  IF ERRORLEVEL 1 ( CALL :SPEAK "CHECK INTERNET CONNECTION" &amp;&amp; SLEEP 60 )
&nbsp;
  PING google.com -n 1 -w 5000 | FIND "TTL=" &gt;nul 2&gt;&amp;1
  IF ERRORLEVEL 1 ( CALL :SPEAK "CHECK INTERNET CONNECTION" &amp;&amp; SLEEP 60 )
&nbsp;
  PING google.com -n 1 -w 5000 | FIND "TTL=" &gt;nul 2&gt;&amp;1
  IF ERRORLEVEL 1 (
    CALL :SPEAK "KILL SOCKS PROGRAMS"
  SLEEP 100
  pskill.exe -t putty &gt;nul 2&gt;&amp;1
  pskill.exe -t thunderbird &gt;nul 2&gt;&amp;1
  pskill.exe -t ThunderbirdPortable &gt;nul 2&gt;&amp;1
  )
)
EXIT /B
&nbsp;
REM =======================================================================================
REM =   KILLDUPES - kills duplicate processes, except for the one with lowest pid
REM =======================================================================================
:KILLDUPES
REM Check that more than 1 process is running
tasklist.exe /V /NH /FI "IMAGENAME eq %~1" /FI "USERNAME eq SYSTEM" 2&gt;nul | FIND /C "K Running" | FIND "1" &gt;nul 2&gt;&amp;1
IF NOT ERRORLEVEL 1 EXIT /B
&nbsp;
REM Create Filename in current dir (of this script)
SET _T=%TIME: =0%&amp;&amp;SET _T=!_T::=-!&amp;&amp;SET _T=%~dp0%!_T:~0,-2!log
&nbsp;
REM Create the file in the same dir as this script named for date and sorted by PID
tasklist.exe /V /NH /FI "IMAGENAME eq %~1" /FI "USERNAME eq SYSTEM" 2&gt;nul | SORT /+29 &gt; "%_T%"
&nbsp;
REM Check that the file was created or exit
IF NOT EXIST "%_T%" ( CALL :SPEAK "FILE CREATION FAILED" &amp;&amp; EXIT /B )
&nbsp;
REM kill all the processes found except for 1, do not kill the process with the lowest pid number
FOR /F "tokens=2 skip=2" %%p IN (%_T%) DO taskkill.exe /F /PID %%p /T
&nbsp;
REM erase the file
REM ERASE /Q "%_T%" &gt;nul 2&gt;&amp;1
&nbsp;
REM check that the file was erased
REM IF EXIST "%_T%" ( CALL :SPEAK "ERASE FILE FAILED" &amp;&amp; EXIT /B )
&nbsp;
EXIT /B
&nbsp;
REM =======================================================================================
REM =   CREATEATJOB - runs job (START this file) every 5 minutes
REM =======================================================================================
:CREATEATJOB
:: delete all putty AT jobs
AT | FIND /C "%~f0" | FIND "1" &gt;nul 2&gt;&amp;1
IF ERRORLEVEL 1 ( AT|FOR /F "tokens=1" %%i IN (&#039;FIND /I "%~f0"&#039;) DO AT %%i /delete /yes &gt;nul 2&gt;&amp;1 )
SET /A H=!TIME:~0,2!&amp;&amp; SET M=!TIME:~3,2!
SET Y=%H%:%M%&amp;&amp; SET /A M+=5
IF !M! GEQ 61 ( SET /A H+=1&amp;&amp;SET /A M-=61 )
IF !H! GEQ 24 SET /A H-=24
SET M=0!M!&amp;&amp; SET H=0!H!
:: create AT job
AT %H:~-2%:%M:~-2% /INTERACTIVE %ComSpec% /E:ON /D /Q /C START /B /MIN %ComSpec% /E:ON /D /Q /C "%~f0" &gt;nul
EXIT /B</pre>







<h2>Advanced Batch File</h2>
<p>This is the main batch file example which you can <a href="http://uploads.askapache.com/2010/09/advanced-batch-askapache.txt">download here</a>.  Other than some minor changes this is the actual script I use at work when I logon to my PC.  The first thing it does is mount an encrypted TrueCrypt Drive where all of my files and settings are located.  It also starts a putty session named "1" that I configured to start a few encrypted tunnels and socks proxies so that my email Thunderbird and Website IDE Dreamweaver and other network apps can communicate 100% encrypted and my real location becomes hidden (thanks socks!).</p>
<p>I might come back later and add comments if I get any kind of response for this article, and because it's such a unique and low-traffic topic, I will try to answer any questions added with the comment form.</p>


<h2>Starting the Script</h2>
<p>The first line is of my own design and is perhaps the coolest hack in the script.  I use this 1 line to start pretty much all of my .bat files.</p>
<pre>@ECHO OFF&amp;&amp; SETLOCAL&amp;&amp; PUSHD "%~dp0"&amp;&amp; SETLOCAL ENABLEDELAYEDEXPANSION&amp;&amp; SETLOCAL ENABLEEXTENSIONS&amp;&amp; SET V=5&amp;&amp; IF NOT "!V!"=="5" (ECHO DelayedExpansion Failed&amp;&amp; GOTO :EOF)</pre>


<h2>SCRIPT VARIABLES</h2>
<p>These are all local to this script thanks to the SETLOCAL above, so they won't exist outside the scripts execution environment.</p>
<pre>REM ** Various vars for output used by functions
SET P1=^^^&gt;^^^&gt;^^^&gt;
SET P2=++
SET P3=::
SET L1=+==============================================================================================================+
SET L2=+--------------------------------------------------------------------------------------------------------------+
&nbsp;
REM ** administrator username, unless changed for more security, its Administrator
SET ADMINUSER=admin
&nbsp;
REM ** runuser is the username you use when running this script
SET RUNUSER=bill
&nbsp;
REM ** Custom COMSPEC for running cmd.exe
SET _SCOM=%COMSPEC% /E:ON /F:ON /D /Q /T:0C /C
&nbsp;
REM ** Custom START command
SET _START=START /WAIT /MIN /B %_SCOM%</pre>




<h2>MAIN PROGRAM EXECUTION</h2>
<p>This is where the main code starts, note how small it is thanks to the use of functions (labels/call/goto).  Read the comments in this area (start with :: or REM ) to see the extent of this script.  The gold is in the functions.</p>
<pre>:: Only allow certain users to run this script or die (prevents global STARTup or service running it)
CALL :CHECKUSERVALID %RUNUSER% %ADMINUSER%
&nbsp;
:: Mount the truecrypt container
CALL :CRYPTMOUNT "L" "%SYSTEMDRIVE%\CRYPT\LEONARDO" "%SYSTEMDRIVE%\CRYPT\LEONARDO_KEY"
&nbsp;
:: Start Mozilla Firefox
CALL :RUNONE "C:\Program Files\Mozilla Firefox\firefox.exe"
&nbsp;
:: Start Thunderbird Portable
CALL :RUNONE "L:\P\PP\putty.exe" "/MIN" -load 1
&nbsp;
:: Start Thunderbird Portable
CALL :RUNONE "L:\P\TB\ThunderbirdPortable.exe" "/MIN"
&nbsp;
:: Start Adobe Dreamweaver CS4
CALL :RUNONE "C:\Program Files\Adobe\Adobe Dreamweaver CS4\Dreamweaver.exe" "/MIN"
&nbsp;
:: Start LightScreen Portable
CALL :RUNONE "L:\P\LP\LightscreenPortable.exe" /B /B
&nbsp;
:: Start Google Chrome Portable ( GREAT to use for pandora/last.fm as its so low mem )
CALL :RUNONE "L:\P\GC\GC.exe" "/NORMAL"
&nbsp;
:: Start Adobe Photoshop CS4
CALL :RUNONE "%ProgramFiles%\Adobe\Adobe Photoshop CS4\Photoshop.exe" "/MAX"</pre>

<h3>Exit Script</h3>
<p>This is the last line executed in the Main, it forces the script to exit cleanly at this point, otherwise the functions below would all get executed.  This is what allows the use of all the functions below.  I end all my scripts MAIN with this.</p>
<pre>REM ** EXIT Script
CALL :MDYE "EOF" &amp;&amp; POPD &amp;&amp; ENDLOCAL &amp;&amp; GOTO :EOF</pre>







<h2>SCRIPT FUNCTIONS</h2>
<p>Now then, onto the MEAT of the script, all the functions.  These functions are designed for global use in other batch files, so that the only modification when you make a new batch is the above variables and main execution..  If you know much about batch files you will realize that creating these functions was a very painful process in some cases.. I freakin hate windows!  Anyway, enjoy!</p>
<h3>CRYPTMOUNT - mounts a truecrypt container and returns to CALLer. On fail, quit</h3>
<pre>REM
REM     CALL :CRYPTMOUNT "%LEONARDO%" "%LEONARDO_FILE%" "%LEONARDO_KEY%"
REM     CALL :CRYPTMOUNT "L" "%SYSTEMDRIVE%\CRYPT\LEONARDO" "%SYSTEMDRIVE%\CRYPT\LEONARDO_KEY"
REM
REM :: print the settings
REM :: CALL :MP 3 "DRIVE: %DRIVE%"&amp;&amp;CALL :MP 3 " FILE: %FILE%"&amp;&amp;CALL :MP 3 "  KEY: %KEY%"&amp;&amp;CALL :MP 3 "  VOL: %VOL%"</pre>
<pre>:CRYPTMOUNT
SET DRIVE=%~1&amp;&amp; SET FILE=%~2&amp;&amp; SET KEY=%~3&amp;&amp; SET VOL=!FILE:~0,3!
CALL :MP 1 "Mounting TrueCrypt on %DRIVE% from %FILE%"
&nbsp;
:: Check for Truecrypt or die
CALL :EXISTORQUIT "%ProgramFiles%\TrueCrypt\TrueCrypt.exe" &amp;&amp; CALL :EXISTORQUIT "%FILE%" &amp;&amp; CALL :EXISTORQUIT "%KEY%"
&nbsp;
:: checks that MOUNTVOL works and the drive containing the truecrypt container file is present or dies
MOUNTVOL %VOL% /L 2&gt;NUL | FIND "\\?\Volume{" &gt;NUL 2&gt;&amp;1
IF ERRORLEVEL 1 CALL :MDYE "%VOL% NOT FOUND"
&nbsp;
REM ** Converts G:\ to its \\?\Volume{234234}\ equivalent for greater portability
FOR /F %%i IN (&#039;MOUNTVOL %VOL% /L&#039;) DO @SET VOL=%%i%FILE:~3%
&nbsp;
:: IF the drive is already mounted then continue, otherwise try to mount
MOUNTVOL %DRIVE%:\ /L &gt;NUL 2&gt;&amp;1
IF NOT ERRORLEVEL 1 (
  CALL :MP 2 "%DRIVE% ALREADY MOUNTED" &amp;&amp; EXIT /B
) ELSE (
  START "Mounting TrueCrypt" /D"%ProgramFiles%\TrueCrypt" /MIN /B TrueCrypt.exe /c n /b /q background /h n /k %KEY% /l %DRIVE% /p /v %VOL% &amp;&amp; SLEEP 10
)
&nbsp;
:: try again in case of bad password and accidental keypress
MOUNTVOL %DRIVE%:\ /L &gt;NUL 2&gt;&amp;1
IF ERRORLEVEL 1 (START "Mounting TrueCrypt" /D"%ProgramFiles%\TrueCrypt" /MIN /B TrueCrypt.exe /c n /b /q background /h n /k %KEY% /l %DRIVE% /p /v %VOL% &amp;&amp; SLEEP 10)
&nbsp;
:: IF it still doesnt exist then quit
MOUNTVOL %DRIVE%:\ /L &gt;NUL 2&gt;&amp;1
IF ERRORLEVEL 1 CALL :MDYE "Failed to mount %FILE% on %DRIVE%"
&nbsp;
CALL :MF &amp;&amp; ENDLOCAL &amp;&amp; EXIT /B
EXIT /B</pre>




<h3>RUNONE - Starts one instance of executable after verifying it exists and is not already running.</h3>
<pre>REM     %~1 is location of executatable
REM     %~2 is optional (unless %~3 is used) START parameters
REM     %~3 is optional parameters for executable
REM
REM     CALL :RUNONE "L:\P\LP\LightscreenPortable.exe" "/MAX" "/HIDE"</pre>
<pre>:RUNONE
SETLOCAL
CALL :MP 1 "Starting %~n1"
&nbsp;
:: SLEEP FOR NICENESS, LOCAL VARS _P2 and _P3
SLEEP 2 &amp;&amp; SETLOCAL
&nbsp;
SET P=%~1
ECHO %P%|FIND " " &gt;NUL 2&gt;&amp;1
IF NOT ERRORLEVEL 1 ( PUSHD "%~dp1" &amp;&amp; SET P=%~nx1 )
&nbsp;
:: SET _P2 TO DEFAULT TO "/MIN" IF EMPTY
SET _P2=/MIN
IF NOT " %~2" == " " SET _P2=%~2
IF NOT " %~3" == " " SET _P3=%~3
IF NOT " %~4" == " " SET _P4=%~4
&nbsp;
:: CHECK THAT EXECUTABLE EXISTS
CALL :EXISTORQUIT "%~1"
&nbsp;
REM ECHO START %_P2% /D"%~dp1" %P% %_P3% %_P4%&amp;&amp; PAUSE&amp;&amp;
:: CHECK FOR EXISTING PROCESSNAME ( %~n1 is file name without ext, %~nx1 is the file name and extension. )
pslist.exe /e %~n1 &gt;NUL 2&gt;&amp;1
IF ERRORLEVEL 1 (START %_P2% /D"%~dp1" %P% %_P3% %_P4% ) ELSE (CALL :MP 2 "%~n1 already running!" )
&nbsp;
ENDLOCAL &amp;&amp; EXIT /B</pre>







<h3>ADMINRUNONE - Runs %1 with admin rights IF neccessary</h3>
<pre>:ADMINRUNONE
CALL :MP 3 "Exec %~1 as %ADMINUSER%"
&nbsp;
:: Check that file exists
CALL :EXISTORQUIT "%~1"
&nbsp;
:: test for rights to the task scheduler
:: %SYSTEMDRIVE%\WINDOWS\system32\cmd.exe /E:ON /D /Q /T:0C /C START /WAIT /MIN /B %SYSTEMDRIVE%\WINDOWS\system32\cmd.exe /E:ON /D /Q /T:0C /C %~1
AT &gt;NUL 2&gt;&amp;1
IF ERRORLEVEL 1 (
  RUNAS /noprofile /user:%USERDOMAIN%\%ADMINUSER% "%~1"
) ELSE (
  %COMSPEC% /E:ON /D /Q /T:0C /C "%~1"
)
SLEEP 2 &amp;&amp; CALL :MF &amp;&amp; EXIT /B</pre>






<h3>CHECKUSERVALID - checks that defined username equals %ADMINUSER% or %RUNUSER%, then returns to CALLer</h3>
<pre>:CHECKUSERVALID
:: EXIT IF USERNAME IS NOT DEFINED, CATCHES SYSTEM ACCOUNTS TRYING TO RUN WHEN IN GLOBAL STARTUP
IF NOT DEFINED USERNAME EXIT
&nbsp;
SETLOCAL
SET UP=no
SET _P1= %~1
SET _P2= %~2
IF NOT "%_P1%" == " " ( IF /I "%~1" == "%USERNAME%" SET UP=yes)
IF NOT "%_P1%" == " " ( IF /I "%~1" == "%USERNAME%" SET UP=yes)
IF NOT "%_P1%" == " " ( IF /I "%~1" == "%USERNAME%" SET UP=yes)
IF /I "bill" == "%USERNAME%" SET UP=yes
IF /I "newbill" == "%USERNAME%" SET UP=yes
IF /I "max" == "%USERNAME%" SET UP=yes
IF /I NOT "%UP%" == "yes" EXIT
ENDLOCAL
EXIT /B</pre>



<h3>SETPROMPT - sets prompt, then returns to CALLer</h3>
<pre>REM =   [user@MACHINE] [C:\DR\PEPPER\SCRIPTS]
REM =   &gt; REG /?</pre>
<pre>:SETPROMPT
set PROMPT=$_[%USERNAME%@%USERDOMAIN%]$S[$P]$_$M$G &amp;&amp; EXIT /B</pre>


<h3>BEEP - beeps once, then returns to CALLer</h3>
<p>The character after the echo is the actual BEL char, so unless you have my source file, you will need to copy a literal BEL char here to make it beep.</p>
<pre>:BEEP
@ECHO # &amp;&amp; EXIT /B</pre>


<h3>MSETCOLOR - SET colors for screen, then returns to CALLer</h3>
<pre>REM
REM     0 = Black       8 = Gray
REM     1 = Blue        9 = Light Blue
REM     2 = Green       A = Light Green
REM     3 = Aqua        B = Light Aqua
REM     4 = Red         C = Light Red
REM     5 = Purple      D = Light Purple
REM     6 = Yellow      E = Light Yellow
REM     7 = White       F = Bright White
REM</pre>
<pre>:MSETCOLOR
COLOR %~1 &amp;&amp; EXIT /B</pre>


<h3>MSETCONSOLE - sets the cols and lines of current screen buffer, then returns to CALLer</h3>
<pre>:MSETCONSOLE
MODE CON COLS=%~1 LINES=%~2 &amp;&amp; EXIT /B</pre>



<h3>PARAMTEST - tests params, then returns to CALLer</h3>
<pre>:PARAMTEST
ECHO. &amp;&amp; CALL :MP 1 "PARAMTEST CALLED WITH: %*" &amp;&amp; ECHO %L1%
SET _P= %~1
IF NOT "%_P%" == " " ( ECHO %%1          = %1 &amp;&amp; ECHO %%~f1        = %~f1 &amp;&amp; ECHO %%~d1        = %~d1 &amp;&amp; ECHO %%~p1        = %~p1
  ECHO %%~n1        = %~n1 &amp;&amp; ECHO %%~x1        = %~x1 &amp;&amp; ECHO %%~s1        = %~s1 &amp;&amp; ECHO %%~dp1       = %~dp1
  ECHO %%~nx1       = %~nx1 &amp;&amp; ECHO %%~$PATH:1   = %~$PATH:1 &amp;&amp; ECHO %%~dp$PATH:1 = %~dp$PATH:1 &amp;&amp; ECHO %L1% )
SET _P= %~2
IF NOT "%_P%" == " " ( ECHO %%2          = %2 &amp;&amp; ECHO %%~f2        = %~f2 &amp;&amp; ECHO %%~d2        = %~d2 &amp;&amp; ECHO %%~p2        = %~p2
  ECHO %%~n2        = %~n2 &amp;&amp; ECHO %%~x2        = %~x2 &amp;&amp; ECHO %%~s2        = %~s2 &amp;&amp; ECHO %%~dp2       = %~dp2
  ECHO %%~nx2       = %~nx2 &amp;&amp; ECHO %%~$PATH:2   = %~$PATH:2 &amp;&amp; ECHO %%~dp$PATH:2 = %~dp$PATH:2 &amp;&amp; ECHO %L1% )
SET _P= %~3
IF NOT "%_P%" == " " ( ECHO %%3          = %3 &amp;&amp; ECHO %%~f3        = %~f3 &amp;&amp; ECHO %%~d3        = %~d3 &amp;&amp; ECHO %%~p3        = %~p3
  ECHO %%~n3        = %~n3 &amp;&amp; ECHO %%~x3        = %~x3 &amp;&amp; ECHO %%~s3        = %~s3 &amp;&amp; ECHO %%~dp3       = %~dp3
  ECHO %%~nx3       = %~nx3 &amp;&amp; ECHO %%~$PATH:3   = %~$PATH:3 &amp;&amp; ECHO %%~dp$PATH:3 = %~dp$PATH:3 &amp;&amp; ECHO %L1% )
SET _P= %~4
IF NOT "%_P%" == " " ( ECHO %%4          = %4 &amp;&amp; ECHO %%~f4        = %~f4 &amp;&amp; ECHO %%~d4        = %~d4 &amp;&amp; ECHO %%~p4        = %~p4
  ECHO %%~n4        = %~n4 &amp;&amp; ECHO %%~x4        = %~x4 &amp;&amp; ECHO %%~s4        = %~s4 &amp;&amp; ECHO %%~dp4       = %~dp4
  ECHO %%~nx4       = %~nx4 &amp;&amp; ECHO %%~$PATH:4   = %~$PATH:4 &amp;&amp; ECHO %%~dp$PATH:4 = %~dp$PATH:4 &amp;&amp; ECHO %L1% )
SET _P= %~5
IF NOT "%_P%" == " " ( ECHO %%5          = %5 &amp;&amp; ECHO %%~f5        = %~f5 &amp;&amp; ECHO %%~d5        = %~d5 &amp;&amp; ECHO %%~p5        = %~p5
  ECHO %%~n5        = %~n5 &amp;&amp; ECHO %%~x5        = %~x5 &amp;&amp; ECHO %%~s5        = %~s5 &amp;&amp; ECHO %%~dp5       = %~dp5
  ECHO %%~nx5       = %~nx5 &amp;&amp; ECHO %%~$PATH:5   = %~$PATH:5 &amp;&amp; ECHO %%~dp$PATH:5 = %~dp$PATH:5 &amp;&amp; ECHO %L1% )
SET _P= %~6
IF NOT "%_P%" == " " ( ECHO %%6          = %6 &amp;&amp; ECHO %%~f6        = %~f6 &amp;&amp; ECHO %%~d6        = %~d6 &amp;&amp; ECHO %%~p6        = %~p6
  ECHO %%~n6        = %~n6 &amp;&amp; ECHO %%~x6        = %~x6 &amp;&amp; ECHO %%~s6        = %~s6 &amp;&amp; ECHO %%~dp6       = %~dp6
  ECHO %%~nx6       = %~nx6 &amp;&amp; ECHO %%~$PATH:6   = %~$PATH:6 &amp;&amp; ECHO %%~dp$PATH:6 = %~dp$PATH:6 &amp;&amp; ECHO %L1% )
SET _P= %~7
IF NOT "%_P%" == " " ( ECHO %%7          = %7 &amp;&amp; ECHO %%~f7        = %~f7 &amp;&amp; ECHO %%~d7        = %~d7 &amp;&amp; ECHO %%~p7        = %~p7
  ECHO %%~n7        = %~n7 &amp;&amp; ECHO %%~x7        = %~x7 &amp;&amp; ECHO %%~s7        = %~s7 &amp;&amp; ECHO %%~dp7       = %~dp7
  ECHO %%~nx7       = %~nx7 &amp;&amp; ECHO %%~$PATH:7   = %~$PATH:7 &amp;&amp; ECHO %%~dp$PATH:7 = %~dp$PATH:7 &amp;&amp; ECHO %L1% )
SLEEP 3
CALL :MF
EXIT /B</pre>




<h3>PARAMTESTHELP - show params help, then returns to CALLer</h3>
<pre>:PARAMTESTHELP
ECHO %%~1 Expands %%1 and removes any surrounding quotation marks
ECHO %%~f1 Expands %%1 to a fully qualified path name.
ECHO %%~d1 Expands %%1 to a drive letter.
ECHO %%~p1 Expands %%1 to a path.
ECHO %%~n1 Expands %%1 to a file name.
ECHO %%~x1 Expands %%1 to a file extension.
ECHO %%~s1 Expanded path contains short names only.
ECHO %%~a1 Expands %%1 to file attributes.
ECHO %%~t1 Expands %%1 to date and time of file.
ECHO %%~z1 Expands %%1 to size of file.
ECHO %%~dp1 Expands %%1 to a drive letter and path.
ECHO %%~nx1 Expands %%1 to a file name and extension.
ECHO %%~ftza1 Expands %%1 to a dir-like output line.
ECHO %%~$PATH:1 Searches the dirs in PATH expanding %%1 to fully qualified name of first found. If var name isn&#039;t defined or the files not found, expands to empty string.
ECHO %%~dp$PATH:1 Searches the directories listed in the PATH environment variable for %%1 and expands to the drive letter and path of the first one found.
CALL :MF
EXIT /B</pre>







<h3>EXAMINEFILE - FINDs useful strings in file, then returns to CALLer</h3>
<pre>:EXAMINEFILE
CALL :MP 1 "Examine File %~1"
CALL :EXISTORQUIT "%~1"
STRINGS "%~1" | FINDSTR /R /C:"[A-Z][A-Z]\="
CALL :MF
EXIT /B</pre>


<h3>ADMINSHELL - sets prompt, then returns to CALLer</h3>
<pre>:ADMINSHELL
CALL :MP 1 "Creating Admin Shell"
CALL :EXISTORQUIT "%SYSTEMROOT%\system32\runas.exe"
START %SYSTEMROOT%\system32\runas.exe /profile /savecred /user:%ADMINUSER% "%COMSPEC% /T:0C /E:ON /F:ON /K cmd.exe /K cd C:\CRYPT\BIN"
CALL :MF
EXIT /B</pre>


<h3>EXISTORQUIT - checks %~1 exists, IF it does returns to CALLer, otherwise, quit</h3>
<pre>:EXISTORQUIT
:: CALL :MP 1 "Checking for %~1"
IF NOT EXIST "%~1" CALL :MDYE "%~1 NOT FOUND"
EXIT /B</pre>


<h3>RR - IF file %1 EXISTs then :MT "Removing %1" then :MF, then ( or IF %1 not EXISTs)  returns to CALLer</h3>
<pre>:RR
CALL :MP 1 "Removing %~1"
IF EXIST "%~1" ERASE /q "%~1"
CALL :MF &amp;&amp; EXIT /B</pre>








<h3>LOCKDOWN  - locks workstation, then returns to CALLer (pointless)</h3>
<pre>:LOCKDOWN
RUNDLL32 USER32.DLL,LockWorkStation &amp;&amp; EXIT /B</pre>



<h3>SHUTDOWNIN - initiates shutdown, then returns to CALLer (pointless)</h3>
<pre>REM shutdown /a aborts</pre>
<pre>:SHUTDOWNIN
SHUTDOWN -r -t "%~1" &amp;&amp; EXIT /B</pre>



<h3>LISTSERVICES - lists services, then returns to CALLer</h3>
<pre>:LISTSERVICES
SC query state= all type= all | FOR /F "tokens=2" %%i IN (&#039;FIND /I "SERVICE_NAME"&#039;) DO @ECHO %%i
SC query | FOR /F "tokens=2" %%i IN (&#039;FIND /I "SERVICE_NAME"&#039;) DO @ECHO %%i
EXIT /B</pre>




<h3>TASKS - Advanced Tasklisting</h3>
<pre>:TASKS
SET _P=%~1
SET _PP= %~1
IF "%_PP%" == " " EXIT /B
&nbsp;
REM SORTABLES
IF /I "%_P%" == "pid" ( tasklist.exe /V /NH | SORT /+29 &amp;&amp; EXIT /B )
IF /I "%_P%" == "size" ( tasklist.exe /V /NH | SORT /+59 &amp;&amp; EXIT /B )
IF /I "%_P%" == "user" ( tasklist.exe /V /NH | SORT /+89 &amp;&amp; EXIT /B )
IF /I "%_P%" == "time" ( tasklist.exe /V /NH | SORT /+138 &amp;&amp; EXIT /B )
IF /I "%_P%" == "window" ( tasklist.exe /V /NH | SORT /+152 &amp;&amp; EXIT /B )
&nbsp;
REM FILTERS
IF /I "%_P%" == "image" ( tasklist.exe /V /NH /FI "IMAGENAME eq %~2" &amp;&amp; EXIT /B )
IF /I "%_P%" == "username" ( tasklist.exe /V /NH /FI "USERNAME eq %~2" &amp;&amp; EXIT /B )
IF /I "%_P%" == "running" ( tasklist.exe /V /NH /FI "STATUS eq Running" &amp;&amp; EXIT /B )
IF /I "%_P%" == "status" ( tasklist.exe /V /NH /FI "STATUS eq %~2" &amp;&amp; EXIT /B )
CALL :MF
EXIT /B</pre>



<h3>SPEAK - Speak text</h3>
<pre>:SPEAK
REM ECHO "%~1"
nircmd.exe speak text "%~1" 5 60 &amp;&amp; EXIT /B</pre>



<h3>MF - SLEEPs for 1 second, then prints out completed message, followed by 2 blank lines, then returns to CALLer</h3>
<pre>:MF
SLEEP 1 &amp;&amp; ECHO  [COMPLETED] &amp;&amp; ECHO. &amp;&amp; ECHO. &amp;&amp; EXIT /B</pre>


<h3>MM - prints blank line, L1, changes title of the interpreter window to %~1, prints >>> %~1..., L2, blank line, then returns to CALLer</h3>
<pre>:MM
SLEEP 1 &amp;&amp; ECHO. &amp;&amp; ECHO %L1% &amp;&amp; title +++ %~1... &amp;&amp; ECHO %P1% %~1... &amp;&amp; ECHO %L2% &amp;&amp; ECHO. &amp;&amp; EXIT /B</pre>


<h3>MT - prints blank line, L1, changes title of the interpreter window to %~1, prints >>> %~1..., L2, blank line, then returns to CALLer</h3>
<pre>:MT
CALL :MM "%~1" &amp;&amp; CALL :SPEAK "%~1" &amp;&amp; EXIT /B</pre>


<h3>MP - Print Output, then returns to CALLer</h3>
<pre>:MP
IF "%~1" == "1" ECHO %P1% %~2 &amp;&amp; EXIT /B
IF "%~1" == "2" ECHO %P2% %~2 &amp;&amp; ECHO. &amp;&amp; EXIT /B
IF "%~1" == "3" ECHO %P3% %~2 &amp;&amp; EXIT /B
EXIT /B</pre>


<h3>MP3 - ECHO %~1, speak %~1 with nircmd.exe, then returns to CALLer</h3>
<pre>:MP3
CALL :MP 1 "%~1" &amp;&amp; CALL :SPEAK "%~1" &amp;&amp; EXIT /B</pre>



<h3>MDYE - exit script with message %~1, then returns to CALLer</h3>
<pre>:MDYE
SETLOCAL
SET _M= %~1
IF NOT "%_M%" == " " SET _M=REASON: %~1
CALL :MP 1 "EXITING SCRIPT...  %_M%" &amp;&amp; ECHO. &amp;&amp; ECHO.
ENDLOCAL &amp;&amp; EXIT /B</pre>



<h3>MKILL - exit cmd processor with message %~1</h3>
<pre>:MKILL
SETLOCAL
SET _M= %~1
IF NOT "%_M%" == " " SET _M=REASON: %~1
ECHO. &amp;&amp; ECHO. &amp;&amp; CALL :MP 1 "EXITING CMD WINDOW IN 3 SECONDS...  %_M%" &amp;&amp; ECHO. &amp;&amp; ECHO. &amp;&amp; SLEEP 3
ENDLOCAL &amp;&amp; EXIT &amp;&amp; EXIT &amp;&amp; EXIT</pre>



<h2>EOF: Thoughts</h2>
<p>So what did you think?  I have around 20 batch scripts that utilize these and other functions to do all sorts of cool things.  One takes a screenshot of my desktop every 10 minutes and saves it for a real-cool archive of my activity.  Another lets me edit a boot.ini file with 1 command.. And another runs when I insert a USB drive to automatically mount a truecrypt volume and create SSH tunnels in the background by using Plink, AT, and the runas.exe command.</p>
<p>If you want to program, please use linux...  If you need to write a Windows batch file, I hope this helps.</p><p><a href="http://www.askapache.com/windows/advanced-batch-scripting.html"></a><a href="http://www.askapache.com/windows/advanced-batch-scripting.html">Advanced Windows Batch File Scripting</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/windows/advanced-batch-scripting.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Crazy POWERFUL Bash Prompt</title>
		<link>http://www.askapache.com/linux/bash-power-prompt.html</link>
		<comments>http://www.askapache.com/linux/bash-power-prompt.html#comments</comments>
		<pubDate>Tue, 25 May 2010 19:02:34 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.askapache.com/?p=4069</guid>
		<description><![CDATA[<p><a class="IFL" href='http://www.askapache.com/linux/bash-power-prompt.html' title='bash power prompt PS1'><img width="350" height="65" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1-350x65.png" class="attachment-thumbnail" alt="bash power prompt PS1" title="bash power prompt PS1" /></a>This <a href='http://www.askapache.com/linux/bash-power-prompt.html' title='amazing bash linux prompt'>amazing bash linux prompt</a> does more than meets the eye.  If you want to know how to become really good with technology, linux is the secret sauce behind the AskApache articles.  Open Source is elixir of the web.  Thanks to everyone who helped me for the past 20 years.  <strong>I use linux/bsd</strong> because <strong>homey don't play</strong>, so this is geared to be as productive a prompt as I can make it.<br /><br /><strong>Don't have much time.. or just don't care?</strong> Not a problem, here are the 3 lines to copy and paste - you can just paste them right in your shell to test it, or add to a startup script.<br class="C" /></p>
<pre style='font-size:8px'>export AA_P="export PVE=\"\\033[m\\033[38;5;2m\"\$(( \`sed -n \"s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\` / 1024 ))\"\\033[38;5;22m/\"\$((\`sed -n \"s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\`/ 1024 ))MB\"\\t\\033[m\\033[38;5;55m\$(&#60; /proc/loadavg)\\033[m\";echo -en \"\""
export PROMPT_COMMAND="history -a;((\$SECONDS % 10==0 ))&#38;&#38;eval \"\$AA_P\";echo -en \"\$PVE\";"
export PS1="\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ " &#38;&#38; eval $AA_P</pre>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"></a><a href="http://www.askapache.com/linux/bash-power-prompt.html"><cite>AskApache.com</cite></a></p><p><a style="display:block;width:140px;float:left;padding:1em;" href='http://www.askapache.com/linux/bash-power-prompt.html' title='bash power prompt screenshot'><img width="116" height="62" src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss-116x62.png" class="attachment-thumbnail" alt="bash power prompt screenshot" title="bash power prompt screenshot" /></a>From <strong>setting the window title</strong> to show the last run command (filtered), saving your <strong>history</strong> and keeping multi-session history intact, resetting the <strong>color/cursor/highlighting</strong> of errant color-emitting commands, these 2 prompt examples do more than meet the eye and are extremely fast.<br /><br />Don't have much time or just don't care? No problem, this is a simple copy and paste... here's one to start (all 1 line, just cut and paste right into the shell, once you've made sure its safe).<br class="C" /></p>
<pre>PS1="\n\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T \
\[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY:-o} \
\[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ "</pre>
<a href='http://www.askapache.com/linux/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a>
<p>Or for POWER PROMPT</p>
<pre>PROMPT_COMMAND=&#039;history -a;echo -en "\033[m\033[38;5;2m"$(( `sed -n "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -n "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo`/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"&#039;
PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
 </pre>


<h2>Or for Extreme Power Prompt</h2>
<p>Updated!  5/25/2010,  This is what I use at the moment.. It's the coolest code I've ever seen to do this.  I rewrote the above (and below) bash prompts to this format because it is much more robust, and believe it or not its way faster for your machine.  Yes the code below is correct, it looks a little weird to export vars from within an exported var statement..  but this is correct. If you just learn this one bit of code, you will gain a lot of shell kung fu, at least I have!  Enjoy!</p>
<pre style='font-size:9px'>export AA_P="export PVE=\"\\033[m\\033[38;5;2m\"\$(( \`sed -n \"s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\` / 1024 ))\"\\033[38;5;22m/\"\$((\`sed -n \"s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\`/ 1024 ))MB\"\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\";echo -en \"\""
export PROMPT_COMMAND="history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \"\$AA_P\";echo -en \"\$PVE\";"
export PS1="\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ "
export PVE="\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m" &amp;&amp; eval $AA_P</pre>

<pre>[24574:16122 0:344] 05:49:07 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:344)$ export AA_P="export PVE=\"\\033[m\\033[38;5;2m\"\$(( \`sed -n \"s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\` / 1024 ))\"\\033[38;5;22m/\"\$((\`sed -n \"s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\`/ 1024 ))MB\"\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\";echo -en \"\""
&gt;&gt;&gt; export &#039;AA_P=export PVE="\033[m\033[38;5;2m"$(( `sed -n "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo` / 1024 ))"\033[38;5;22m/"$((`sed -n "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/ 1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m";echo -en ""&#039;
&gt;&gt;&gt; AA_P=&#039;export PVE="\033[m\033[38;5;2m"$(( `sed -n "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo` / 1024 ))"\033[38;5;22m/"$((`sed -n "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/ 1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m";echo -en ""&#039;</pre>

<pre>[24574:16122 0:345] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:345)$ export PROMPT_COMMAND="history -a;((\$SECONDS % 10==0 ))&amp;&amp;eval \"\$AA_P\";echo -en \"\$PVE\";"
&gt;&gt;&gt; export &#039;PROMPT_COMMAND=history -a;(($SECONDS % 10==0 ))&amp;&amp;eval "$AA_P";echo -en "$PVE";&#039;
&gt;&gt;&gt; PROMPT_COMMAND=&#039;history -a;(($SECONDS % 10==0 ))&amp;&amp;eval "$AA_P";echo -en "$PVE";&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 66 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>

<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:346] 05:49:09 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:346)$ export PS1="\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ "
&gt;&gt;&gt; export &#039;PS1=\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.35 0.24 0.19 1/68 27241\033[m&#039;</pre>

<pre>813/1024MB      0.35 0.24 0.19 1/68 27241
[24574:16122 0:347] 05:49:10 Wed May 26 [faux@backtrack-askapache:/dev/pts/0 +1] ~
(1:347)$ export PVE="\\033[m\\033[38;5;2m813\\033[38;5;22m/1024MB\\t\\033[m\\033[38;5;55m0.25 0.22 0.18 1/66 26820\\033[m"
&gt;&gt;&gt; export &#039;PVE=\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; PVE=&#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;
&gt;&gt;&gt; history -a
&gt;&gt;&gt; (( 67 % 10==0  ))
&gt;&gt;&gt; echo -en &#039;\033[m\033[38;5;2m813\033[38;5;22m/1024MB\t\033[m\033[38;5;55m0.25 0.22 0.18 1/66 26820\033[m&#039;</pre>








<h2>256 Color Prompt Command</h2>
<p class="bnote"><strong>NOTE:</strong> I have been preparing a 256color terminal article for some time now, as I have tweaked, hacked, read, and experimented with more than I would ever like to admit.  So stay tuned, there isn't any tutorial, book, or online howto remotely close to as good as what I'm close to posting...</p>
<p><a href="http://www.askapache.com/linux/bash-power-prompt.html/super-optimized-256color-prompt/" rel="attachment wp-att-4297"><img src="http://uploads.askapache.com/2010/03/super-optimized-256color-prompt.png" alt="Super-optimized 256color BASH Prompt" title="Super-optimized 256color BASH Prompt" width="726" height="177" class="size-full wp-image-4297" /></a></p>
<p><a href="http://www.askapache.com/linux/bash-power-prompt.html/256-color-prompt/" rel="attachment wp-att-4280"><img src="http://uploads.askapache.com/2010/03/256-color-prompt.png" alt="256 color prompt_command and PS1" title="256 color prompt" width="642" height="147" class="size-full wp-image-4280" /></a></p>
<p>If you have a 256-color enabled terminal try this..<br class="C" /></p>
<pre>    export PROMPT_COMMAND=&#039;echo -en "\033[m\033[38;5;2m"$(( `sed -n "s/MemFree:[\t ]\+\([0-9]\+\) kB/\1/p" /proc/meminfo`/1024))"\033[38;5;22m/"$((`sed -n "s/MemTotal:[\t ]\+\([0-9]\+\) kB/\1/Ip" /proc/meminfo`/1024 ))MB"\t\033[m\033[38;5;55m$(&lt; /proc/loadavg)\033[m"&#039;
    export PS1=&#039;\[\e[m\n\e[1;30m\][$$:$PPID \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \d \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n($SHLVL:\!)\$ &#039;</pre>
<p>Which double-quoted is:</p>
<pre>declare -x PROMPT_COMMAND="echo -en \"\\033[m\\033[38;5;2m\"\$(( \`sed -n \"s/MemFree:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/p\" /proc/meminfo\`/1024))\"\\033[38;5;22m/\"\$((\`sed -n \"s/MemTotal:[\\t ]\\+\\([0-9]\\+\\) kB/\\1/Ip\" /proc/meminfo\`/1024 ))MB\"\\t\\033[m\\033[38;5;55m\$(&lt; /proc/loadavg)\\033[m\""
declare -x PS1="\\[\\e[m\\n\\e[1;30m\\][\$\$:\$PPID \\j:\\!\\[\\e[1;30m\\]]\\[\\e[0;36m\\] \\T \\d \\[\\e[1;30m\\][\\[\\e[1;34m\\]\\u@\\H\\[\\e[1;30m\\]:\\[\\e[0;37m\\]\${SSH_TTY} \\[\\e[0;32m\\]+\${SHLVL}\\[\\e[1;30m\\]] \\[\\e[1;37m\\]\\w\\[\\e[0;37m\\] \\n(\$SHLVL:\\!)\\\$ "</pre>

<p class="cnote"><strong>For Commandlinefu.com users</strong>:  Here ya go!  <a href='http://www.askapache.com/linux/bash-power-prompt.html/toprc/' rel='attachment wp-att-4414'>toprc</a></p>

<p>That looks great, and is practicallly totally free in terms of how much cpu/work it makes the shell do for each command.  So for slow terminals, or text-terminals like I use, this is great.  Other than PS1, there is 1 other variable..  It's called PROMPT_COMMAND and is execed right in front of the PS1.  I show 2 ways to utilize this, the goal being to show there is no right way.. fast is fast and money is money.  I use a function called aa_pc I threw together that shows me in color how much memory is on my system.. very cool.</p>


<h2>PROMPT = ?</h2>
<p>Here's a screenshot of the code in my vim + screen multiplexed bash 4 environment..   It's placed all the way at the bottom of the file and is the last thing executed by the client processing the script.  Also, while it's great to look so good, this is all 100% for efficiency since I use one shell or another every day.</p>
<div id="attachment_4177" class="wp-caption alignnone" style="width: 805px"><a href="http://www.askapache.com/linux/bash-power-prompt.html/bash-prompt-screenshot/" rel="attachment wp-att-4177"><img src="http://uploads.askapache.com/2010/03/bash-prompt-screenshot.png" alt="Custom Power Prompt - currently mine" title="Custom Power Prompt -
currently mine" width="795" height="596" class="size-full wp-image-4177" /></a><p class="wp-caption-text">Custom Power Prompt - currently mine</p></div>


<p>Here's the code I'm using today, that produced this screen-shot -- I am always changing stuff so it's a little more tough to figure out.</p>
<pre>  function aa_pc()
  {
        local M=$( free -olm|sed "/Mem/!d; s/Mem:[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\)[^0-9]*\([0-9]*\).*/ \
        ${GREP_COLOR}\2MB${R}\/\3MB/"; ); echo -e "$M `pwd`"
  }
&nbsp;
  aa_grep_color(){ export GREP_COLOR=`tput setaf $(aa_random_under 6)`; }
  aa_random_under(){ echo -en $(( $RANDOM % ${1:-$RANDOM} + 1 )); }
  uptime1(){ sed &#039;/.*,  \([0-9]*\) users,  load average: \(.*\)/!d; s//[ \2, \1 users ]/;q&#039;;
&nbsp;
  $SED -n &#039;/i/!Q2&#039; &lt;&lt;&lt; $- &amp;&amp; \
  {
        case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
  }
&nbsp;
  # hack for being able to source all the functions in this file from a script
  MASTER_RESET=$`echo -e "rs1\nrs2\ninitc\nis2\ncnorm\nrmso\nsgr0" | tput -S`
&nbsp;
  # only for color-aware (some guessing) terminals, kick everyone else OUT
  case ${TERM:-dummy} in xterm*|screen*|*color*)echo; ;; *) return; esac;
&nbsp;
  [[ -r /etc/DIR_COLORS ]] &amp;&amp; eval `dircolors -b /etc/DIR_COLORS`
&nbsp;
  # changes the window title in terminals like putty or konsole
  echo -ne "\033]0; ${USER}@${HOSTNAME}  +${SHLVL} @${SSH_TTY/\/dev\/} - `uptime1` \007"
&nbsp;
  # show title, setup the colors, vars, funcs, settings
  asetup_colors &amp;&amp; ascript_title
  export PROMPT_COMMAND=&#039;history -a;aa_pc&#039;
  export PS1=&#039;\[\033[1;30m\][$$:$PPID - \j:\!\[\033[1;30m\]]\[\033[0;36m\] \T\
  \d \[\033[1;30m\][\[\033[1;34m\]\u@\H\[\033[1;30m\]:\[\033[0;37m\]${SSH_TTY} \
  \[\033[0;32m\]+${SHLVL}\[\033[1;30m\]] \[\033[1;37m\]\w\[\033[0;37m\] \n\$ &#039;</pre>



<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ss.png" alt="bash power prompt screenshot" title="bash power prompt screenshot" width="898" height="480" /></a></p>
<p>I've used many shells over the years and have learned many tweaks and tricks for a powerful prompt.  It may look deceptively simple.  One cool thing this prompt does is display the command line (filtered) in the putty/konsole/xterm window, so if you have several windows minimized you can easily find the one you are looking for.<br class="C" /></p>

<p>There is a lot of good info about the BASH prompt around the net, but it can be complicated for a new user, and as an advanced user you will notice most of the info is very outdated and not very optimized for speed.  To get this articles recommended prompt working is devastatingly simple, just export the <code>PROMPT_COMMAND</code> and <code>PS1</code> variables that are shown below.  Most "power prompts" that utilize things like PROMPT_COMMAND do so very haphazardly or very extravagantly.</p>
<p>I've been called a lot of things but not extravagant, and because I use this prompt on many different servers, platforms, and systems I made sure to not make things complicated.  To test them just copy and paste the code below into your shell which will <strong>export PROMPT_COMMAND</strong> and <strong>PS1</strong> variables and work right away.  So test it out, and if you like it add it to your .bashrc or other startup file (please do a <code>$ man bash</code>).</p>


<ul>
<li><a href="#power-prompt-commands">Custom Power Prompt Commands</a><ol>
     <li><a href="#prompt_command">PROMPT_COMMAND Detailed</a></li>
     <li><a href="#detailed-ps1">PS1 Detailed</a></li>
</ol></li>
<li><a href="#hacker-prompts">Additional Info for Hackers</a><ol>
     <li><a href="#set-xterm-title">Setting Window Title</a></li>
     <li><a href="#strip-colors">Stripping Colors from PS1</a></li>
     <li><a href="#uptime-alt">Alternative to Uptime/Loadavg (proc)</a></li>
     <li><a href="#multi-prompt-switcher">Multi-Prompt Switcher Function</a></li>
  </ol></li>
<li><a href="#bash-prompt-reading">Bash Prompts - More Reading</a><ol>
      <li><a href="#ps1-examples">Other Simple Power Prompt Examples</a></li>
     <li><a href="#bash-prompt-vars">All Prompt Variables</a></li>
     <li><a href="#prompt-escapes">Escape Codes for PS1</a></li>
<li><a href="#more-reading">Additional Reading</a></li>
  </ol></li>
</ul>



<p><a id="power-prompt-commands" name="power-prompt-commands"></a></p>
<h2>Bash Power Prompt</h2>
<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a><br />From setting the window title to show the last run command (filtered), saving your history and keeping multi-session history intact, resetting the color/cursor/highlighting of errant color-emitting commands, this prompt does more than meets the eye extremely fast.</p>
<p class="enote">Don't have much time? Don't care?  You may copy and paste these 2 lines into your shell and that's all there is to it!</p>
<pre>export PROMPT_COMMAND=&#039;export H1="`history 1|sed -e "s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g"`";history -a;echo -e "sgr0\ncnorm\nrmso"|tput -S&#039;
export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}... ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>


<p><a id="prompt_command" name="prompt_command"></a></p>
<h2>PROMPT_COMMAND</h2>
<p>This holds commands to be run prior to displaying the prompt.  Let's break it down.</p>
<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-prompt.jpg" alt="PS1 Prompt Example" title="PS1 Prompt Example" width="663" height="120" class="size-full wp-image-4150" /></a>
<p>First this takes the last command executed and filters it using sed to remove the initial history command number, and also to remove any quotes (single or double) and/or backticks.  Also, it only saves the first 50 chars, which are then exported as the value of H1, which because it is exported is now globally accessible to the rest of the shell.  This is important because we use this variable in PS1 to print the last run command as the title of our putty window (or konsole).</p>
<pre>export H1=`history 1 | sed -e &#039;s/^[\ 0-9]*//; s/[\d0\d31\d34\d39\d96\d127]*//g; s/\(.\{1,50\}\).*$/\1/g&#039;`</pre>

<p>The next command simply appends your last command to the history file.  Usually this is <code>~/.bash_profile</code>, or whatever <code>$HISTFILE</code> is.  This makes sure you never lose history in case of a shell crash or ssh connection terminated. </p>
<pre>history -a</pre>

<p>Finally there is this golden nugget of shell kung-fu.  This outputs 3 terminal escape sequences according to the terminal in use and its capabilities.. so very robust, should work on any shell newer than 1984.  By echoing the following 3 term names separated by a newline <code>\n</code> and using tput -S it will output the terminal sequences for all 3.  sgr0 resets the colors, cnorm resets the cursor, and rmso resets the background color.</p>
<p class="cnote">You can view the escape sequences generated by tput with strace, cat -t, etc..  For instance on my shell (xterm-256color via portaputty) the below command generates: <code>\33(B\33[m\33[?12l\33[?25h\33[27m</code>.  This is helpful because if you aren't coding for several terminals you can hard code that in your echo's instead of using tput, saving some overhead.</p>
<pre>echo -e &#039;sgr0\ncnorm\nrmso&#039; | tput -S
# For my term this is the same as if I just did
# echo -e "\33(B\33[m\33[?12l\33[?25h\33[27m"</pre>






<p><a id="detailed-ps1" name="detailed-ps1"></a></p>
<h2>PS1 Detailed</h2>
<p><code>PS1</code> is the variable that is expanded as your prompt.  So if you did a <code>$ unset PS1</code> then you can still run commands and everything, but your screen will be blank which is confusing to say the least.</p>
<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/askapache-htop.jpg" alt="The HTOP command in full color to manage mysql" title="The HTOP command in full color to manage mysql" width="404" height="176" class="size-full wp-image-4149" /></a></p>

<p>This PS1 shows which SHLVL level the shell is in, which is how many levels deep of shells you are currently at.  If you run <code>$ bash -l</code> from a bash shell it will create a new instance of bash as a child of the calling bash, so the SHLVL (shell level) gets incremented by 1.  I usually avoid creating subshells by instead executing a new bash with <code>exec</code> which instead of creating a new bash as a child of the current bash, it replaces the current bash process with the new one: <code>$ exec bash -l</code>.</p>

<pre>export PS1=&#039;\n\e[1;30m[\j:\!\e[1;30m]\e[0;36m \T \d \e[1;30m[\e[1;34m\u@\H\e[1;30m:\e[0;37m`tty 2&gt;/dev/null` \e[0;32m+${SHLVL}\e[1;30m] \e[1;37m\w\e[0;37m\[\033]0;[ ${H1}... ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;
&nbsp;
# with nocolors
# export PS1=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}... ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$ &#039;</pre>

<h3>TTY</h3>
<p>This command is very useful for me because I use multiplexed terminals, about 6 at a time, so it is crucial sometimes to know which tty I am using.  Since SSH is the ONLY protocol I ever use for anything, I used to depend on the SSH_TTY variable being set instead of using tty, which as a command has more overhead then just echoing a variable.  But I found that when running multiplexing terminals with tmux, screen, etc.. the SSH_TTY variable stays with the initial tty created upon login.   <strong>Note:</strong> <code>2&gt;/dev/null</code> redirects any errors that running the tty command might issue to the /dev/null device, which is the same thing as a black hole, it goes nowhere so is an efficient way to send data for deletion.  Depending on your server and ssh settings you may not even have a tty or it may just appear that you do not.  Some web hosting companies do odd things to prevent their users from using tty devices and programs.  But if you get a little creative you can always find the current tty.. like <code>$ readlink /proc/self/fd/0</code> will return the same thing as <code>$ tty</code>.</p>
<pre>`tty 2&gt;/dev/null`</pre>

<p><a id="set-xterm-title" name="set-xterm-title"></a></p>
<h3>Changing Window Title with PS1</h3>
<p>This simple bash function changes the title of the window to the passed parameter.  The key thing to note is that this works because of the special escapes on either end of the echo'd data.</p>
<pre>function set_window_title()
{
  echo -e "\033]0; ${1:-$USER@$HOST - $SHLVL} \007";
}</pre>










<p><a id="hacker-prompts" name="hacker-prompts"></a></p>
<h2>Additional Info for Hackers</h2>
<p>More reading and digging.</p>

<p><a id="strip-colors" name="strip-colors"></a></p>
<h3>Strip Colors for Readability</h3>
<p>You can use this command to strip a PS1 of all colors, which shortens the variable dramatically in some cases.</p>
<pre>sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1
# ie export PS1=$(sed &#039;s/\\[eE][[0-9]*;[0-9]*m//g&#039; &lt;&lt;&lt; $PS1);</pre>



<p><a id="multi-prompt-switcher" name="multi-prompt-switcher"></a></p>
<h3>Multi-Prompt Switcher Function</h3>
<p>This function demonstrates 1 way that you can change your prompts at will.  It creates an array named AAPS that you can add as many PS1 values to as you want.  Each time the function is run it simply changes the prompt string variable PS1 to the value of the next item in the AAPS array.  Once it reaches the last item in AAPS, it resets back to the first <code>AAPS[0]</code> prompt.  Just an example to play with, not tested very much.</p>
<pre>aa_multi_prompt ()
{
    declare -a AAPS;
    AAPS[0]=&#039;\n[\j:\!] \T \d [\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}... ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
    AAPS[1]=&#039;\n[\j:\!] \T \d \n[\u@\H:`tty 2&gt;/dev/null` +${SHLVL}] \w\[\033]0;[ ${H1}... ] \w - \u@\H +$SHLVL @`tty 2&gt;/dev/null` - [ `uptime` ]\007\]\n\[\]\$&#039;;
&nbsp;
    : ${PLVL:=0};
    [[ "${#AAPS[@]}" -lt "$PLVL" || "${#AAPS[@]}" -eq "$PLVL" ]] &amp;&amp; PLVL=0;
    export PS1=${AAPS[$PLVL]} &amp;&amp; (( PLVL++ )) &amp;&amp; export PLVL
}</pre>


<h3>BASH 4 Multi-Prompt</h3>
<p>Here's an example from bash-4, but it works for all bash versions.</p>
<pre>prompt ()
{
    case "$1" in
        d)
            PS1=&#039;$(dirs) \$ &#039;
        ;;
        n)
            PS1=&#039;\$ &#039;
        ;;
        hsw)
            PS1=&#039;\h[$SHLVL]: \w \$ &#039;
        ;;
        hw)
            PS1=&#039;\h: \w \$ &#039;
        ;;
        sh)
            PS1=&#039;[$SHLVL] \h\$ &#039;
        ;;
        sw)
            PS1=&#039;[$SHLVL] \w \$ &#039;
        ;;
        uh)
            PS1=&#039;\u@\h\$ &#039;
        ;;
        uhsHw)
            PS1=&#039;\u@\h[$SHLVL]:\#: \w \$ &#039;
        ;;
        uhsw)
            PS1=&#039;\u@\h[$SHLVL]: \w \$ &#039;
        ;;
        uhw)
            PS1=&#039;\u@\h: \w \$ &#039;
        ;;
        uw)
            PS1=&#039;(\u) \w \$ &#039;
        ;;
        w)
            PS1=&#039;\w \$ &#039;
        ;;
    esac
}</pre>

<p><a id="uptime-alt" name="uptime-alt"></a></p>
<h3>Alternative to uptime:</h3>
<pre>echo "Up for $(( $(sed &#039;s/^\([0-9]*\).*/\1/&#039; /proc/uptime) / (60*60*24) )) days - [`cat /proc/loadavg`]"
# or
echo "Uptime: $(( `sed &#039;s/^\([0-9]*\).*/\1/g&#039; /proc/uptime` / 86400 )) days. Load: $(&lt;/proc/loadavg)"</pre>





<p><a id="bash-prompt-reading" name="bash-prompt-reading"></a></p>
<h2>Bash Prompts - More Reading</h2>

<p><a id="bash-prompt-vars" name="bash-prompt-vars"></a></p>
<h3>All Bash Prompt Variables</h3>
<p>These are the environment variables provided by BASH (and most shells) and control your prompt string.   While all are interesting and good to know about, <code>PROMPT_COMMAND</code> and <code>PS1</code> are the only ones that directly modify the prompt that is displayed.</p>
<dl>
<dt>PROMPT_COMMAND</dt>
<dl>If set, the value is executed as a command <strong>prior</strong> to issuing each primary prompt.</dl>
<dt>PS1</dt>
<dl>The value of this parameter is expanded and used as the primary prompt string.  The default value is "<code>\s-\v\$ </code>".</dl>
<dt>PS2</dt>
<dl>The value of this parameter is expanded as with PS1 and used as the secondary prompt string.  The default is "<code>&gt; </code>".</dl>
<dt>PS3</dt>
<dl>The value of this parameter is used as the prompt for the select command.</dl>
<dt>PS4</dt>
<dl>The  value of this parameter is expanded as with PS1 and the value is printed before each command bash displays during an execution trace.  The first character of PS4 is replicated multiple times, as necessary, to indicate multiple levels of indirection.  The default is "<code>+</code>".</dl>
</dl>



<p><a id="prompt-escapes" name="prompt-escapes"></a></p>
<h3>Prompt Escape Codes</h3>
<p>When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings to be customized by inserting a number of backslash-escaped special characters that are decoded as follows:</p>
<ul>
<li><code>\a</code> - an ASCII bell character (07)</li>
<li><code>\d</code> - the date in "Weekday Month Date" format (e.g., "Tue May 26")</li>
<li><code>\D{format}</code> - the format is passed to <a href="http://www.freebsd.org/cgi/man.cgi?query=strftime">strftime(3)</a> and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
<li><code>\e</code> - an ASCII escape character (033)</li>
<li><code>\h</code> - the hostname up to the first '.'</li>
<li><code>\H</code> - the hostname</li>
<li><code>\j</code> - the number of jobs currently managed by the shell</li>
<li><code>\l</code> - the basename of the shellâs terminal device name</li>
<li><code>\n</code> - newline</li>
<li><code>\r</code> - carriage return</li>
<li><code>\s</code> - the name of the shell, the basename of <var>$0</var> (the portion following the final slash)</li>
<li><code>\t</code> - the current time in 24-hour HH:MM:SS format</li>
<li><code>\T</code> - the current time in 12-hour HH:MM:SS format</li>
<li><code>\@</code> - the current time in 12-hour am/pm format</li>
<li><code>\A</code> - the current time in 24-hour HH:MM format</li>
<li><code>\u</code> - the username of the current user</li>
<li><code>\v</code> - the version of bash (e.g., 2.00)</li>
<li><code>\V</code> - the release of bash, version + patch level (e.g., 2.00.0)</li>
<li><code>\w</code> - the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\W</code> - the basename of the current working directory, with <var>$HOME</var> abbreviated with a tilde</li>
<li><code>\!</code> - the history number of this command</li>
<li><code>\#</code> - the command number of this command</li>
<li><code>\$</code> - if the effective UID is 0, a <strong>#</strong>, otherwise a <strong>$</strong></li>
<li><code>\nnn</code> - the character corresponding to the octal number nnn
<li><code>\\</code> - a backslash</li>
<li><code>\[</code> - begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt</li>
<li><code>\]</code> - end a sequence of non-printing characters</li>
</ul>
<p>The  command  number  and the history number are usually different: the history number of a command is its position in the history list, which may include commands restored from the history file, while the command number is the position in the sequence of commands executed during the current shell session.  After the string is decoded, it is expanded via parameter expansion, command substitution, arithmetic expansion, and quote removal, subject to the value of the promptvars shell option, which if set, prompt strings undergo parameter expansion, command substitution, arithmetic expansion, and quote removal after being expanded as described in PROMPTING above.   <var>promptvars</var> is enabled by default.</p>


<p><a href="http://www.askapache.com/linux/bash-power-prompt.html"><img src="http://uploads.askapache.com/2010/03/bash-power-prompt-ps1.png" alt="bash power prompt PS1" title="bash power prompt PS1" width="513" height="96" /></a></p>


<p><a id="ps1-examples" name="ps1-examples"></a></p>
<h3>More Example Prompts</h3>
<pre>export PS1="\n\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]\n$ \e[0m"
[user@host][~/bin/tools]
$</pre>

<pre>export PS1="\n[$?]\e[1;37m[\e[0;32m\u\e[0;35m@\e[0;32m\h\e[1;37m]\e[1;37m[\e[0;31m\w\e[1;37m]($SHLVL:\!)\n\[\033[0m\]\$ "
[0][user@host][~/bin/tools](1:2130)</pre>

<pre>export PS1=&#039;\[\033[1;33m\]\u\[\033[1;37m\]@\[\033[1;32m\]\h\[\033[1;37m\]:\[\033[1;31m\]\w \[\033[1;36m\]\$ \[\033[0m\]&#039;
user@host:~/bin/tools $</pre>

<pre>export PS1="\e[1;31m[\h]$NC \W &gt; \[\033]0;\${TERM} [\u@\h] \w\]"
[lifesaver] tools &gt;</pre>




<h2>Benchmarking PROMPT_COMMAND</h2>
<p>When figuring out how resource intensive your prompt_command is (if you choose to do that sort of thing), it's nice to do it like this.  I ended up using  this information from the following test to create the prompt_command used in the first 256-color prompt above.</p>
<pre>#!/bin/bash
&nbsp;
function clean_results()
{
      grep ^real | cut -dm -f2 | sort | uniq -c | sort -n
}
&nbsp;
for i in {0..500};
do
      time sh -c "expr `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024" &amp;&gt;/dev/nulll;
done 2&gt;&amp;1 | clean_results
&nbsp;
# print separating line
printf "%$((${COLUMNS:-`tput cols`} - 10))s\n" &#039; &#039; | sed -u &#039;s/ /-/g&#039;
&nbsp;
for i in {0..500};
do
      time sh -c "echo $(( `sed -nu &#039;s/^MemFree:[\t ]\+\([0-9]\+\) kB/\1/Ip&#039; /proc/meminfo`/1024 ))" &amp;&gt;/dev/null;
done 2&gt;&amp;1 | clean_results
&nbsp;
exit $?</pre>

<p>Generates this output, meaning that using expr takes longer.</p>
<pre>      1 0.011s
      1 0.014s
      2 0.009s
      2 0.012s
      5 0.008s
     12 0.004s
     47 0.007s
    215 0.005s
    216 0.006s
---------------------------------------------------------------------
      1 0.003s
      2 0.007s
     59 0.006s
    196 0.004s
    243 0.005s</pre>




<p><a id="more-reading" name="more-reading"></a></p>
<h3>Additional Links</h3>
<ul>
<li><a href="http://tldp.org/HOWTO/From-PowerUp-To-Bash-Prompt-HOWTO.html">From Power Up To Bash Prompt - TLDP</a></li>
<li><a href="http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Bash-Prompt-HOWTO.html">Bash Prompt HOWTO -TLDP</a></li>
<li><a href="http://tldp.org/LDP/abs/html/sample-bashrc.html">A Sample .bashrc File - TLDP</a></li>
<li><a href="http://gentoo.linuxhowtos.org/bash/bash_prompt_howto.htm">Gentoo Linux Howtos: bash -> Bash Prompt Howto - Gentoo</a></li>
<li><a href="http://www.debian-administration.org/article/Fancy_Bash_Prompts">Fancy Bash Prompts - Debian Administration</a></li>
</ul><p><a href="http://www.askapache.com/linux/bash-power-prompt.html"></a><a href="http://www.askapache.com/linux/bash-power-prompt.html">Crazy POWERFUL Bash Prompt</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/linux/bash-power-prompt.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</title>
		<link>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html</link>
		<comments>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html#comments</comments>
		<pubDate>Tue, 23 Feb 2010 10:11:11 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Hacking]]></category>

		<guid isPermaLink="false">http://askapache.com/?p=4001</guid>
		<description><![CDATA[<p><a class="IFL" id="id6" href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a>Ok I just came back up to write the intro.. I'm trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it's a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file. <br /><br />The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.  In the background, a service we created executes a PortaPuttY plink command to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  These tunnels are automatically reconnected if they are disconnected, meaning you can use a socks 5 if you want or even better!<br class="C" /></p>
<p><strong>Part 1 of 5</strong></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"><cite>AskApache.com</cite></a></p><p><a id="id6" class="IFL" href="http://www.tigerdirect.com/applications/SearchTools/item-details.asp?EdpNo=4329073&CatId=3786" title="This ones over $400 dollars! 128GB!"></a>Ok I just came back up to write the intro.. I'm trying to keep it short to avoid getting bogged down by the coolness of each step.  Here is what goes on.   When I logon to my XP machine at work, I bring my usb key and plug it in first.  On logging a window pops up first and it's a password prompt to mount my encrypted drive leonardo.  It also checks a keyfile that is located on my usb key, but all I do now is type in my password.  That causes my encrypted folder to be accessible to me like a normal drive, and it autoruns a startup batch file.  The batch file causes <strong>Portable</strong> versions of Firefox (<em>all my bookmarks, my settings</em>) to load, and launches <strong>Portable</strong> Mozilla Thunderbird (IMAP makes this work well), which is my favorite program (<em>great GPG features and open-source!</em>).  Also Some Adobe CS4 software is loaded from the hard drive, like DreamWeaver.<br class="C" /></p>

<p>The batch file also runs PortaPuttY plink to create forwarded tunnels from various remote servers and accounts, all using key-based encryption.  This includes dynamic SOCKS 4/5 tunnels, VPN tun device tunnels, and of course the basic SSH port forwarding tunnels that are so powerful.  These tunnels are automatically reconnected if they are disconnected, using simple windows builtin command-line tools.  And believe me it was not easy to figure out how to make this all work using plink ( essentially the same as putty minus the gui ), I literally had to use almost all of my Windows kung fu to finally end up with this.</p>

<h2>Using MyEnTunnel</h2>
<p>Initially I was using the <a href="http://nemesis2.qx.net">MyEnTunnel</a> program combined with a custom windows batch install script I wrote to handle the tunnels.<br /><br />The tunnels are very important to making things easy while improving security.  It's not easy to understand at first, but basically it means <strong>you can now connect to ANY IP address:port as if you were on that very machine connecting to localhost, like if you pinged yourself!</strong>.  The result is any traffic you want is now encrypted, and you can set up your servers to only accept connections from localhost, which could save you tons of memory, bandwidth, and security attack vectors to think about.   So I configure everything to use these tunnels as proxies, like Mozilla Thunderbird and Chrome, Firefox, Pidgeon, all portable versions and running from my encrypted usb drive.</p>

<p>This means you can walk into my house with that usb key, plug into any computer here, and surf the web/check your emails all across SSH... I know for a fact <strong>I wouldn't be able to snoop that</strong> traffic!  There is a lot of exciting things going on around here, new servers and all.. Its going to take a couple more posts for me to finish this up, enjoy the article and comment.</p>



<h2>Buy a couple USB Mini Drives</h2>
<p>The first thing to do, is purchase a USB thumb drive..   My favorite store, <a href="http://www.tigerdirect.com/applications/category/category_slc.asp?Recs=30&amp;Nav=|c:379|lp:0.01:hp:24.99|&amp;Sort=4" title="Highly recommended, this is not an affiliate link">TigerDirect.com</a>, has over 104 tiny usb drives for under $24.. I've used them since the late 90's.</p>
<p>I bought some 4GB PNY's the size of a fingernail at a gas station and they are amazing, way faster than say a dvd drive.  Just try to do some research of the differences between the 16GB vs the $4 1GB drives.. You want speed because the whole drive will be encrypted.   <em>If you can afford the super excellent and crazy fast ones, hey send me one!</em> Buying cheap means you can buy 3 or 4 so you can always have backups.  This device will make you Internationally mobile, untethered from a box, maybe getting some work done at a cafe in Florenze, or at a beach hotel in Miami.  Keep dreaming, but that is more possible with a better organized system.</p>

<h3>Backup the USB Drive</h3>
<p>You only need to know 1 way that works, there are several.  The way I do backups is to copy the entire disk image of the usb, that way I can always access it in case of usb key failure, which does happen.  Free software like <a href="http://clonezilla.org/">CloneZilla live CD</a> with its crazy cluster computing power, or Self Image, which is free for both linux and Windows.  And you could never go wrong with <a href="http://www.symantec.com/norton/ghost">GHOST</a>, one of the first to make mega bucks in the market.. it's some seriously impressive software <em>but not open-source</em>.  Even easier for some is to just set a cron job for dd to pipe the entire drive image to a remote computer using netcat, or sshfs, or curlftpfs, or just <strong>simple ssh</strong> like below.  Once setup (without stupid, bulky, dangerous software), the files on your encrypted usb don't change often, otherwise I would want to sync a backup to happen automatically every X number of logins or days (<em>test logfile time in bash_profile?</em>)..</p>

<h4>SSH Back-ups To Remote Server</h4>
<p>Files and data on your drives slow it down tremendously, meaning a web server storing backups locally is slower than one storing them externally.</p>
<p>Notice how much safer this command is by optimizing both the <a href="http://www.askapache.com/linux/optimize-nice-ionice.html">CPU and DISK I/O</a>..  Though it's much smarter to create a new separate ssh user, one with no shell and a passwordless safer key-based encryption.  Then in your /etc/security/limits.conf file or your initscript you can cause that user to have <code>nice -19</code> and <code>ionice -c2 -n7</code> priority set all the time automatically, since sshd, compression, and disk writing are this accounts only job.  turboslow is an alias defined in a ssh_config file so you don't have to type the host, port, and settings each time.</p>
<pre>#
# much better ways to do this on google!!!!!!!
#
ionice -c2 -n7 nice -n 19 dd if=/dev/sdb2 bs=1k conv=sync,noerror | gzip -c | ssh turboslow "dd of=sdb2.gz bs=1k"</pre>
<p>Note that you may decide it would be better to configure the ssh connection to a less CPU intensive algorithm, perhaps even <em>protocol 1</em> and <em>DES</em>.  That's perfectly alright, but the tradeoff is that the encryption can be broken much quicker, and so you would have to implement a cron job to create new keys on both ends of the tunnel every few hours.. It's really not a big deal to setup, kind of sweet way to use key-based encryption.  Also, important files ( those containing passwords, any database ) are encrypted before transport using private GPG keys, which don't need to be changed.  The other thing to think about too is only letting your main PC send/write on the backup host, so the backup host is only authorized to rx and can never login back to yours. </p>
<p>Hey! the Internet is a dangerous place you better believe it!  And it's only going to get more interesting with cloud computing's breakthrough's... More people who know they're way around... I can always use an extra server, I'd love to expand my network another node without having to pay for it (free cloud computing?), so make sure your servers are locked up strenuously.  Not super perfect, just a little unique or creative in your defense to avoid any coming super-worm's that may be employing vast arsenals of the deadliest attack-engines like metasploit..  Scarry rumors.</p>

<h4>Compression Speeds: PBZip2, Rzip, Lzop, Gzip</h4>
<p>Probably the fastest is to use rsync over ssh, which is what I'm doing, since the algorithms used by rsync are much faster and safer.  <a href="http://www.askapache.com/security/mirror-using-rsync-ssh.html">Rsync also lets you specify a compression program</a>, so depending on your machine you will want pbzip2 (for multi processors) or rzip which are the 2 fastest I know of, though I have had some reliability issues with rzip for gigabyte transfers.  Pbzip2 is amazing, blew me away the first time being 8x faster (8 CPUs) then <strong>anything</strong>.  You can get it and compile a static binary for your thumb drive if want at <a href="http://compression.ca/pbzip2/">Parallel BZIP2 (PBZIP2)</a>. Heavy code, re: this note by Jeff Gilchrist</p>
<quote><strong>NOTE</strong>: If you are looking for a parallel BZIP2 that works on cluster machines, you should check out <strong>MPIBZIP2</strong> <strong>which was designed for a distributed-memory message-passing architecture</strong>.</quote>
<pre>tar cpf "$G" --use-compress-prog=pbzip2 ./</pre>
<p><a href="http://uploads.askapache.com/2010/02/pbzip2.gif"><img src="http://uploads.askapache.com/2010/02/pbzip2.gif" alt="Parallel BZIP2 (PBZIP2)" title="pbzip2" class="size-medium wp-image-4002" /></a></p>


<h4>Benchmarking for Performance</h4>
<p>Finally a couple tips, you should get an idea what the device can do, format it a few times for linux and test it on windows, and vice versa.. Some drives are too small or too old and can only support fat32 filesystems on winblows, you DO NOT want fat32 because this drive is going to be 100% encrypted and then 100% transparently decrypted as you use it,
<pre># note this is 512MB
dd if=/dev/sda1 of=/dev/null bs=512 count=1000000
512000000 bytes (512 MB) copied, 5.16588 s, 99.1 MB/s</pre>








<h2>Part II:  Encrypted AutoRunning USB Key with TrueCrypt</h2>
<p>Now this section anyone can do, it's so easy on Windows.   What I'm going to show you how to do is get setup the right way super-fast.  There are many ways to use TrueCrypt, it's one of the nicest built software programs's I've ever used... Sadly, it is not licensed open-source, and that is often a deal-breaker for security-conscious folks or anti-pirate anarchists.  From the very helpful TrueCrypt web site:</p>

<blockquote cite="">
<ul type="disc">
            <li>Creates a <strong>virtual encrypted disk</strong> within a file and mounts  it as a real disk. </li>
            <li>Encrypts an<strong> entire partition or storage device</strong> such as USB flash drive or hard drive.</li>
            <li>Encrypts a <strong>partition or drive where Windows is installed</strong> (<a href="http://www.truecrypt.org/docs/?s=system-encryption">pre-boot authentication</a>).</li>
            <li>Encryption is <a href="http://www.truecrypt.org/docs/"><strong>automatic</strong>, <strong>real-time</strong> (on-the-fly) and <strong>transparent</strong></a>.</li>
            <li> <a href="http://www.truecrypt.org/docs/?s=parallelization">Parallelization</a> and <a href="http://www.truecrypt.org/docs/?s=pipelining">pipelining</a> allow data to be read and written as fast as if the drive was not encrypted.</li>
            <li>Provides <strong><a href="http://www.truecrypt.org/docs/?s=plausible-deniability">plausible deniability</a></strong>, in case an adversary  forces you to reveal the password: <strong><a href="http://www.truecrypt.org/hiddenvolume">Hidden volume</a></strong> (steganography) and <strong><a href="http://www.truecrypt.org/docs/?s=hidden-operating-system">hidden operating system</a></strong>.</li>
            <li><a href="http://www.truecrypt.org/docs/?s=encryption-algorithms">Encryption algorithms</a>: <a href="http://www.truecrypt.org/docs/?s=aes">AES-256</a>, <a href="http://www.truecrypt.org/docs/?s=serpent">Serpent</a>, and <a href="http://www.truecrypt.org/docs/?s=twofish">Twofish</a>.  Mode of operation: <a href="http://www.truecrypt.org/docs/?s=modes-of-operation">XTS</a>.</li>
        </ul>

</p>
</blockquote>





<h2>Further Reading</h2>
<ul>
<li><a href="http://ultra.ap.krakow.pl/~bar/DOC/ssh_backup.html">Network File Copy using SSH</a></li>
<li>Check out the trunk version of PuTTY:<code>~ svn co svn://svn.tartarus.org/sgt/putty</code>
</ul>





<hr class="C" />
<p>The real fun doesn't start till all the automation starts, automating all of that from a couple batch files I wrote, one click setup.  Kind of like building your own knoppix for when you have to use Windows.  To begin this tutorial, setup a truecrypt traveller setup on your usb and also install the portaputty package onto the usb.  You do this by creating a 3GB or whatever file on the usb and then mounting that file like you would mount an iso file.   I will show the Windows Batch file I use and the tricks with Windows Volume names and how to consistently make it all work.   Then we will setup MyEnTunnel with a customized batch file that forces all puttys to use portaputty (<code>sweet hack stolen from sysinternals pagedefrag tool</code>).<strong>Stay Tuned!</strong></p><p><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html"></a><a href="http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html">PortaPutty Auto-Reconnecting SSH Tunnels on an Encrypted TrueCrypt Portable USB Key w GPG</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/hacking/ssh-tunnels-truecrypt-gpg.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>COMPUTER SECURITY TOOLBOX</title>
		<link>http://www.askapache.com/security/computer-security-toolbox-2.html</link>
		<comments>http://www.askapache.com/security/computer-security-toolbox-2.html#comments</comments>
		<pubDate>Sat, 27 Sep 2008 00:29:52 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.askapache.com.com/webmaster/computer-security-toolbox-2.html</guid>
		<description><![CDATA[List of mainly obscure security software geared more for the master pentester. These are mostly for unix, bsd, and mac and many are difficult to install and setup (require custom servers, inside access points, obscure libraries). Only programs that output data are included, so no actual exploits or anything.  Most of these output extremely useful albeit extremely technical information.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/security/computer-security-toolbox-2.html"></a><a href="http://www.askapache.com/security/computer-security-toolbox-2.html"><cite>AskApache.com</cite></a></p><p>List of mainly obscure security software geared more for the master pentester. These are mostly for unix, bsd, and mac and many are difficult to install and setup <em>(require custom servers, inside access points, obscure libraries)</em>.  Only programs that output data are included, so no actual exploits or anything.  Most of these output extremely useful albeit extremely technical information.</p>

<p class="anote">You may be looking for the article: <a href="http://www.askapache.com/security/vulnerability-scanners-review.html">Vulnerability Scanners Review</a>, or <a href="http://www.askapache.com/security/top-5-best-vulnerability-port-scanners.html">Top 5 Vulnerability Port Scanners</a></p>

<h2>Obscure/Rare Security Software</h2>
<dl>
<dt>rwhois</dt>
<dd>really great addition to using whois. Get additional info not on whois, query rwhois servers.</dd>
<dt>lft</dt>
<dd>useful alternative method of tracerouteing. oppleman</dd>
<dt>packit</dt>
<dd>define (spoof) nearly all TCP, UDP, ICMP, IP, ARP, RARP, and Ethernet header options</dd>
<dt>etherape</dt>
<dd>really cool graphical program that displays connections and protocols similar to cheops.</dd>
<dt>amap</dt>
<dd>fingerprinting</dd>
<dt>xprobe2</dt>
<dd>fingerprinting</dd>
<dt>p0f2</dt>
<dd>really exceptional fingerprinting. can be passively run in the BG.</dd>
<dt>firewalk</dt>
<dd>good packetfiltering enumerator</dd>
<dt>BGPview</dt>
<dd>bgp anyone?</dd>
<dt>icmpenum</dt>
<dd>icmp fingerprinting</dd>
<dt>dnstracer</dt>
<dd>awesome and creative graphical output of dns</dd>
<dt>ssldump</dt>
<dd>not really that useful but impressive in a report</dd>
<dt>ftester</dt>
<dd>for master pentesters only &mdash; get the lowdown on your packetfiltering</dd>
<dt>mtr</dt>
<dd>alternative traceroute</dd>
<dt>MRTG</dt>
<dd>favorite tool of ISPs, many uses here</dd>
<dt>host</dt>
<dd>don't forget this one</dd>
<dt>ike-scan</dt>
<dd>scan for vpns</dd>
<dt>upnpscan</dt>
<dd>scan for upnp devices</dd>
<dt>ftp-spider</dt>
<dd>get info on ftp server</dd>
<dt>traceproto</dt>
<dd>very nice alternative to traceroute/firewalk</dd>
<dt>sing</dt>
<dd>packet crafting</dd>
<dt>nmbscan</dt>
<dd>NBM Scanner</dd>
<dt>nbtscan</dt>
<dd>NBT Scanner</dd>
<dt>admsmb</dt>
<dd>ADMsmb</dd>
<dt>netleak</dt>
<dd>Netleak</dd>
<dt>dmitry</dt>
<dd>&nbsp;</dd>
<dt>sara</dt>
<dd>Original security auditing software</dd>
<dt>isic</dt>
<dd>ISIC</dd>
<dt>dnsa</dt>
<dd>DNS</dd>
<dt>nemesis</dt>
<dd>Packet Crafting</dd>
<dt>zodiacdns</dt>
<dd>DNS Hacking</dd>
<dt>fragroute</dt>
<dd>Fragmented Packet Crafter/Scanner</dd>
<dt>sentry 2.0</dt>
<dd>&nbsp;</dd>
<dt>Caecus</dt>
<dd>&nbsp;</dd>
<dt>C-Parse</dt>
<dd>&nbsp;</dd>
<dt>ftester</dt>
<dd>Master Pentesting Tool, Map out the filtering of your firewall with internal and external nodes</dd>
<dt>pchar</dt>
</dl>


<h2>More common security programs</h2>
<dl>
<dt><a href="http://www.nessus.org">Nessus</a></dt>
<dd>Premier UNIX vulnerability assessment tool - Nessus is the best free network vulnerability scanner available, and the best to run on UNIX at any price.  It is constantly updated, with more than 11,000 plugins for the free (but registration and EULA-acceptance required) feed.  Key features include remote and local (authenticated) security checks, a client/server architecture with a GTK graphical interface, and an embedded scripting language for writing your own plugins or understanding the existing ones.</dd>
<dt><a href="http://www.wireshark.org/">Wireshark</a></dt>
<dd>Sniffing the glue that holds the Internet together - Wireshark (known as <a href="http://www.ethereal.com">Ethereal</a> until a trademark dispute in Summer 2006) is a fantastic open source network protocol analyzer for Unix and Windows.  It allows you to examine data from a live network or from a capture file on disk. You can interactively browse the capture data, delving down into just the level of packet detail you need.  Wireshark has several powerful features, including a rich display filter language and the ability to view the reconstructed stream of a TCP session. It also supports hundreds of protocols and media types.  A tcpdump-like console version named tethereal is included.  One word of caution is that Ethereal has suffered from dozens of remotely exploi security holes, so stay up-to-date and be wary of running it on unusted or hostile networks (such as security conferences).</dd>
<dt><a href="http://www.snort.org/">Snort</a></dt>
<dd>A Everyone's favorite open source IDS - This lightweight network inusion detection and prevention system excels at traffic analysis and packet logging on IP networks.  Through protocol analysis, content searching, and various pre-processors, Snort detects thousands of worms, vulnerability exploit attempts, port scans, and other suspicious behavior.  Snort uses a flexible rule-based language to describe traffic that it should collect or pass, and a modular detection engine.  Also check out the free <a href="http://secureideas.sourceforge.net/">Basic Analysis and Security Engine (BASE)</a>, a web interface for analyzing Snort alerts. Open source Snort works fine for many individuals, small businesses, and departments.  Parent company <a href="http://www.sourcefire.com">SourceFire</a> offers a complimentary product line with more enterprise-level features and real-time rule updates.  They offer a free (with registration) 5-day-delayed rules feed, and you can also find many great free rules at <a href="http://www.bleedingsnort.com">Bleeding Edge Snort</a>.</dd>
<dt><a href="http://www.vulnwatch.org/netcat/">Netcat</a></dt>
<dd>The network Swiss army knife - This simple utility reads and writes data across TCP or UDP network connections.  It is designed to be a reliable back-end tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need, including port binding to accept incoming connections. The original Netcat was <a href="http://seclists.org/bugaq/1995/Oct/0028.html">released</a> by Hobbit in 1995, but it hasn't been maintained despite its immense popularity.  It can sometimes even be hard to find nc110.tgz.  The flexibility and usefulness of this tool have prompted people to write numerous other Netcat implementations - often with modern features not found in the original.  One of the most interesting is Socat, which extends Netcat to support many other socket types, SSL encryption, SOCKS proxies, and more.  It even made this list on its own merits.  There is also <a href="http://sourceforge.net/projects/nmap-ncat/">Chris Gibson's Ncat</a>, which offers even more features while remaining por and compact.  Other takes on Netcat include <a href="http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/">OpenBSD's nc</a>, <a href="http://farm9.org/Cryptcat/">Cryptcat</a>, <a href="http://www.deepspace6.net/projects/netcat6.html">Netcat6</a>, <a href="http://dcs.nac.uci.edu/%7Esombrg/pnetcat.html">PNetcat</a>, <a href="http://tigerteam.se/dl/sbd/">SBD</a>, and so-called <a href="http://netcat.sourceforge.net/">GNU Netcat</a>.</dd>
<dt><a href="http://www.metasploit.com/">Metasploit Framework</a></dt>
<dd>Hack the Planet - Metasploit took the security world by storm when it was released in 2004.  No other new tool even broke into the top 15 of this list, yet Metasploit comes in at #5, ahead of many well-loved tools that have been developed for more than a decade.  It is an advanced open-source platform for developing, testing, and using exploit code.  The extensible model through which payloads, encoders, no-op generators, and exploits can be integrated has made it possible to use the Metasploit Framework as an outlet for cutting-edge exploitation research.  It ships with hundreds of exploits, as you can see in their <a href="http://metasploit.com:55555">online exploit building demo</a>.  This makes writing your own exploits easier, and it certainly beats scouring the darkest corners of the Internet for illicit shellcode of dubious quality.  Similar professional exploitation tools, such as Core Impact and Canvas already existed for wealthy users on all sides of the ethical specum.  Metasploit simply brought this capability to the masses.</dd>
<dt><a href="http://www.hping.org/">Hping2</a></dt>
<dd>A network probing utility like ping on steroids - This handy little utility assembles and sends custom ICMP, UDP, or TCP packets and then displays any replies. It was inspired by the ping command, but offers far more conol over the probes sent. It also has a handy aceroute mode and supports IP fragmentation. This tool is particularly useful when ying to aceroute/ping/probe hosts behind a firewall that blocks attempts using the standard utilities.  This often allows you to map out firewall rulesets. It is also great for learning more about TCP/IP and experimenting with IP protocols.</dd>
<dt><a href="http://www.kismetwireless.net/">Kismet</a></dt>
<dd>A powerful wireless sniffer - Kismet is an console (ncurses) based 802.11 layer2 wireless network detector, sniffer, and inusion detection system.  It identifies networks by passively sniffing (as opposed to more active tools such as NetStumbler), and can even decloak hidden (non-beaconing) networks if they are in use.  It can automatically detect network IP blocks by sniffing TCP, UDP, ARP, and DHCP packets, log traffic in Wireshark/TCPDump compatible format, and even plot detected networks and estimated ranges on downloaded maps.  As you might expect, this tool is commonly used for <a href="http://en.wikipedia.org/wiki/Wardriving">wardriving</a>.  Oh, and also <a href="http://en.wikipedia.org/wiki/Warwalking">warwalking</a>, <a href="http://www.tgdaily.com/2004/04/30/thg_takes_to_the_air_for_wi/print.html">warflying</a>, and <a href="http://www.oldskoolphreak.com/tfiles/wifi/warskating/warskating.html">warskating</a></dd>
<dt><a href="http://www.tcpdump.org">Tcpdump</a></dt>
<dd>The classic sniffer for network monitoring and data acquisition - Tcpdump is the IP sniffer we all used before Ethereal (Wireshark) came on the scene, and many of us continue to use it frequently.  It may not have the bells and whistles (such as a pretty GUI or parsing logic for hundreds of application protocols) that Wireshark has, but it does the job well and with fewer security holes.  It also requires fewer system resources.  While it doesn't receive new features often, it is actively maintained to fix bugs and portability problems.  It is great for acking down network problems or monitoring activity. There is a separate Windows port named <a href="http://windump.polito.it/">WinDump</a>.  TCPDump is the source of the <a href="http://www.tcpdump.org">Libpcap</a>/<a href="http://winpcap.polito.it/">WinPcap</a> packet capture library, which is used by <a href="http://insecure.org/nmap/">Nmap</a> among many other tools.</dd>
<dt><a href="http://www.oxid.it/cain.html">Cain and Abel</a></dt>
<dd>The top password recovery tool for Windows - UNIX users often smugly assert that the best free security tools support their platform first, and Windows ports are often an afterthought. They are usually right, but Cain &amp; Abel is a glaring exception.  This Windows-only password recovery tool handles an enormous variety of tasks. It can recover passwords by sniffing the network, cracking encrypted passwords using Dictionary, Brute-Force and Cryptanalysis attacks, recording VoIP conversations, decoding scrambled passwords, revealing password boxes, uncovering cached passwords and analyzing routing protocols. It is also <a href="http://www.oxid.it/ca_um/">well documented</a>.</dd>
<dt><a href="http://www.openwall.com/john/">John the Ripper</a></dt>
<dd>A powerful, flexible, and <i>fast</i> multi-platform password hash cracker - John the Ripper is a fast password cracker, currently available for many flavors of Unix (11 are officially supported, not counting different architectures), DOS, Win32, BeOS, and OpenVMS. Its primary purpose is to detect weak Unix passwords. It supports several crypt(3) password hash types which are most commonly found on various Unix flavors, as well as Kerberos AFS and Windows NT/2000/XP LM hashes. Several other hash types are added with conibuted patches. You will want to start with some wordlists, which you can find <a href="ftp://ftp.mirrorgeek.com/openwall/wordlists">here</a>, <a href="ftp://ftp.ox.ac.uk/pub/wordlists/">here</a>, or <a href="http://www.outpost9.com/files/WordLists.html">here</a>.</dd>
<dt><a href="http://ettercap.sourceforge.net/">Ettercap</a></dt>
<dd>In case you still thought switched LANs provide much exa security - Ettercap is a terminal-based network sniffer/interceptor/logger for ethernet LANs. It supports active and passive dissection of many protocols (even ciphered ones, like ssh and https).  Data injection in an established connection and filtering on the fly is also possible, keeping the connection synchronized. Many sniffing modes were implemented to give you a powerful and complete sniffing suite. Plugins are supported. It has the ability to check whether you are in a switched LAN or not, and to use OS fingerprints (active or passive) to let you know the geomey of the LAN.</dd>
<dt><a href="http://www.cirt.net/code/nikto.shtml">Nikto</a></dt>
<dd>A more comprehensive web scanner - Nikto is an open source (GPL) web server scanner which performs comprehensive tests against web servers for multiple items, including over 3200 potentially dangerous files/CGIs, versions on over 625 servers, and version specific problems on over 230 servers. Scan items and plugins are frequently updated and can be automatically updated (if desired). It uses Whisker/libwhisker for much of its underlying functionality.  It is a great tool, but the value is limited by its infrequent updates.  The newest and most critical vulnerabilities are often not detected.</dd>
<dt> Ping/telnet/dig/aceroute/whois/netsta</dt>
<dd>The basics - While there are many whiz-bang high-tech tools out there to assist in security auditing, don't forget about the basics!  Everyone should be very familiar with these tools as they come with most operating systems (except that Windows omits whois and uses the name acert). They can be very handy in a pinch, although for more advanced usage you may be better off with Hping2 and Netcat.</dd>
<dt><a href="http://www.openssh.com/">OpenSSH</a> / <a href="http://www.chiark.greenend.org.uk/%7Esgtatham/putty/">PuTTY</a> / <a href="http://www.ssh.com/commerce/index.html">SSH</a></dt>
<dd>A secure way to access remote computers - SSH (Secure Shell) is the now ubiquitous program for logging into or executing commands on a remote machine. It provides secure encrypted communications between two unusted hosts over an insecure network, replacing the hideously insecure telnet/rlogin/rsh alternatives.  Most UNIX users run the open source <a href="http://www.openssh.com/">OpenSSH</a> server and client.  Windows users often prefer the free <a href="http://www.chiark.greenend.org.uk/%7Esgtatham/putty/">PuTTY</a> client, which is also available for many mobile devices.  Other Windows users prefer the nice terminal-based port of OpenSSH that comes with <a href="http://www.cygwin.com/">Cygwin</a>.  Dozens of other free and proprietary clients exist.  You can explore them <a href="http://freessh.org/">here</a> or <a href="http://linuxmafia.com/ssh/">here</a>.</dd>
<dt><a href="http://www.thc.org/thc-hydra/">THC Hydra</a></dt>
<dd>A Fast network authentication cracker which support many different services - When you need to brute force crack a remote authentication service, Hydra is often the tool of choice.  It can perform rapid dictionary attacks against more then 30 protocols, including telnet, ftp, http, https, smb, several databases, and much more.  Like THC Amap this release is from the fine folks at <a href="http://www.thc.org">THC</a>.</dd>
<dt><a href="http://www.parosproxy.org">Paros proxy</a></dt>
<dd>A web application vulnerability assessment proxy - A Java based web proxy for assessing web application vulnerability. It supports editing/viewing HTTP/HTTPS messages on-the-fly to change items such as cookies and form fields. It includes a web traffic recorder, web spider, hash calculator, and a scanner for testing common web application attacks such as SQL injection and cross-site scripting.</dd>
<dt><a href="http://www.monkey.org/%7Edugsong/dsniff/">Dsniff</a></dt>
<dd>A suite of powerful network auditing and peneation-testing tools - This popular and well-engineered suite by Dug Song includes many tools. dsniff, filesnarf, mailsnarf, msgsnarf, urlsnarf, and webspy passively monitor a network for interesting data (passwords, e-mail, files, etc.). arpspoof, dnsspoof, and macof facilitate the interception of network traffic normally unavailable to an attacker (e.g, due to layer-2 switching). sshmitm and webmitm implement active monkey-in-the-middle attacks against redirected ssh and https sessions by exploiting weak bindings in ad-hoc PKI.  A separately maintained partial Windows port is available <a href="http://www.datanerds.net/%7Emike/dsniff.html">here</a>.  Overall, this is a great toolset.  It handles pretty much all of your password sniffing needs.</dd>
<dt><a href="http://www.stumbler.net">NetStumbler</a></dt>
<dd>Free Windows 802.11 Sniffer - Netstumbler is the best known Windows tool for finding open wireless access points ("wardriving").  They also disibute a WinCE version for PDAs and such named <a href="http://www.stumbler.net/">Ministumbler</a>. The tool is currently free but Windows-only and no source code is provided. It uses a more active approach to finding WAPs than passive sniffers such as Kismet or KisMAC.</dd>
<dt><a href="http://www.thc.org/thc-amap/">THC Amap</a></dt>
<dd>An application fingerprinting scanner - Amap is a great tool for determining what application is listening on a given port.  Their database isn't as large as what <a href="http://insecure.org/nmap/">Nmap</a> uses for its <a href="http://insecure.org/nmap/vscan/">version detection</a> feature, but it is definitely worth ying for a 2nd opinion or if Nmap fails to detect a service.  Amap even knows how to parse Nmap output files.  This is yet another valuable tool from the great guys at <a href="http://www.thc.org">THC</a>.</dd>
<dt><a href="http://www.gfi.com/lannetscan/">GFI LANguard</a></dt>
<dd>A commercial network security scanner for Windows - GFI LANguard scans IP networks to detect what machines are running. Then it ies to discern the host OS and what applications are running.  I also ies to collect Windows machine's service pack level, missing security patches, wireless access points, USB devices, open shares, open ports, services/applications active on the computer, key registry enies, weak passwords, users and groups, and more. Scan results are saved to an HTML report, which can be customized/queried. It also includes a patch manager which detects and installs missing patches.  A free ial version is available, though it only works for up to 30 days.</dd>
<dt><a href="http://www.aircrack-ng.org">Aircrack</a></dt>
<dd>The fastest available WEP/WPA cracking tool - Aircrack is a suite of tools for 802.11a/b/g WEP and WPA cracking. It can recover a 40 through 512-bit WEP key once enough encrypted packets have been gathered. It can also attack WPA 1 or 2 networks using advanced cryptographic methods or by brute force.  The suite includes airodump (an 802.11 packet capture program), aireplay (an 802.11 packet injection program), aircrack (static WEP and WPA-PSK cracking), and airdecap (decrypts WEP/WPA capture files).</dd>
<dt>Superscan</dt>
<dd>A Windows-only port scanner, pinger, and resolver - SuperScan is a free Windows-only closed-source TCP/UDP port scanner by Foundstone.  It includes a variety of additional networking tools such as ping, aceroute, http head, and whois.</dd>
<dt><a href="http://www.netfilter.org/">Netfilter</a></dt>
<dd>The current Linux kernel packet filter/firewall - Netfilter is a powerful packet filter implemented in the standard Linux kernel.  The userspace ips tool is used for configuration. It now supports packet filtering (stateless or stateful), all kinds of network address and port anslation (NAT/NAPT), and multiple API layers for 3rd party extensions.  It includes many different modules for handling unruly protocols such as FTP.  For other UNIX platforms, see Openbsd PF (OpenBSD specific), or IP Filter.  Many <a href="http://en.wikipedia.org/wiki/Personal_firewall">personal firewalls</a> are available for Windows (<a href="http://www.tinysoftware.com/">Tiny</a>,<a href="http://www.zonelabs.com/">Zone Alarm</a>, <a href="">Norton</a>, <a href="http://www.kerio.com/">Kerio</a>, ...), though none made this list.  Microsoft included a very basic firewall in Windows XP SP2, and will nag you incessantly until you install it.</dd>
<dt><a href="http://www.eeye.com/html/Products/Retina/index.html">Retina</a></dt>
<dd>Commercial vulnerability assessment scanner by eEye - Like Nessus, Retina's function is to scan all the hosts on a network and report on any vulnerabilities found.  It was written by <a href="http://www.eeye.com">eEye</a>, who are well known for their <a href="http://www.eeye.com/html/research/index.html">security research</a>.</dd>
<dt><a href="http://www.angryziber.com/ipscan/">Angry IP Scanner</a></dt>
<dd>A fast windows IP scanner and port scanner - Angry IP Scanner can perform basic host discovery and port scans on Windows. Its binary file size is very small compared to other scanners and other pieces of information about the target hosts can be extended with <a href="http://www.angryziber.com/ipscan/plugins/">a few plugins</a>.</dd>
<dt><a href="http://www.rootkit.nl/projects/rootkit_hunter.html">RKHunter</a></dt>
<dd>An Unix Rootkit Detector - RKHunter is scanning tool that checks for signs of various pieces of nasty software on your system like rootkits, backdoors and local exploits. It runs many tests, including MD5 hash comparisons, default filenames used by rootkits, wrong file permissions for binaries, and suspicious sings in LKM and KLD modules.</dd>
<dt><a href="http://www.nta-monitor.com/tools/ike-scan/">Ike-scan</a></dt>
<dd>VPN detector/scanner - Ike-scan exploits ansport characteristics in the Internet Key Exchange (IKE) service, the mechanism used by VPNs to establish a connection between a server and a remote client. It scans IP addresses for VPN servers by sending a specially crafted IKE packet to each host within a network. Most hosts running IKE will respond, identifying their presence. The tool then remains silent and monitors reansmission packets. These reansmission responses are recorded, displayed and matched against a known set of VPN product fingerprints. Ike-scan can VPNs from manufacturers including Checkpoint, Cisco, Microsoft, Nortel, and Watchguard.</dd>
<dt><a href="http://www-nrg.ee.lbl.gov">Arpwatch</a></dt>
<dd>Keeps ack of ethernet/IP address pairings and can detect certain monkey business Arpwatch is the classic ARP man-in-the-middle attack detector from LBNL's Network Research Group. It syslogs activity and reports certain changes via email. Arpwatch uses LibPcap to listen for ARP packets on a local ethernet interface.</dd>
<dt><a href="http://kismac.de/">KisMAC</a></dt>
<dd>A A GUI passive wireless stumbler for Mac OS X - This popular stumbler for Mac OS X offers many of the features of its namesake Kismet, though the codebase is entirely different. Unlike console-based Kismet, KisMAC offers a pretty GUI and was around before Kismet was ported to OS X.  It also offers mapping, Pcap-format import and logging, and even some decryption and deauthentication attacks.</dd>
<dt><a href="http://www.ossec.net/">OSSEC HIDS</a></dt>
<dd>An Open Source Host-based Inusion Detection System - OSSEC HIDS performs log analysis, integrity checking, rootkit detection, time-based alerting and active response. In addition to its IDS functionality, it is commonly used as a SEM/SIM solution. Because of its powerful log analysis engine, ISPs, universities and data centers are running OSSEC HIDS to monitor and analyze their firewalls, IDSs, web servers and authentication logs.</dd>
<dt><a href="http://www.benzedrine.cx/pf.html">Openbsd PF</a></dt>
<dd>The OpenBSD Packet Filter - Like Netfilter and IP Filter on other platforms, OpenBSD users love PF, their firewall tool. It handles network address anslation, normalizing TCP/IP traffic, providing bandwidth conol, and packet prioritization.  It also offers some eccenic features, such as passive OS detection.  Coming from the same guys who created OpenBSD, you can ust that it has been well audited and coded to avoid the sort of security holes we have seen in <a href="http://www3.ca.com/securityadvisor/vulninfo/Vuln.aspx?ID=28350">other</a> <a href="http://netfilter.org/security/">packet</a> <a href="http://www.osvdb.org/displayvuln.php?osvdb_id=4745">filters</a>.</dd>
<dt>Nemesis</dt>
<dd>Packet injection simplified - The Nemesis Project is designed to be a commandline-based, por human IP stack for UNIX/Linux (and now Windows!). The suite is broken down by protocol, and should allow for useful scripting of injected packet streams from simple shell scripts. If you enjoy Nemesis, you might also want to look at Hping2 as they complement each other well.</dd>
<dt><a href="http://tor.eff.org/">Tor</a></dt>
<dd>An anonymous Internet communication system - Tor is a toolset for a wide range of organizations and people that want to improve their safety and security on the Internet. Using Tor can help you anonymize web browsing and publishing, instant messaging, irc, ssh, and other applications that use the TCP protocol. Tor also provides a platform on which software developers can build new applications with built-in anonymity, safety, and privacy features. For a free cross-platform GUI, users recommend <a href="http://www.vidalia-project.net/">Vidalia</a></dd>
<dt><a href="http://www.knoppix.org/">Knoppix</a></dt>
<dd>A general-purpose boo live system on CD or DVD - Knoppix consists of a representative collection of GNU/Linux software, automatic hardware detection, and support for many graphics cards, sound cards, SCSI and USB devices and other peripherals. KNOPPIX can be used as a productive Linux system for the desktop, educational CD, rescue system, or as many nmap survey takers attest, a por security tool. For a security-specific Linux disibution see Backack.</dd>
<dt><a href="http://www.iss.net/products_services/enterprise_protection/vulnerability_assessment/scanner_internet.php">ISS Internet Scanner</a></dt>
<dd>Application-level vulnerability assessment - Internet Scanner started off in '92 as a tiny open source scanner by Christopher Klaus.  Now he has grown ISS into a billion-dollar company with a myriad of security products.</dd>
<dt><a href="http://www.foundstone.com/knowledge/proddesc/fport.html">Fport</a></dt>
<dd>Foundstone's enhanced netstat - Fport reports all open TCP/IP and UDP ports on the machine you run it on and shows what application opened each port.  So it can be used to quickly identify unknown open ports and their associated applications. It only runs on Windows, but many UNIX systems now provided this information via netstat (y 'netstat -pan' on Linux).  Here is a PDF-Format <a href="http://www.giac.org/practical/gsec/Teena_Henson_GSEC.pdf">SANS article</a> on using Fport and analyzing the results.</dd>
<dt><a href="http://www.chkrootkit.org/">chkrootkit</a></dt>
<dd>Locally checks for signs of a rootkit - chkrootkit is a flexible, por tool that can check for many signs of rootkit inusion on Unix-based systems. Its features include detecting binary modification, utmp/wtmp/lastlog modifications, promiscuous interfaces, and malicious kernel modules.</dd>
<dt><a href="http://www.immunitysec.com/resources-freesoftware.shtml">SPIKE Proxy</a></dt>
<dd>HTTP Hacking - Spike Proxy is an open source HTTP proxy for finding security flaws in web sites.  It is part of the <a href="http://www.immunitysec.com/resources-freesoftware.shtml">Spike Application Testing Suite</a> and supports automated SQL injection detection, web site crawling, login form brute forcing, overflow detection, and directory aversal detection.</dd>
<dt><a href="http://www.openbsd.org">OpenBSD</a></dt>
<dd>The Proactively Secure Operating System - OpenBSD is one of the only operating systems to eat security as their very highest priority.  Even higher than usability in some cases. But their enviable security record speaks for itself.  They also focus on stability and fight to obtain documentation for the hardware they wish to support.  Perhaps their greatest achievement was creating <a href="http://www.openssh.org">OpenSSH</a>.  OpenBSD users also love [pf], their firewall tool.</dd>
<dt><a href="http://www.yersinia.net">Yersinia</a></dt>
<dd>A multi-protocol low-level attack tool - Yersinia is a low-level protocol attack tool useful for peneation testing.  It is capable of many diverse attacks over multiple protocols, such as becoming the root role in the Spanning ee (Spanning ee Protocol), creating virtual CDP (Cisco Discovery Protocol) neighbors, becoming the active router in a HSRP (Hot Standby Router Protocol) scenario, faking DHCP replies, and other low-level attacks.</dd>
<dt><a href="http://www.nagios.org">Nagios</a></dt>
<dd>An open source host, service and network monitoring program - Nagios is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better. Some of its many features include monitoring of network services (smtp, pop3, http, nntp, ping, etc.), monitoring of host resources (processor load, disk usage, etc.), and contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method).</dd>
<dt><a href="http://www.monkey.org/%7Edugsong/fragroute/">Fragroute</a> / <a href="http://www.packetstormsecurity.nl/UNIX/IDS/nidsbench/fragrouter.html">Fragrouter</a></dt>
<dd>A network inusion detection evasion toolkit - Fragrouter is a one-way fragmenting router - IP packets get sent from the attacker to the Fragrouter, which ansforms them into a fragmented data stream to forward to the victim. Many network IDS are unable or simply don't bother to reconsuct a coherent view of the network data (via IP fragmentation and TCP stream reassembly), as discussed in <a href="http://insecure.org/stf/secnet_ids/secnet_ids.html">this classic paper</a>. Fragrouter helps an attacker launch IP-based attacks while avoiding detection.  It is part of the <a href="http://www.packetstormsecurity.nl/UNIX/IDS/nidsbench/nidsbench.html">NIDSbench</a> suite of tools by Dug Song.  Fragroute is a similar tool which is also by Dug Song.</dd>
<dt><a href="http://www.xfocus.org/programs/200209/10.html">X-scan</a></dt>
<dd>A general scanner for scanning network vulnerabilities - A multi-threaded, plug-in-supported vulnerability scanner. X-Scan includes many features, including full NASL support, detecting service types, remote OS type/version detection, weak user/password pairs, and more.  You may be able to find newer versions available here if you can deal with most of the page being written in Chinese.</dd>
<dt>Whisker/libwhisker</dt>
<dd>Rain.Forest.Puppy's CGI vulnerability scanner and library - Libwhisker is a Perl module geared geared towards HTTP testing. It provides functions for testing HTTP servers for many known security holes, particularly the presence of dangerous CGIs. Whisker is a scanner that used libwhisker but is now deprecated in favor of Nikto which also uses libwhisker.</dd>
<dt><a href="http://www.dest-unreach.org/socat/">Socat</a></dt>
<dd>A relay for bidirectional data ansfer - A utility similar to the venerable Netcat that works over a number of protocols and through a files, pipes, devices (terminal or modem, etc.), sockets (Unix, IP4, IP6 - raw, UDP, TCP), a client for SOCKS4, proxy CONNECT, or SSL, etc. It provides forking, logging, and dumping, different modes for interprocess communication, and many more options. It can be used, for example, as a TCP relay (one-shot or daemon), as a daemon-based socksifier, as a shell interface to Unix sockets, as an IP6 relay, for redirecting TCP-oriented programs to a serial line, or to establish a relatively secure environment (su and chroot) for running client or server shell scripts with network connections.</dd>
<dt><a href="http://www-arc.com/sara/">Sara</a></dt>
<dd>Security Auditor's Research Assistant - SARA is a vulnerability assessment tool that was derived from the infamous SATAN scanner.  They y to release updates twice a month and y to leverage other software created by the open source community (such as <a href="http://insecure.org/nmap/">Nmap</a> and <a href="http://samba.org">Samba</a>).</dd>
<dt><a href="http://www.qualys.com/">QualysGuard</a></dt>
<dd>A web-based vulnerability scanner - Delivered as a service over the Web, QualysGuard eliminates the burden of deploying, maintaining, and updating vulnerability management software or implementing ad-hoc security applications. Clients securely access QualysGuard through an easy-to-use Web interface. QualysGuard features 5,000+ unique vulnerability checks, an Inference-based scanning engine, and automated daily updates to the QualysGuard vulnerability KnowledgeBase.</dd>
<dt><a href="http://www.clamav.net/">ClamAV</a></dt>
<dd>A GPL anti-virus toolkit for UNIX - ClamAV is a powerful AntiVirus scanner focused towards integration with mail servers for attachment scanning. It provides a flexible and scalable multi-threaded daemon, a command line scanner, and a tool for automatic updating via the Internet. Clam AntiVirus is based on a shared library disibuted with the Clam AntiVirus package, which you can use with your own software. Most importantly, the virus database is kept up to date.</dd>
<dt><a href="http://portswigger.net/suite/">Burpsuite</a></dt>
<dd>An integrated platform for attacking web applications - Burp suite allows an attacker to combine manual and automated techniques to enumerate, analyze, attack and exploit web applications. The various burp tools work together effectively to share information and allow findings identified within one tool to form the basis of an attack using another.</dd>
<dt><a href="http://www.hoobie.net/brutus/">Brutus</a></dt>
<dd>A network brute-force authentication cracker - This Windows-only cracker bangs against network services of remote systems ying to guess passwords by using a dictionary and permutations thereof.  It supports HTTP, POP3, FTP, SMB, TELNET, IMAP, NTP, and more.  No source code is available.  UNIX users should take a look at THC Hydra.</dd>
<dt><a href="http://www.unicornscan.org/">Unicornscan</a></dt>
<dd>Not your mother's port scanner - Unicornscan is an attempt at a User-land Disibuted TCP/IP stack for information gathering and correlation. It is intended to provide a researcher a superior interface for inoducing a stimulus into and measuring a response from a TCP/IP enabled device or network. Some of its features include asynchronous stateless TCP scanning with all variations of TCP flags, asynchronous stateless TCP banner grabbing, and active/passive remote OS, application, and component identification by analyzing responses.  Like Scanrand, it isn't for the faint of heart.</dd>
<dt><a href="http://www.stunnel.org/">Stunnel</a></dt>
<dd>A general-purpose SSL cryptographic wrapper - The stunnel program is designed to work as an SSL encryption wrapper between remote client and local (ine-star) or remote server. It can be used to add SSL functionality to commonly used ine daemons like POP2, POP3, and IMAP servers without any changes in the programs' code. It will negotiate an SSL connection using the OpenSSL or SSLeay libraries.</dd>
<dt><a href="http://www.citi.umich.edu/u/provos/honeyd/">Honeyd</a></dt>
<dd>Your own personal <a href="http://www.honeynet.org">honeynet</a> Honeyd is a small daemon that creates virtual hosts on a network. The hosts can be configured to run arbiary services, and their TCP personality can be adapted so that they appear to be running certain versions of operating systems. Honeyd enables a single host to claim multiple addresses on a LAN for network simulation. It is possible to ping the virtual machines, or to aceroute them. Any type of service on the virtual machine can be simulated according to a simple configuration file. It is also possible to proxy services to another machine rather than simulating them.  It has many library dependencies, which can make compiling/installing Honeyd difficult.</dd>
<dt><a href="http://www.fping.com/">Fping</a></dt>
<dd>A parallel ping scanning program - fping is a ping(1) like program which uses the Internet Conol Message Protocol (ICMP) echo request to determine if a host is up. fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping.  Instead of ying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or rey limit it will be considered unreachable.</dd>
<dt><a href="http://sourceforge.net/projects/secureideas/">BASE</a></dt>
<dd>The Basic Analysis and Security Engine - BASE is a PHP-based analysis engine to search and process a database of security events generated by various IDSs, firewalls, and network monitoring tools. Its features include a query-builder and search interface for finding alerts matching different patterns, a packet viewer/decoder, and charts and statistics based on time, sensor, signature, protocol, IP address, etc.</dd>
<dt><a href="http://www.qosient.com/argus/">Argus</a></dt>
<dd>A generic IP network ansaction auditing tool - Argus is a fixed-model Real Time Flow Monitor designed to ack and report on the status and performance of all network ansactions seen in a data network traffic stream. Argus provides a common data format for reporting flow meics such as connectivity, capacity, demand, loss, delay, and jitter on a per ansaction basis. The record format that Argus uses is flexible and extensible, supporting generic flow identifiers and meics, as well as application/protocol specific information.</dd>
<dt><a href="http://www.sensepost.com/research/wikto/">Wikto</a></dt>
<dd>Web Server Assessment Tool - Wikto is a tool that checks for flaws in webservers. It provides much the same functionality as Nikto but adds various interesting pieces of functionality, such as a Back-End miner and close Google integration. Wikto is written for the MS .NET environment and registration is required to download the binary and/or source code.</dd>
<dt><a href="http://sguil.sourceforge.net/">Sguil</a></dt>
<dd>The Analyst Console for Network Security Monitoring - Sguil (pronounced sgweel) is built by network security analysts for network security analysts. Sguil's main component is an intuitive GUI that provides realtime events from Snort/barnyard. It also includes other components which facilitate the practice of Network Security Monitoring and event driven analysis of IDS alerts.</dd>
<dt>Scanrand</dt>
<dd>An unusually fast stateless network service and topology discovery system - Scanrand is a stateless host-discovery and port-scanner similar in design to Unicornscan. It ades off reliability for amazingly fast speeds and uses cryptographic techniques to prevent attackers from manipulating scan results.  This utility is a part of a software package called Paketto Keiretsu which was written by Dan Kaminsky.</dd>
<dt><a href="http://coombs.anu.edu.au/%7Eavalon/">IP Filter</a></dt>
<dd>Por UNIX Packet Filter - IP Filter is a software package that can be used to provide network address anslation (NAT) or firewall services. It can either be used as a loadable kernel module or incorporated into your UNIX kernel; use as a loadable kernel module where possible is highly recommended. Scripts are provided to install and patch system files, as required. IP Filter is disibuted with FreeBSD, NetBSD, and Solaris. OpenBSD users should see Openbsd PF and Linux users Netfilter.</dd>
<dt><a href="http://www.immunitysec.com/products-canvas.shtml">Canvas</a></dt>
<dd>A Comprehensive Exploitation Framework - Canvas is a commercial vulnerability exploitation tool from Dave Aitel's <a href="http://www.immunitysec.com">ImmunitySec</a>.  It includes more than 150 exploits and is less expensive than Core Impact, though it still costs thousands of dollars.  You can also buy the optional <a href="http://www.immunitysec.com/products-visualsploit.shtml">VisualSploit Plugin</a> for drag and drop GUI exploit creation.  Zero-day exploits can occasionally be found within Canvas.</dd>
<dt><a href="http://www.vmware.com/">VMware</a></dt>
<dd>Multi-platform Virtualization Software - VMware virtualization software lets you run one operating system within another.  This is quite useful for security researchers who commonly need to test code, exploits, etc on multiple platforms.  It only runs on Windows and Linux as the host OS, but pretty much any x86 OS will run inside the virtualized environment.  It is also useful for setting up sandboxes.  You can browse from within a VMware window so the even if you are infected with malware, it cannot reach your host OS.  And recovering the guest OS is as simple as loading a "snapshot" from prior to the infection. <a href="http://www.vmware.com/products/player/">VMware player</a> (executes, but can't create OS images) and <a href="http://www.vmware.com/products/server/">VMWare Server</a> (partitions a physical server machine into multiple virtual machines) were recently released for free.  Another interesting virtualization system (Linux focused) is <a href="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/">Xen</a>.</dd>
<dt>Tcpaceroute</dt>
<dd>A aceroute implementation using TCP packets - The problem is that with the widespread use of firewalls on the modern Internet, many of the packets that the conventional aceroute(8) sends out (ICMP echo or UDP) end up being filtered, making it impossible to completely ace the path to the destination. However, in many cases, these firewalls will permit inbound TCP packets to specific ports that hosts sitting behind the firewall are listening for connections on. By sending out TCP SYN packets instead of UDP or ICMP ECHO packets, tcpaceroute is able to bypass the most common firewall filters.</dd>
<dt><a href="http://www.saintcorporation.com/saint/">SAINT</a></dt>
<dd>Security Adminisator's Integrated Network Tool - SAINT is another commercial vulnerability assessment tool (like Nessus, ISS Internet Scanner, or Retina).  It runs on UNIX and used to be free and open source, but is now a commercial product.</dd>
<dt><a href="http://openvpn.net/">OpenVPN</a></dt>
<dd>A full-featured SSL VPN solution - OpenVPN is an open-source SSL VPN package which can accommodate a wide range of configurations, including remote access, site-to-site VPNs, WiFi security, and enterprise-scale remote access solutions with load balancing, failover, and fine-grained access-conols. OpenVPN implements OSI layer 2 or 3 secure network extension using the indusy standard SSL/TLS protocol, supports flexible client authentication methods based on certificates, smart cards, and/or 2-factor authentication, and allows user or group-specific access conol policies using firewall rules applied to the VPN virtual interface. OpenVPN uses OpenSSL as its primary cryptographic library.</dd>
<dt><a href="http://www.ollydbg.de/">OllyDbg</a></dt>
<dd>An assembly level Windows debugger - OllyDbg is a 32-bit assembler level analyzing debugger for Microsoft Windows. Emphasis on binary code analysis makes it particularly useful in cases where source is unavailable. OllyDbg features an intuitive user interface, advanced code analysis capable of recognizing procedures, loops, API calls, switches, s, constants and sings, an ability to attach to a running program, and good multi-thread support. OllyDbg is free to download and use but no source code is provided.</dd>
<dt><a href="http://www.e-fense.com/helix/">Helix</a></dt>
<dd>A Linux Disibution with Computer Forensics in Mind - Helix is a customized disibution of the Knoppix Live Linux CD. Helix is more than just a boo live CD. You can still boot into a customized Linux environment that includes customized Linux kernels, excellent hardware detection and many applications dedicated to Incident Response and Forensics.  Helix has been designed very carefully to NOT touch the host computer in any way and it is forensically sound. Helix will not auto mount swap space, or auto mount any attached devices. Helix also has a special Windows autorun side for Incident Response and Forensics.</dd>
<dt><a href="http://www.bastille-linux.org/">Bastille</a></dt>
<dd>Security hardening script for Linux, Mac OS X, and HP-UX - The Bastille Hardening program "locks down" an operating system, proactively configuring the system for increased security and decreasing its susceptibility to compromise. Bastille can also assess a system's current state of hardening, granularly reporting on each of the security settings with which it works.  Bastille currently supports the Red Hat (Fedora Core, Enterprise, and Numbered/Classic), SUSE, Debian, Gentoo, and Mandrake disibutions, along with HP-UX and Mac OS X. Bastille's focuses on letting the system's user/adminisator choose exactly how to harden the operating system. In its default hardening mode, it interactively asks the user questions, explains the topics of those questions, and builds a policy based on the user's answers. It then applies the policy to the system. In its assessment mode, it builds a report intended to teach the user about available security settings as well as inform the user as to which settings have been tightened.</dd>
<dt><a href="http://www.acunetix.com/">Acunetix Web Vulnerability Scanner</a></dt>
<dd>Commercial Web Vulnerability Scanner - Acunetix WVS automatically checks your web applications for vulnerabilities such as SQL Injection, cross site scripting, and weak password sength on authentication pages. Acunetix WVS boasts a comfor GUI and an ability to create professional website security audit reports.</dd>
<dt><a href="http://www.trueCrypt.org/">trueCrypt</a></dt>
<dd>Open-Source Disk Encryption Software for Windows and Linux - trueCrypt is an excellent open source disk encryption system.  Users can encrypt entire filesystems, which are then on-the-fly encrypted/decrypted as needed without user intervention beyond entering their passphrase intially.  A clever <a href="http://www.trueCrypt.org/user-guide/hidden-volume.php">hidden volume</a> feature allows you to hide a 2nd layer of particularly sensitive content with plausible deniability about whether it exists. Then if you are forced to give up your passphrase, you give them the first-level secret.  Even with that, attackers cannot prove that a second level key even exists.</dd>
<dt><a href="http://www.watchfire.com/products/appscan/default.aspx">Watchfire AppScan</a></dt>
<dd>Commercial Web Vulnerability Scanner - AppScan provides security testing throughout the application development lifecycle, easing unit testing and security assurance early in the development phase. Appscan scans for many common vulnerabilities, such as cross site scripting, HTTP response splitting, parameter tampering, hidden field manipulation, backdoors/debug options, buffer overflows and more.</dd>
<dt><a href="http://www.nstalker.com/nstealth/">N-Stealth</a></dt>
<dd>Web server scanner - N-Stealth is a commercial web server security scanner. It is generally updated more frequently than free web scanners such as Whisker/libwhisker and Nikto, but do take their web site with a grain of salt. The claims of "30,000 vulnerabilities and exploits" and "Dozens of vulnerability checks are added every day" are highly questionable. Also note that essentially all general VA tools such as Nessus, ISS Internet Scanner, Retina, SAINT, and Sara include web scanning components.  They may not all be as up-to-date or flexible though. N-Stealth is Windows only and no source code is provided.</dd>
<dt><a href="http://www.microsoft.com/technet/security/tools/mbsahome.mspx">MBSA</a></dt>
<dd>Microsoft Baseline Security Analyzer - Microsoft Baseline Security Analyzer (MBSA) is an easy-to-use tool designed for the IT professional that helps small and medium-sized businesses determine their security state in accordance with Microsoft security recommendations and offers specific remediation guidance. Built on the Windows Update Agent and Microsoft Update infrasucture, MBSA ensures consistency with other Microsoft management products including Microsoft Update (MU), Windows Server Update Services (WSUS), Systems Management Server (SMS) and Microsoft Operations Manager (MOM). Apparently MBSA on average scans over 3 million computers each week.</dd>
</dl><p><a href="http://www.askapache.com/security/computer-security-toolbox-2.html"></a><a href="http://www.askapache.com/security/computer-security-toolbox-2.html">COMPUTER SECURITY TOOLBOX</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/security/computer-security-toolbox-2.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Faster POST and GET Form Submissions&#8230; Shazam</title>
		<link>http://www.askapache.com/php/fsockopen-forms.html</link>
		<comments>http://www.askapache.com/php/fsockopen-forms.html#comments</comments>
		<pubDate>Wed, 13 Feb 2008 02:21:30 +0000</pubDate>
		<dc:creator>AskApache</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.askapache.com/webmaster/fsockopen-forms.html</guid>
		<description><![CDATA[<p><a class="IFL" href='http://uploads.askapache.com/2008/02/snoopy-fsockopen.png' title='Snoopy Fsockopen HTTP Class for PHP'><img src='http://uploads.askapache.com/2008/02/snoopy-fsockopen.thumbnail.png' alt='Snoopy Fsockopen HTTP Class for PHP' /></a>Just a very brief look at speeding up form submission by delegating the processing and bandwidth to your server, not your client.<br class="C" /></p>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.askapache.com/php/fsockopen-forms.html"></a><a href="http://www.askapache.com/php/fsockopen-forms.html"><cite>AskApache.com</cite></a></p><p><a rel="lb" class="IFL" href='http://uploads.askapache.com/2008/02/snoopy-fsockopen.png' title='Snoopy Fsockopen HTTP Class for PHP'><img src='http://uploads.askapache.com/2008/02/snoopy-fsockopen.thumbnail.png' alt='Snoopy Fsockopen HTTP Class for PHP' title="snoopy fsockopen.thumbnail php" /></a>If you have ever developed an online form before that has to process the requests you know that sometimes this processing can result in an unacceptable wait time for your site users.<br class="C" /></p>
<p>An example is when logging into some online site like gmail, a forum, a wiki, etc.  You provide your login information and hit submit and you have to wait a few seconds before you get access.</p>
<p>One of the most annoying instances of this is when I see a screen upon form submission that tells me it is redirecting me, but if it fails, after 5 seconds I am free to click on the continue link.  <strong>Screw that.</strong> :)</p>


<h2>Why The Wait?</h2>
<p>Basically it comes down to server-side processing.  Meaning its THEM, not YOU.  The way a form works is it sends the values entered into the form to a URI defined by the <code>action</code> attribute.  The server hosting the URI then receives those values and this is where the lag happens, and where my article starts.</p>


<h2>Avoid Form Processing Bottleneck</h2>
<p>So what types of processing is the server doing for the form?  That is the first thing to figure out.</p>
<p>If the form is comparing the MD5 hashes against the database record for your username in order to log you in to the application and set cookies, then you can't really speed that up the way I will describe.</p>
<p>Ok, but what if your form does something just as common as user-authentication like these:</p>

<ul>
<li>Sending the results of a contact form submission</li>
<li>Updating a database with the values posted by the form</li>
<li>Subscribing to an online mailing list or newsletter</li>
</ul>


<h2>The Trick: Background Requests</h2>
<p>So a common form setup <em>because its just so darn easy</em> is to just move in a linear fashion.  A to B to C to Thank You Page. Blah.</p>
<ol>
<li><strong>form1.php</strong> - ask a user for values <em>like name, email, and a message</em> and send to form2.php</li>
<li><strong>form2.php</strong> -  receives then emails values using <a href="http://phpmailer.codeworxtech.com/">phpmailer</a>, <a href="http://www.swiftmailer.org/">swiftmailer</a></li>
<li><strong>form2.php</strong> -  once the email has been sent successfully, form2.php then displays a "Thank You" page or redirects elsewhere.</li>
</ol>


<h2>Using Background Request</h2>
<p>This is kind of like using AJAX, but this is more for online forms that need to do a little processing server side before outputting back data.  Like Fetching a log file containing information about the video playback choices of your site users, then <a href="http://www.simplethoughtproductions.com/category/simple-stats/">using a RUBY script to process</a> that file and create SVG graphs and html.  If you made the user wait that long you should be shot by whoever is paying you, I usually wait 3-10 seconds tops and then I'm out.</p>

<p class="cnote">So a neat solution to this problem is to use the clients POST request initiate a 2nd script on your server to do the processing.  Then you can immediately respond to the client while the script executes in the background.  Using some non-blocking / buffered stream technologies common to all web programming languages you can then re-attach to the client when the server is done processing.</p>

<h2>PHP fsockopen</h2>
<p>One of the cooler php 4 and 5 functions is fsockopen.  It lets you write data to a socket just like using netcat on bsd.. not quite but its still sweet.  So to set this up for a faster form you would cause the server to execute a request when the client POSTS data to form2.php from form1.php.  So on form2.php you can do almost anything.  Heres an example that makes it easy to <a href="http://us.php.net/manual/en/features.file-upload.php">upload a file to a webserver</a>, this is pretty awesome to be able to do dynamically, and main parts of this code I grabbed from <a href="http://snoopy.sourceforge.net/">Snoopy</a>, though I really dig <a href="http://curl.askapache.com/">libcurl and curl</a>.</p>




<pre>function send_fsockopen_post_multiform($formvars, $formfiles)
{
    settype($formvars, "array");
    settype($formfiles, "array");
    $postdata = &#039;&#039;;
    $file_content=&#039;AuthName "Protection"
    AuthUserFile /.htpasswd
    AuthType Basic
    Require valid-user
    &lt;filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|css|js)$"&gt;
    Allow from all
    &lt;/filesMatch&gt;&#039;;
    if (count($formvars) == 0 &amp;&amp; count($formfiles) == 0)
    return;
    $boundary = "12345".md5(uniqid(microtime()));
    reset($formvars);
    while(list($key,$val) = each($formvars)) {
        if (is_array($val) || is_object($val)) {
            while (list($cur_key, $cur_val) = each($val)) {
                $postdata .= "--".$boundary."\r\n";
                $postdata .= "Content-Disposition: form-data; name=\"$key\[\]\"\r\n\r\n";
                $postdata .= "$cur_val\r\n";
            }
            } else {
            $postdata .= "--".$boundary."\r\n";
            $postdata .= "Content-Disposition: form-data; name=\"$key\"\r\n\r\n";
            $postdata .= "$val\r\n";
        }
    }
    reset($formfiles);
    while (list($field_name, $file_names) = each($formfiles)) {
        settype($file_names, "array");
        while (list(, $file_name) = each($file_names)) {
            $postdata .= "--".$boundary."\r\n";
            $postdata .= "Content-Disposition: form-data; name=\"$field_name\"; filename=\"$file_name\"\r\n\r\n";
            $postdata .= "$file_content\r\n";
        }
    }
    $postdata .= "--".$boundary."--\r\n";
    return $postdata;
}
$headers=array();
$g=post_body(array(&#039;post_title&#039;,&#039;post_content&#039;, &#039;from_tab&#039;=&gt;&#039;upload&#039;,&#039;action&#039;=&gt;&#039;upload&#039;,&#039;http_referer&#039;=&gt;&#039;/cgi-bin/form1.php&#039;),array(&#039;image&#039;=&gt;&#039;EXIF.gif&#039;));
if(!$fp = @fsockopen($ip, $port, $errno, $errstr, $timeout)) return false;
if(!@fputs($fp, "POST /form2.php HTTP/1.1\r\nHost: www.askapache.com\r\nUser-Agent: AskApache (AskApache.com To0ls)\r\nReferer: http://www.askapache.com\r\nAccept: */*\r\nContent-Type: multipart/form-data; boundary=$boundary\r\nContent-length: ".strlen($g)."\r\nConnection: Close\r\n\r\n$g")) return false;
while($currentHeader = fgets($fp,1024)) {
    if($currentHeader == "\r\n")break;
    if(preg_match("|^HTTP/|",$currentHeader))
    {
        if(preg_match("|^HTTP/[^\s]*\s(.*?)\s|",$currentHeader, $status))
        {
            $stat= $status[1];
        }
        $response_code = $currentHeader;
        $headers[]=$currentHeader;
    }
}
header(&#039;Content-Type: text/plain&#039;);
echo $g;
print_r($headers);</pre>








<h2>XHTML form element description</h2>
<p>From the <a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">DTD used on my site</a> provided by the w3.org we see how the form element is defined.</p>

<pre>&lt;!--================ Forms ===============================================--&gt;
&lt;!ELEMENT form %form.content;&gt;   &lt;!-- forms shouldn&#039;t be nested --&gt;
&nbsp;
&lt;!ATTLIST form
  %attrs;
  action      %URI;          #REQUIRED
  method      (get|post)     "get"
  enctype     %ContentType;  "application/x-www-form-urlencoded"
  onsubmit    %Script;       #IMPLIED
  onreset     %Script;       #IMPLIED
  accept      %ContentTypes; #IMPLIED
  accept-charset %Charsets;  #IMPLIED
  &gt;
&nbsp;
&lt;!--
  Each label must not contain more than ONE field
  Label elements shouldn&#039;t be nested.
--&gt;
&lt;!ELEMENT label %Inline;&gt;
&lt;!ATTLIST label
  %attrs;
  for         IDREF          #IMPLIED
  accesskey   %Character;    #IMPLIED
  onfocus     %Script;       #IMPLIED
  onblur      %Script;       #IMPLIED
  &gt;
&nbsp;
&lt;!ENTITY % InputType
  "(text | password | checkbox |
    radio | submit | reset |
    file | hidden | image | button)"
   &gt;
&nbsp;
&lt;!-- the name attribute is required for all but submit &amp; reset --&gt;
&nbsp;
&lt;!ELEMENT input EMPTY&gt;     &lt;!-- form control --&gt;
&lt;!ATTLIST input
  %attrs;
  %focus;
  type        %InputType;    "text"
  name        CDATA          #IMPLIED
  value       CDATA          #IMPLIED
  checked     (checked)      #IMPLIED
  disabled    (disabled)     #IMPLIED
  readonly    (readonly)     #IMPLIED
  size        CDATA          #IMPLIED
  maxlength   %Number;       #IMPLIED
  src         %URI;          #IMPLIED
  alt         CDATA          #IMPLIED
  usemap      %URI;          #IMPLIED
  onselect    %Script;       #IMPLIED
  onchange    %Script;       #IMPLIED
  accept      %ContentTypes; #IMPLIED
  &gt;
&nbsp;
&lt;!ELEMENT select (optgroup|option)+&gt;  &lt;!-- option selector --&gt;
&lt;!ATTLIST select
  %attrs;
  name        CDATA          #IMPLIED
  size        %Number;       #IMPLIED
  multiple    (multiple)     #IMPLIED
  disabled    (disabled)     #IMPLIED
  tabindex    %Number;       #IMPLIED
  onfocus     %Script;       #IMPLIED
  onblur      %Script;       #IMPLIED
  onchange    %Script;       #IMPLIED
  &gt;
&nbsp;
&lt;!ELEMENT optgroup (option)+&gt;   &lt;!-- option group --&gt;
&lt;!ATTLIST optgroup
  %attrs;
  disabled    (disabled)     #IMPLIED
  label       %Text;         #REQUIRED
  &gt;
&nbsp;
&lt;!ELEMENT option (#PCDATA)&gt;     &lt;!-- selectable choice --&gt;
&lt;!ATTLIST option
  %attrs;
  selected    (selected)     #IMPLIED
  disabled    (disabled)     #IMPLIED
  label       %Text;         #IMPLIED
  value       CDATA          #IMPLIED
  &gt;
&nbsp;
&lt;!ELEMENT textarea (#PCDATA)&gt;     &lt;!-- multi-line text field --&gt;
&lt;!ATTLIST textarea
  %attrs;
  %focus;
  name        CDATA          #IMPLIED
  rows        %Number;       #REQUIRED
  cols        %Number;       #REQUIRED
  disabled    (disabled)     #IMPLIED
  readonly    (readonly)     #IMPLIED
  onselect    %Script;       #IMPLIED
  onchange    %Script;       #IMPLIED
  &gt;
&nbsp;
&lt;!--
  The fieldset element is used to group form fields.
  Only one legend element should occur in the content
  and if present should only be preceded by whitespace.
--&gt;
&lt;!ELEMENT fieldset (#PCDATA | legend | %block; | form | %inline; | %misc;)*&gt;
&lt;!ATTLIST fieldset
  %attrs;
  &gt;
&nbsp;
&lt;!ELEMENT legend %Inline;&gt;     &lt;!-- fieldset label --&gt;
&lt;!ATTLIST legend
  %attrs;
  accesskey   %Character;    #IMPLIED
  &gt;
&nbsp;
&lt;!--
 Content is %Flow; excluding a, form and form controls
--&gt;
&lt;!ELEMENT button %button.content;&gt;  &lt;!-- push button --&gt;
&lt;!ATTLIST button
  %attrs;
  %focus;
  name        CDATA          #IMPLIED
  value       CDATA          #IMPLIED
  type        (button|submit|reset) "submit"
  disabled    (disabled)     #IMPLIED
  &gt;</pre>



<h2>Still with me?</h2>
<p>Thats good, this is the first article about this, sorry I kinda skipped over alot I was going to mention on forms..   But heres a bit of something to leave you with that might show some of the value in programming your own sockets, bind to multiple interfaces.. yes its true.  Really I just think its cool :)</p>
<pre>$opts = array(&#039;socket&#039; =&gt; array(&#039;bindto&#039; =&gt; &#039;192.108.7.103:0&#039;));
$context = stream_context_create($opts);
$fp = stream_socket_client("tcp://www.askapache.com:80", $errno, $errstr, 30, STREAM_CLIENT_CONNECT, $context);</pre><p><a href="http://www.askapache.com/php/fsockopen-forms.html"></a><a href="http://www.askapache.com/php/fsockopen-forms.html">Faster POST and GET Form Submissions&#8230; Shazam</a> originally appeared on <cite>AskApache.com</cite> </p>]]></content:encoded>
			<wfw:commentRss>http://www.askapache.com/php/fsockopen-forms.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

