[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 | ||||
| # | Time | Memory | Function | Location |
| 1 | 0.0001 | 53060 | {main}( ) | ../index.php:0 |
| 2 | 0.0002 | 56500 | require( '/home/bbbart/www/htdocs/blog/wp-blog-header.php' ) | ../index.php:17 |
| 3 | 0.2583 | 16856560 | require_once( '/home/bbbart/www/htdocs/blog/wp-includes/template-loader.php' ) | ../wp-blog-header.php:16 |
| 4 | 0.2600 | 16919140 | include( '/home/bbbart/www/htdocs/blog/wp-content/themes/svelt/single.php' ) | ../template-loader.php:43 |
| 5 | 0.3265 | 17038056 | the_content( ) | ../single.php:16 |
| 6 | 0.3266 | 17040480 | apply_filters( ) | ../post-template.php:169 |
| 7 | 0.3301 | 17048512 | call_user_func_array ( ) | ../plugin.php:166 |
| 8 | 0.3301 | 17048696 | vim_color( ) | ../plugin.php:0 |
| 9 | 0.3301 | 17049032 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 10 | 0.3301 | 17058216 | preg_replace ( ) | ../wp-vimcolor.php:143 |
| 11 | 0.3301 | 17058584 | vimcolor_process_color( ) | ../wp-vimcolor.php(143) : regexp code:8 |
| 12 | 0.3555 | 17075292 | fread ( ) | ../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. :-)