Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

fak3r http://fak3r.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Populate titlebar in any term

Populate your titlebar in any term with some useful info such as uname -a, architecture, if you're ROOT or not, etc. In Linux:
   1  
   2  #!/bin/bash
   3  HOST_NAME=`hostname -f`
   4  if [ `id -u` = 0 ]; then
   5  OPT=”`uname` (`uname -a | cut -f12 -d’ ‘ -`) - ROOT USER   6  else
   7  OPT=”`uname` (`uname -a | cut -f12 -d’ ‘ -`)”
   8  fi
   9  REPLACE=”${HOST_NAME} - ${OPT}”
  10  echo -n -e “\033]0; $REPLACE \007  11  echo “${REPLACE}”
  12  exit 0

Then run this script, and your termtitle will be something like the following:
   1  
   2  Servername (Linux / x86_64).

For Solaris it needs to be done a bit differently:
   1  
   2  #!/usr/local/bin/bash
   3  HOST_NAME=`uname -a | cut -f2 -d’ ‘ -`
   4  OPT=”(`uname -a | cut -f1 -d’ ‘ -` / `uname -a | cut -f6 -d’ ‘`)”
   5  REPLACE=”${HOST_NAME} - ${OPT}”
   6  echo -n -e “\033]0; $REPLACE \007   7  echo “${REPLACE}”
   8  exit 0

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.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS