<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: terminal code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 12:42:25 GMT</pubDate>
    <description>DZone Snippets: terminal code</description>
    <item>
      <title>Print color highlighted strings to unix terminal</title>
      <link>http://snippets.dzone.com/posts/show/5445</link>
      <description>Sample of escape sequences needed to print in color to unix/linux terminal.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;print x.replace('toostis', '\033[0;31mtoostis\033[m')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This will highlight all 'toostis' instances in x with red.</description>
      <pubDate>Wed, 30 Apr 2008 11:06:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5445</guid>
      <author>kedder (Andrey lebedev)</author>
    </item>
    <item>
      <title>Bash title random Quote routine</title>
      <link>http://snippets.dzone.com/posts/show/5428</link>
      <description>#&lt;br /&gt;#this is a script in my .bash_profile that gets a random&lt;br /&gt;#quote .txt file and assigns it to the terminal title.&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;quote_path="/Users/glynch/Documents/quotes/*"&lt;br /&gt;files=($quote_path)&lt;br /&gt;N=${#files[@]}&lt;br /&gt;((N=RANDOM%N))&lt;br /&gt;randomfile=${files[$N]}&lt;br /&gt;quote=""&lt;br /&gt;while read line; do quote="$quote $line"; done &lt; $randomfile&lt;br /&gt;echo -n -e "\033]0;$quote\007"</description>
      <pubDate>Thu, 24 Apr 2008 19:43:08 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5428</guid>
      <author>robotsu (Robot)</author>
    </item>
    <item>
      <title>Untill keypressed / conio.h</title>
      <link>http://snippets.dzone.com/posts/show/5030</link>
      <description>Turbo Pascal and conio.h allowed immediate character reading, without wainting for enter. Following code does the same under unix terminals:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;#include &lt;termios.h&gt;&lt;br /&gt;&lt;br /&gt;char getch(void) {&lt;br /&gt;        char buf = 0;&lt;br /&gt;        struct termios old = {0};&lt;br /&gt;        if (tcgetattr(0, &amp;old) &lt; 0)&lt;br /&gt;                perror("tcsetattr()");&lt;br /&gt;        old.c_lflag &amp;= ~ICANON;&lt;br /&gt;        old.c_lflag &amp;= ~ECHO;&lt;br /&gt;        old.c_cc[VMIN] = 1;&lt;br /&gt;        old.c_cc[VTIME] = 0;&lt;br /&gt;        if (tcsetattr(0, TCSANOW, &amp;old) &lt; 0)&lt;br /&gt;                perror("tcsetattr ICANON");&lt;br /&gt;        if (read(0, &amp;buf, 1) &lt; 0)&lt;br /&gt;                perror ("read()");&lt;br /&gt;        old.c_lflag |= ICANON;&lt;br /&gt;        old.c_lflag |= ECHO;&lt;br /&gt;        if (tcsetattr(0, TCSADRAIN, &amp;old) &lt; 0)&lt;br /&gt;                perror ("tcsetattr ~ICANON");&lt;br /&gt;        return (buf);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main() {&lt;br /&gt;        char key;&lt;br /&gt;        printf("Press 'x' to exit...\n");&lt;br /&gt;        while((key=getch()) &amp;&amp; (key != 'x'))&lt;br /&gt;                printf ("you pressed %c\n", key);&lt;br /&gt;        return(0);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 23 Jan 2008 03:29:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5030</guid>
      <author>ptr128 (Mariusz)</author>
    </item>
    <item>
      <title>Colorized text from php in unix terminals</title>
      <link>http://snippets.dzone.com/posts/show/3292</link>
      <description>Colorized text from php in unix terminals&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# first define colors to use&lt;br /&gt;$_colors = array(&lt;br /&gt;        LIGHT_RED      =&gt; "[1;31m",&lt;br /&gt;        LIGHT_GREEN     =&gt; "[1;32m",&lt;br /&gt;        YELLOW         =&gt; "[1;33m",&lt;br /&gt;        LIGHT_BLUE     =&gt; "[1;34m",&lt;br /&gt;        MAGENTA     =&gt; "[1;35m",&lt;br /&gt;        LIGHT_CYAN     =&gt; "[1;36m",&lt;br /&gt;        WHITE         =&gt; "[1;37m",&lt;br /&gt;        NORMAL         =&gt; "[0m",&lt;br /&gt;        BLACK         =&gt; "[0;30m",&lt;br /&gt;        RED         =&gt; "[0;31m",&lt;br /&gt;        GREEN         =&gt; "[0;32m",&lt;br /&gt;        BROWN         =&gt; "[0;33m",&lt;br /&gt;        BLUE         =&gt; "[0;34m",&lt;br /&gt;        CYAN         =&gt; "[0;36m",&lt;br /&gt;        BOLD         =&gt; "[1m",&lt;br /&gt;        UNDERSCORE     =&gt; "[4m",&lt;br /&gt;        REVERSE     =&gt; "[7m",&lt;br /&gt;&lt;br /&gt;);&lt;br /&gt;##############################################&lt;br /&gt;# Output colorized text to terminal run&lt;br /&gt;# php scripts..&lt;br /&gt;##############################################&lt;br /&gt;function termcolored($text, $color="NORMAL", $back=1){&lt;br /&gt;    global $_colors;&lt;br /&gt;    $out = $_colors["$color"];&lt;br /&gt;    if($out == ""){ $out = "[0m"; }&lt;br /&gt;    if($back){&lt;br /&gt;        return chr(27)."$out$text".chr(27)."[0m";#.chr(27);&lt;br /&gt;    }else{&lt;br /&gt;        echo chr(27)."$out$text".chr(27).chr(27)."[0m";#.chr(27);&lt;br /&gt;    }//fi&lt;br /&gt;}// end function&lt;br /&gt;##############################################&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 16 Jan 2007 23:30:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3292</guid>
      <author>joeldg (joeldg)</author>
    </item>
    <item>
      <title>Linux - XTerm font size</title>
      <link>http://snippets.dzone.com/posts/show/2993</link>
      <description>// Aumenta la dimensione del carattere sul terminale&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;xterm -geometry 640x480 -fn *-fixed-*-*-*-20-*&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 13 Nov 2006 22:53:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2993</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Run R from the command line</title>
      <link>http://snippets.dzone.com/posts/show/2637</link>
      <description>// This runs R from the command line in batch mode.&lt;br /&gt;// The log file is output to track R's progress&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;R CMD BATCH --vanilla path/to/file.R file.log &amp;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 22 Sep 2006 02:52:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2637</guid>
      <author>mroutley (Matthew Routley)</author>
    </item>
    <item>
      <title>Fix Terminal spacing bug</title>
      <link>http://snippets.dzone.com/posts/show/2268</link>
      <description>&lt;pre&gt;defaults write com.apple.Terminal FontWidthSpacing 1.003&lt;/pre&gt;</description>
      <pubDate>Wed, 12 Jul 2006 08:45:18 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2268</guid>
      <author>willcodeforfoo ()</author>
    </item>
  </channel>
</rss>
