source: trunk/essentials/app-shells/bash/examples/scripts/xterm_title@ 3506

Last change on this file since 3506 was 3228, checked in by bird, 19 years ago

bash 3.1

File size: 495 bytes
Line 
1#! /bin/bash
2#
3# xterm_title - print the contents of the xterm title bar
4#
5# Derived from http://www.clark.net/pub/dickey/xterm/xterm.faq.html#how2_title
6#
7P=${0##*/}
8[ -z "$DISPLAY" ] && {
9 echo "${P}: not running X" >&2
10 exit 1
11}
12
13if [ -z "$TERM" ] || [ "$TERM" != "xterm" ]; then
14 echo "${P}: not running in an xterm" >&2
15 exit 1
16fi
17
18exec </dev/tty
19old=$(stty -g)
20stty raw -echo min 0 time ${1-10}
21echo -e "\033[21t\c" > /dev/tty
22IFS='' read -r a
23stty $old
24b=${a#???}
25echo "${b%??}"
26
27exit 0
Note: See TracBrowser for help on using the repository browser.