[BACK]Return to .etsh.prompt CVS log [TXT][DIR] Up to [cvs] / v6shell / examples

File: [cvs] / v6shell / examples / .etsh.prompt (download)

Revision 1.3, Sat Dec 15 21:22:04 2018 UTC (4 weeks, 4 days ago) by jneitzel
Branch: MAIN
Changes since 1.2: +1 -1 lines

Update examples/{.*,*}; primarily, 'io' to 'nl' changes...; + in
examples/.etshrc, remove the fd2(1) rdirection to /dev/null from
the V & VV aliases

: etsh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;;
:
: "  The author of this file, J.A. Neitzel <jan (at) etsh (dot) nl>,  "
: "  hereby grants it to the public domain.                           "

: "  $h/.etsh.prompt - etsh prompt preprocessor - modify to taste  "
:
: "  It's pretty simple.  It organizes the elements I want in my   "
: "  prompt.  Then, it does a `. SetP string'.  That's all.        "
: "  NOTE: Please choose the examples you want below.              "
:
: "  usage: . $h/.etsh.prompt  "

( : " Fail if this process does not have a controlling terminal. " ) >/dev/tty
if -z "$t" if { fd2 -e echo 'error: need tty name' } if { exit } false

: " Ensure we have a usable ETSHDIR ($d). "
fd2 -ef/dev/null etshdir
if $? -eq 0 goto Continue
	source etshdir $$
	if $? -eq 0 goto Continue
		fd2 -e echo "$0: Error!" ; false ; exit
	: fallthrough

: Continue
	: " In total, there are about 6 examples here.  I flagged each "
	: " one w/ a comment, including a [something or other].  That  "
	: " way, we can identify and reference them if needed.         "
	:
	: " SetP appends `% ' or `# ' to $Q for !root or root users.   "
	: " Choose and modify as you wish to build your prompt.        "

	set Q '\>'          ; : " [0 default]   - upon which to build "
	: set Q "' >\|/< '" ; : " [0 alternate] - that I like         "

	: " Change the following test as needed to add/remove 1 or "
	: " more tty(s) that want a simple, non-default, prompt.   "
	if $t != /dev/ttyC1 -a $t != /dev/ttyp1 goto Jump
		: " like each $Q above but prepend each w/ \n "

		set Q '\n\>'          ; : " [0t  default]   "
		: set Q "\n' >\|/< '" ; : " [0ta alternate] "

		. SetP "$Q" ; goto Done
	: Jump
	echo "$t" | grep "$q$" >/dev/null
	if $? -eq 0 goto TtyIsEqual
		( echo -n set q \" ; \
		  echo "$t" | cut -d/ -f3- | sed 's,tty,,' | tr -d \\n ; \
		  echo \" ) >$d/tty
		. $d/tty ; rm -f $d/tty
		: fallthrough
	: TtyIsEqual
	echo "$w" | grep "$h" >/dev/null
	if $? -ne 0 goto Jump1
		unset o
		( echo -n set o \" ; \
		  echo "$w" | sed 's,'"$h"',~,' | tr -d \\n ; echo \" ) >$d/wd
		. $d/wd ; rm -f $d/wd
		: . SetP "\n$o\n$k\($u\)\n$q$Q" ; : " [1]         "
		. SetP "\n$o\n$u@$H\n$q$Q"      ; : " [2]         "
		: . SetP "\n\a$o\n$q$Q"         ; : " [3 w/ bell] "
		: . SetP "\n$o\n$q$Q"           ; : " [4]         "
		: . SetP "$q$Q"                 ; : " [5]         "
		unset o ; goto Done
	: Jump1
		: . SetP "\n$w\n$k\($u\)\n$q$Q" ; : " [1 companion]         "
		. SetP "\n$w\n$u@$H\n$q$Q"      ; : " [2 companion]         "
		: . SetP "\n\a$w\n$q$Q"         ; : " [3 companion w/ bell] "
		: . SetP "\n$w\n$q$Q"           ; : " [4 companion]         "
		: . SetP "$q$Q"                 ; : " [5 identical]         "
		: fallthrough

: Done - zero status - true