Home > OpenSolaris, Solaris, UNIX > Customizing vim and coloring the terminal in OpenSolaris 2009.06

Customizing vim and coloring the terminal in OpenSolaris 2009.06

July 12th, 2009

I have been using Sun’s Solaris (and now OpenSolaris) for years now. In fact while some of you can probably go as far back as the SunOS days, the first Solaris operating system that I worked on was Solaris 8. The company that I was working for had some older SPARC server/client nodes. They had conformed to the mindset of, “if it isn’t broken, why fix it?”

During this time I had already grown extremely comfortable with GNU/Linux. Especially when it came to the text editor tools. I have always been a fan of vim (vi improved); but when I would hop from one platform to the other, I always found myself getting stuck with the way Solaris and now, OpenSolaris default their environment.

By stuck, I mean trying to get used to their command line interface in general. The shell used to always default to the traditional Bourne Shell (/bin/sh) and not the Bourne Again Shell (/bin/bash). While this could always be customized under the user’s profile in the /etc/passwd file, I am glad to see that at least in OpenSolaris this has been changed. Now the terminal defaults to bash. Although I do not know if this will carry over to Solaris 11.

That is why as soon as a new Solaris/OpenSolaris installation is completed, I append the following additions to my my ~/.vimrc and ~/.bashrc files:

.vimrc

syntax on
set background=dark
set ru
set hls

.bashrc

export TERM=xterm-color
alias ls='ls --color=always'
alias ll='ls -l --color=always'

Note that sometimes (if it doesn’t already exist) you may have to create the .vimrc file. What these settings do is enable the ruler and syntax highlighting while also adding some necessary color to your terminal environment. This will aid in differentiating between file types from normal listings of directory contents while also color coding scripting and other code-like syntax.

To add some more customization, I will even append certain key binding because for some odd reason Sun has never implemented them in their terminal. For example, the Delete, Page Up and Page Down keys (still working on figuring out Home and End; although same results can be obtained with CTRL+A and CTRL+E). The delete will perform a delete of the characters on the prompt while the page up/down keys will page through your recent history. You would append the following to the .bashrc file:

# delete key
bind '"e[3~":delete-char'
# page up key
bind '"e[5~":history-search-forward'
# page down key
bind '"e[6~":history-search-backward'

These features help me get started and as I use the system more, usually more will get added to these configuration files.

Categories: OpenSolaris, Solaris, UNIX Tags:
  1. August 17th, 2009 at 17:36 | #1

    Some additional settings that can be set in your .vimrc file are the following:
    set backspace=indent,eol,start
    map [5~ <PageUp>
    map [6~ <PageDown>
    What these settings do is enable the backspace during insert mode in the listed situations. It also enabled the binded Page Up/Down keys to move a whole page up/down.

Comments are closed.