<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: helpful code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 28 Aug 2008 21:05:55 GMT</pubDate>
    <description>DZone Snippets: helpful code</description>
    <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>
  </channel>
</rss>
