Nan Xiao's Blog

A system software / performance engineer's home

Customize ksh display for OpenBSD

The default shell for OpenBSD is ksh, and it looks a little monotonous:


To make its user-experience more friendly, I need to do some customizations:

(1) Modify the “Prompt String” to display the user name and current directory:

PS1='$USER:$PWD# '

(2) Install colorls package:

# pkg_add colorls

Use it to replace the shipped ls command:

alias ls='colorls -G'

(3) Change LSCOLORS environmental variable to make your favorite color. For example, I don’t want the directory is displayed in default blue, change it to magenta:


For detailed explanation of LSCOLORS, please refer manual of colorls:

# man colorls
LSCOLORS        The value of this variable describes what color to use
                     for which attribute when colors are enabled with
                     CLICOLOR.  This string is a concatenation of pairs of the
                     format fb, where f is the foreground color and b is the
                     background color.

                     The color designators are as follows:

                           a     black
                           b     red

This is my final modification of .profile:

PS1='$USER:$PWD# '
export PS1
alias ls='colorls -G'

And this is the final effect:

Add Color to Your Terminal;
Why doesn’t alias work in AIX (Korn shell, .profile)?;



My first patch to OpenBSD


Build gRPC on ArchLinux


  1. Hi there excellent blog! Does running a blog similar to this require a massive amount work? I’ve very little understanding of computer programming however I was hoping to start my own blog in the near future. Anyway, should you have any suggestions or techniques for new blog owners please share. I know this is off subject but I just wanted to ask. Thanks a lot!|

    • nanxiao

      Build your own blog is very easy, even requires little knowledge. You just need to apply for a domain name. If you don’t want to lease host, you can utilise github pages to hold your blog. If you don’t want to spend a cent, or feel a little difficult to do this. You can use third-party blog platform, such as blogspot, wordpress, etc.

      If you want to share your stories, great! Just write it. Don’t care whether people would read it or not. The important thing is you get joy from blogging.

      Trust me, enjoy blogging!

  2. Billy Larlad

    Maybe it’s a kind of electronic Stockholm Syndrome, but for _me_ the default is totally fine. I don’t see any need to call it “monstrous.”

    What you’ve come up with is nice for sure (too many folks go way too far with customizing their terminal prompts) but I myself don’t feel the need to customize my profile and install third party software just to get dotfiles printed in purple.

    Anyhow, keep up the nice OpenBSD coverage!

  3. Rex Rollman

    Couldn’t you create and export the variable in one shot, so that instead of having two lines for LSCOLORS and PS1, you could have one each? Of does OpenBSD’s ksh not support that?

Leave a Reply

Powered by WordPress & Theme by Anders Norén