[t]csh prompt magic


( ! ) Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home/bbbart/www/htdocs/blog/wp-content/plugins/vimcolor/wp-vimcolor.php on line 105
Call Stack
#TimeMemoryFunctionLocation
10.000153060{main}( )../index.php:0
20.000256500require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' )../index.php:17
30.258316856560require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' )../wp-blog-header.php:16
40.260016919140include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/single.php' )../template-loader.php:43
50.326517038056the_content( )../single.php:16
60.326617040480apply_filters( )../post-template.php:169
70.330117048512call_user_func_array ( )../plugin.php:166
80.330117048696vim_color( )../plugin.php:0
90.330117049032preg_replace ( )../wp-vimcolor.php:143
100.330117058216preg_replace ( )../wp-vimcolor.php:143
110.330117058584vimcolor_process_color( )../wp-vimcolor.php(143) : regexp code:8
120.355517075292fread ( )../wp-vimcolor.php:105

I refer to Jan’s
smiley system
. I like the idea, and tried to implement something similar
in [t]csh… with only limited success.

First of all, I needed an equivalent of that bash function inspecting the
return value of the previous command and printing a corresponding smiley.
[t]csh doesn’t support functions, so I needed an alias. But in aliases, you
can’t use if-then-else. Or so I thought.
But this works:


Watch your quoting; remember that the shell strips off one level of quoting
when you set the alias and another during the first pass of the eval. The
echo_style could also be just ``sysv'', but not ``none'' or ``bsd'' if you
want some colour instead of a scrambled shell. And, oh yes. Smileys won't
work, as there is no way I could make this statement not
evaluate ('s or )'s correctly (unless maybe I try it with makealias or
quote
one day), so I opted for the +
and - signs
instead.

Now after figuring this out, I needed a way to get an alias call into my
$prompt variable. Bummer. No support for this in [t]csh. Yikes!

So now what? Well, you could just set the printexitvalue shell variable to
print the exit status of commands which exit with a status other than zero,
which is supported by default by [t]csh.

So, the same functionality can be gotten (even far simpler than in bash), but
not the same coolness factor. Too bad for those [t]csh users out there. :-)

Add a Comment   Trackback  

Add a Comment