Skip to content

[NetBSD] Change Default Shell to OKSH on NetBSD

Install OKSH on NetBSD

$ doas pkgin -y install oksh
$ cd /bin
$ doas ln -s /usr/pkg/bin/oksh      # Use /bin/oksh

Change Default Shell to OKSH for root and common user

$ su -
# chsh -s oksh
# exit
$ chsh -s oksh

Customize OKSH Profile

Create /etc/okshenv, /etc/okshrc, ~/.okshenv, ~/.okshrc

/etc/okshenv

$ doas cp /etc/shrc /etc/okshenv

/etc/okshrc

$ doas touch /etc/okshrc

~/.okshenv

$ cd ~
$ cp .shrc .okshenv
$ vim .okshenv
$ su -
# cp .shrc .okshenv
# vim .okshenv
Edit ~/.okshenv for both root and common users:

Replace . /etc/shrc with . /etc/okshenv in ~/.okshenv.

~/.okshrc

$ cd ~
$ touch .okshrc
$ su -
# touch .okshrc
Edit ~/.okshrc for both root and common users:
echo ". /etc/okshrc" >> ~/.okshrc

Source Your Customized Profile

$ vim ~/.profile
$ doas vim ~/.profile
Edit ~/.profile for both root and common users:

Replace export ENV=$HOME/.shrc with export ENV=$HOME/.okshenv in ~/.profile.

Add . $HOME/.okshrc at the end of ~/.profile.


Now let's do something!

Change the Default Shell Prompt (PS1)

Step 1: Comment PS1 in /etc/okshenv:

        #PS1="${HOST%%.*}$PS1"

Step 2: Add PS1 to /etc/okshrc:

(A PS1 Example)

export PS1='\! - \# \l \t [\w] \s-\v \$ '

(Add an export setting to PS1 solved some weird problems.)

The result would look like this:

(Root)

3 - 3 ttyE2 22:14:07 [/usr/pkg/lib] -oksh-v5.2.14 #

(Common User)

6 - 6 ttyE1 22:18:32 [~/sources] -oksh-v5.2.14 $

(What is the meaning of the PS1 characters? Please read man oksh.)

WARNING: You are not encouraged to add things to /etc/okshenv and ~/.okshenv because it's not safe, instead you can add things to /etc/okshrc and ~/.okshrc, however it's OK to remove things from /etc/okshenv and ~/.okshenv if you understand it.

Set Color for ls

Step 1: Install colorls:

$ doas pkgin -y install colorls

Step 2: Add alias ls to /etc/okshrc:

alias ls='colorls -FG'

How to set color for every item? Read man colorls.

Bind CTRL-L to "clear-screen"

$ doas echo "bind \"^L=clear-screen\"" >> /etc/okshrc

Oksh is known to run on OpenBSD, NetBSD, FreeBSD, Dragonfly BSD, Haiku OS and SerenityOS.

 

 

 

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.

@cppfx.xyz