lilalo

annotate l3bashrc @ 70:6f5ad37fc8d9

Добавлен файл l3bashrc, который настраивает среду интерпретатора
и включает запись lilalo-скриптов.
Настройка разбита по функциям.

ПОКА ЧТО НЕ РАБОТАЕТ!
author devi
date Fri Feb 03 22:49:46 2006 +0200 (2006-02-03)
parents
children d499fa3b2af1
rev   line source
devi@70 1 #!/bin/sh
devi@70 2
devi@70 3
devi@70 4 _l3_start()
devi@70 5 {
devi@70 6 L3_TTY=`tty`
devi@70 7 proc_on_the_term=`w | grep "${L3_TTY##/dev/}" | awk '{print $8;}'`
devi@70 8 # freeBSD:
devi@70 9 [ -n "$bsd" ] && \
devi@70 10 proc_on_the_term=`w | grep "${L3_TTY##/dev/tty}" | awk '{print $6;}'`
devi@70 11
devi@70 12 if [ -n "$proc_on_the_term" ] && echo $proc_on_the_term | grep -qv script
devi@70 13 then
devi@70 14 _l3_start_session
devi@70 15 _l3_run_script
devi@70 16 else
devi@70 17 _l3_env
devi@70 18 _l3_prompt
devi@70 19 fi
devi@70 20 }
devi@70 21
devi@70 22 _l3_env()
devi@70 23 {
devi@70 24 true
devi@70 25 }
devi@70 26
devi@70 27 _l3_prompt()
devi@70 28 {
devi@70 29 export PS1='\[`
devi@70 30 a="$?";
devi@70 31 HIDDEN=$([ "$a" = 0 ] || echo -n ^"$a")$(echo -n _${UID}_)$(echo -n _$$_)$(date\
devi@70 32 +"%j$(cat ${LMHOME}/lab 2>/dev/null) %H:%M:%S");
devi@70 33 echo $HIDDEN`\033[50D\033[K\][\u@\h:\W]\$ '
devi@70 34 }
devi@70 35
devi@70 36 _l3_start_session()
devi@70 37 {
devi@70 38 L3_SESSION_ID=${L3_TTY##*/}-$$
devi@70 39 L3_HOME=~/.lilalo/
devi@70 40 mkdir -p $L3_HOME
devi@70 41
devi@70 42 uname -a | grep -qi bsd && bsd=yes
devi@70 43 parent=`cat /proc/$PPID/cmdline 2> /dev/null`
devi@70 44 system=`uname -rs`
devi@70 45 login_from=`who | grep "${tty##/dev/}" | awk '{print $6;}' | tr -d '()'`
devi@70 46 #[ -n "$bsd" ] && login_from="" #FIXME!
devi@70 47 start_time=`date +%s`
devi@70 48 hostname=`hostname -f 2> /dev/null`
devi@70 49 [ -n "$bsd" ] && hostname=`hostname`
devi@70 50
devi@70 51 cat <<INFO > $L3_HOME/$L3_SESSION_ID.info
devi@70 52 <session>
devi@70 53 <local_session_id>$L3_SESSION_ID</local_session_id>
devi@70 54 <hostname>$hostname</hostname>
devi@70 55 <user>$USER</user>
devi@70 56 <uid>$UID</uid>
devi@70 57 <login_from>$login_from</login_from>
devi@70 58 <tty>$tty</tty>
devi@70 59 <system>$system</system>
devi@70 60 <parent>$parent</parent>
devi@70 61 <ppid>$PPID</ppid>
devi@70 62 <pid>$$</pid>
devi@70 63 <start_time>$start_time</start_time>
devi@70 64 </session>
devi@70 65 INFO
devi@70 66
devi@70 67 unset parent system login_from start_time hostname
devi@70 68 }
devi@70 69
devi@70 70 _l3_run_script()
devi@70 71 {
devi@70 72 uname -a | grep -qi bsd && bsd=yes
devi@70 73 flush="-f" #linux
devi@70 74 [ -n "$bsd" ] && flush="-t 0" #freebsd
devi@70 75 exec script $flush -q $L3_HOME/${L3_SESSION_ID}.script
devi@70 76 }
devi@70 77
devi@70 78 _l3_close_session()
devi@70 79 {
devi@70 80 history > $L3_HOME/$L3_SESSION_ID.info
devi@70 81 }
devi@70 82