lilalo

annotate l3prompt.c @ 157:137cf5a580be

bsd fix
author Igor Chubin <igor@chub.in>
date Mon Nov 28 13:26:46 2011 +0200 (2011-11-28)
parents
children
rev   line source
igor@153 1
igor@153 2 /*
igor@153 3 * export PS1='\[$($L3_HOME/l3prompt "v3#\!#$?#$UID#$$#$(/bin/date +%s)#$PWD#$RANDOM#")$(l3_save_last_line >& /dev/null)\]'$PS1
igor@153 4 *
igor@153 5 *
igor@153 6 * l3prompt perl code:
igor@153 7 *
igor@153 8 * my $string=$ARGV[0];
igor@153 9 * my $insert="\e[1K\e[10D";
igor@153 10 * my $max=5;
igor@153 11 *
igor@153 12 * while (length($string) > $max) {
igor@153 13 * $res .= substr($string, 0, $max).$insert;
igor@153 14 * $string = substr($string, $max);
igor@153 15 * }
igor@153 16 * $res .= $string.$insert;
igor@153 17 * print "$res";
igor@153 18 *
igor@153 19 */
igor@153 20 #include <stdio.h>
igor@153 21 #define N 5
igor@153 22 #define BUF_SIZE N+1
igor@153 23 char* mixin="\e[1K\e[10D";
igor@153 24 char buf[BUF_SIZE];
igor@153 25 int main(int argc, char **argv)
igor@153 26 {
igor@153 27 char *i,*j;
igor@153 28 int n;
igor@153 29 argc--;
igor@153 30 argv++;
igor@153 31 while (argc > 0) {
igor@153 32 i=argv[0];
igor@153 33 j=&buf[0];
igor@153 34 n=0;
igor@153 35 while(*i) {
igor@153 36 *j=*i;i++;j++;
igor@153 37 n++;
igor@153 38 if (n==N) {
igor@153 39 *j=0;
igor@153 40 fputs(buf, stdout);
igor@153 41 fputs(mixin,stdout);
igor@153 42 j=&buf[0];
igor@153 43 n=0;
igor@153 44 }
igor@153 45 }
igor@153 46 *j=*i;
igor@153 47 fputs (buf, stdout);
igor@153 48 if (n) fputs(mixin,stdout);
igor@153 49 argc--;
igor@153 50 argv++;
igor@153 51 };
igor@153 52 }