<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: title code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 07:18:57 GMT</pubDate>
    <description>DZone Snippets: title code</description>
    <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>Populate titlebar in any term</title>
      <link>http://snippets.dzone.com/posts/show/4175</link>
      <description>Populate your titlebar in any term with some useful info such as uname -a, architecture, if you're ROOT or not, etc.  In Linux:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;HOST_NAME=`hostname -f`&lt;br /&gt;if [ `id -u` = 0 ]; then&lt;br /&gt;OPT=&#8221;`uname` (`uname -a | cut -f12 -d&#8217; &#8216; -`) - ROOT USER&#8221;&lt;br /&gt;else&lt;br /&gt;OPT=&#8221;`uname` (`uname -a | cut -f12 -d&#8217; &#8216; -`)&#8221;&lt;br /&gt;fi&lt;br /&gt;REPLACE=&#8221;${HOST_NAME} - ${OPT}&#8221;&lt;br /&gt;echo -n -e &#8220;\033]0; $REPLACE \007 &#8220;&lt;br /&gt;echo &#8220;${REPLACE}&#8221;&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Then run this script, and your termtitle will be something like the following:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Servername (Linux / x86_64).&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;For Solaris it needs to be done a bit differently:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/local/bin/bash&lt;br /&gt;HOST_NAME=`uname -a | cut -f2 -d&#8217; &#8216; -`&lt;br /&gt;OPT=&#8221;(`uname -a | cut -f1 -d&#8217; &#8216; -` / `uname -a | cut -f6 -d&#8217; &#8216;`)&#8221;&lt;br /&gt;REPLACE=&#8221;${HOST_NAME} - ${OPT}&#8221;&lt;br /&gt;echo -n -e &#8220;\033]0; $REPLACE \007 &#8220;&lt;br /&gt;echo &#8220;${REPLACE}&#8221;&lt;br /&gt;exit 0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Add/remove things from the OPT= line to customize.  To test it, just issue the command on the commandline without the ()'s to see what it'll look like.</description>
      <pubDate>Wed, 20 Jun 2007 18:28:35 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4175</guid>
      <author>fak3r (fak3r)</author>
    </item>
    <item>
      <title>Extracting web page title</title>
      <link>http://snippets.dzone.com/posts/show/3060</link>
      <description>Easy extracting html 'title' element from an url&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;require 'open-uri'&lt;br /&gt;&lt;br /&gt;URI.parse('http://google.es').open do |f|&lt;br /&gt;	f.each {|l| if md = (/&lt;title&gt;\s*(.*)\s*&lt;\/title&gt;/iu).match(l) then print md[1] end }&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Wed, 29 Nov 2006 21:24:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3060</guid>
      <author>demimismo (David Arango)</author>
    </item>
    <item>
      <title>change title with javascript</title>
      <link>http://snippets.dzone.com/posts/show/2617</link>
      <description>// change title with javascript&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;..&lt;br /&gt;&lt;title&gt;original title&lt;/title&gt;&lt;br /&gt;..&lt;br /&gt;&lt;script type="text/javascript"&gt;&lt;br /&gt;function changeTitle(title) { document.title = title; }&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;..&lt;br /&gt;&lt;input type='button' onclick='changeTitle("new title")' value='Change Title'/&gt; &lt;br /&gt;..&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 17 Sep 2006 21:36:52 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2617</guid>
      <author>ovhaag (Oliver Haag)</author>
    </item>
  </channel>
</rss>
