Tracy Phillips

FreeBSD Usability

leave a comment

Is that title an oxymoron or what :)

Sometimes we just need to add small things that give us comfort when working at the CLI (Command Line Interface). I would like to setup vim, bash and gnuls to make the CLI just a bit more friendly. Make sure that you followed our previous article and have vim, bash, and gnuls installed or you will run into problems :)

The first thing to do is fire up vi with a new file called .bash_profile. This is what we are going to use to make bash look for the .bashrc file we are going to make next. Be sure you are logged in as root and in /root

vi .bash_profile

Now put the following into vi and then save and close the file.

if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
Now use vi to create a new file called .bashrc and put the following in it.

# file permissions: rwxr-xr-x
umask 022
TERM=xterm
BLOCKSIZE=K
EDITOR=/usr/local/bin/vim
PAGER=/usr/bin/less
alias ls='gnuls --color=always'
alias la='gnuls -a --color=always'
alias ll='gnuls -lah --color=always'
alias updatedb='/usr/libexec/locate.updatedb'
alias h='fc -l'
alias disksize='df -kh'
alias dirsize='du -h -d 1 .'
alias free='top -d1 | head -5 | tail -2'
alias vi=vim
PS1="[\u@\h \W]\\$ "
PS2="> "
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
;;
*)
;;
esac
export TERM EDITOR PAGER BLOCKSIZE

Save and close that file.

Think of aliases as shortcuts. You will notice alias vi=vim, which tells bash that when we type vi that what we really want to use is vim. You will also notice that we aliased ls to gnuls and told it that we always want to have colorized output.

Change your default shell from csh to bash

chsh -s /usr/local/bin/bash

Fire up vi with the new file .vimrc. With this we are going to tell vim how we want it to behave by default. Put the following into the file and save and close.

set nu
set backspace=eol,start,indent
set term=linux
set incsearch

The first line tells vi that we want to use line numbers by default, which make long files easier for me to read. The second line makes our backspace, home, and delete keys behave as you would normally expect them to. I can't remember why I actually put the third line :), but I imagine it was to make vim behave as it would when being used in Linux.

Log out and log back in, and type ls. Notice that your hidden files are not shown by default. To view your hidden files, type la notice the color. Now to view permissions on your files type ll. Nice eh?
Now just for fun, use vim by typing vi and open your .bashrc. Notice the nice line numbers with color. Spiffy stuff.

Ok, thats a wrap.

Next we will change our default encryption methods for passwords from MD5 to Blowfish.

Rails Server Setup:

Part 1: New Server Setup
Part 2: Setup FreeBSD 6.x
Part 3: FreeBSD Usability
Part 4: Setup FreeBSD To Use Blowfish
Part 5: Install and Setup PostgreSQL
Part 6: Install Lighttpd on FreeBSD
Part 7: Install MySQL 5.x on FreeBSD
Part 8: Install Ruby On Rails with FreeBSD

Written by Tracy

November 30th, 2005 at 3:47 pm

Posted in FreeBSD

Tagged with ,

Leave a Reply