Pathname in prompt, not FAQ, really.

Skip Montanaro montnaro at spyder.crd.ge.com
Wed Jun 13 05:54:45 AEST 1990


I alias cd to the following ksh function to put the current directory in the
title bar of my xterms. It does the ~ substitution as requested. Note that
there are two ASCII ESC chars ("^[") and two ASCII BEL chars ("^G") in the
code below. Substitute (Saturate? :) before using, folks.

    hostname=$(hostname)
    function cdxterm {
	\cd "$@"
	dir="${PWD#$HOME/}"
	if [ $dir != $PWD ] ; then
	    dir="~/$dir"
	elif [ $dir = $HOME ] ; then
	    dir="~"
	fi
	print -n "^[]1;$hostname^G^[]2;$hostname : $dir^G"
    }

--
Skip (montanaro at crdgw1.ge.com)



More information about the Comp.unix.questions mailing list