|
|||
Color Prompt in OpenBSD.
I've worked long and hard to figure out how to make my prompts in color on OpenBSD and FreeBSD. OpenBSD rocks, so we'll forget we ever used FreeBSD from this point on. Here it is:
In your .kshrc file OR your .profile, add these two lines. Code:
print "\033[1;34m" PS1='| $PWD | ' Log out and log back in or type this at the command line: (If you put it in your .kshrc like I do) --> (don't type this) . .kshrc (type that above), two dots separated by a space then kshrc next to the last dot. ( If you like to put it in your .profile ) type this at the command line: . .profile But, a newbie would definitely log out and log back in. Voila! If you used [1;34m you're gonna get a real nice light blue on black that honors the work the guys do who make OpenBSD a reality for us retards. Go blue, I'm sick of using that Matrix Neo wanna be green on black color scheme for the command line, are you? Yet? Last edited by J65nko; 3rd December 2009 at 03:05 AM. Reason: Added code tags ;) |
|
|||
Instead of using $PWD you can use \w
Code:
PS1="\u@\h[\w]" export PS1 Code:
j65nko@hercules[~/Snapshots]
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
Colour terminals are quite distracting, I can't see how they would be beneficial.. the whole thing just reeks of default GNU/Linux behaviour.
While you are free to abuse ANSI colour codes, please do so on some remote server.. preferably located in Antarctica, or near Mars. |
|
|||
Color terminals are distracting, but the very first computer I programmed on had an Amber Terminal (small, but lovely) back in 1982. I was in second grade, and the school had a computer lab. We got to program Logo!!! Yes. that's right. Logo! I know there are folks out there who've never heard of Logo, but it has warm memories for me. I was in shock and awe at the sight of a computer back in those days. I couldn't imagine doing anything else with my life other than sitting in front of a computer for long hours at a time programming and solving problems. But, it's even better now that we can add images and color. Life without color isn't as exciting as life with color. I'm not saying that we need to over use color. But, a teeny tiny bit of color in an otherwise gray world makes the sun come out in my eyes. Just a little color, not a whole lot.
Try that blue I'm using and see if it grows on you. |
|
|||
Thanks for letting me know about "[ \w ]" as an alternative to " $PWD ". I tried that once a long time ago and it didn't work on OpenBSD, but things change. Now I don't have to begin new lines so much.
|
|
|||
You can check the OpenBSD ksh man page which special characters are supported in the PS1 prompt. Search for 'PS1' to find find them.
RE: Logo A couple of weeks I was reading Seymour Papert's book 'Mindstorms' about the idea's about Logo, and the influence of Piaget's ideas on his theory how children/humans learn. I bought a Windows 3..1 Logo implementation for my daughter when she was young, but at that time she wasn't too interested. Now she studies electrical engineering and develops web apps in PHP as a side-line job. So you never know if it had any influence
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump |
|
|||
Quote:
It had an implementation of Logo, I remember it being taught in class (..basically, type this in and watch the fancy graphics). Daisy chained systems, coaxial networking.. loud obnoxious internal speakers.. lots of memories. |
|
|||
(number)(user)=====(pwd)====
1... number of the command in history 2... current logged in user name pwd... I use spacers (== or equilvalent) around it, and set apart from the other two items. If it is at the left it is ( *here* ) HARDER TO READ without actually looking for it... most of which some posts above this one already implement.
__________________
FreeBSD 13-STABLE Last edited by jb_daefo; 4th December 2009 at 06:45 AM. |
|
|||
I didn't mention this earlier because I didn't want to confuse any noobs who might want to try the color prompt, but I've found on OpenBSD, if you use an ascii code for blinking you can make the pwd blink then close the blink with an ascii code and begin the code I posted above to set the color. you can even combine the blink with a red color and close both of them, before you apply the blue color. Trick is, don't close the blue color and all the text afterwards will be blue. I think I've implemented a short shell script to apply blue ( you can make simple shell scripts to apply any color ) if you lose that color for some reason. But "blinking" is kinda cool, but WAY too distracting for me.
|
|
||||
I always set my prompt to 'username@hostname-$ ' where the $ is colour coded based on the shell and the host. I find it helps me remember which machine I'm typing at, and the colored dollar sign for when I'm about to pass out.
Getting colour prompts to work without getting annoyed at different ksh implementations, resulted in this in my ~/.${LOGNAME}_shrc: Code:
# # The various korn shells handle escape codes in prompts # rather differently from one another. This method appears # to work on all ksh implementations and plays nicely with # VT102 emulators like rxvt perfectly fine. # # Special thanks to Scotto for this technique. # PS1='^[^M${USER}@^[[1;37m${HOSTNAME}^[[0;36m$^[[0;0m ' OpenBSDs implementation seems to be the best for getting a colour prompt, without aggravation. My profile however.... covers most forms of Bourne shell in script.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
set a function before you set the prompt like this:
showblu() { print "\033[01;34m" } PS1='$(showblu)|\w| ' That will keep you from losing color if you compile source from the ports collection. But, still, you lose color in Vim and Vi. That's where you need colorschemes like pablo and murphy. Hope this helps somebody who's a stickler for color text like me. I found a way easy way to do it in FreeBSD about a year ago, on the command line, type: vidcontrol -fg green. I think it's like that. Can't remember, but if you man vidcontrol, it's right there. Put that vidcontrol line in a .profile or .sh script and you've got color. Also, in FreeBSD, vidcontrol can give you and underlined color cursor if you set vidcontrol to desctructive. You also have the option of using vidcontrol to set the reverse bg and fg colors, so when you use a man page you get a really really wicked looking man page. |
|
|||
Quote:
Thanks for the colourization note; I always wanted to spruce up my OpenBSD console, but never had the time (or inclination) to delve to deeply into it (read: work). I am going to see if I can find the codes for a nice orangey-yellow. Not quite amber, but not quite the yellow on Puffy, either. |
|
||||
Quote:
For sane people, they would want a prompt to turn the colour change off afterwards.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
|
|||
Nice, i only get some problems after i lauched top or vi editor. Then after quitting the programs. Then console colors are all default again :-/
Any ideas? |
|
|||
Hi marcolino
I'm using vt220 which comes as standard in openbsd 4.8, it's just the colors that resets when i want to launch vi or top for example. I've been editing the .profile to make the options above |
|
|||
ok I see, it functions inside of x.org and fluxbox (XTERM). It's only problems outside (VT220) so it's ok I'm satisfied to have this functioning inside of x.org with (XTERM) :-)
Thanks Marcolino! |
|
||||
Quote:
Code:
# echo $TERM vt220 Quote:
Quote:
Same behavior with OBSD 5.2_i386, 5.3s_i386 and 5.3s_SPARC64. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Nicer Prompt with ksh on 5.0 | nihonto | NetBSD Installation and Upgrading | 8 | 12th October 2009 08:49 PM |
changing custom prompt ksh for root. | bsdnewbie999 | OpenBSD General | 7 | 1st April 2009 04:53 AM |
Exec command in zsh prompt? | bsddaemon | General software and network | 2 | 18th October 2008 09:37 PM |
what to do at mountroot prompt? | Sunsawe | FreeBSD General | 13 | 5th June 2008 08:06 AM |