lilalo

view l3bashrc @ 70:6f5ad37fc8d9

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

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