Set up a comfortable Linux/Unix environment for development

If you spend most of your time working under Linux/Unix environment, you can benefit from checking other people's toolbox to see if you can use some from them. In this article, we describe some tools that can make your development under Linux/Unix more productive.

Bourne-Again Shell (bash)

Needless to say, the Bourne-Again Shell (bash) is ubiquitous in the Linux world. It is excellent for both interactive use and scripting. It is usually worth the effort to check the following documents from time to time to learn new tricks or just to refresh your memory:

For interactive use, you can also define aliases and functions to save a few key strokes. You can download the sample bash rc file and adapt it to your local environment.

CDargs

CDargs is a useful tool to navigate directories through the command-line easily. It is more powerful than the bash's CDPATH variable, pushd and popd built-ins.

With cdargs, you can save commonly accessed directories to the $HOME/.cdargs file and then you can use the cv command to navigate through them. The cv command also supports auto-complete. For example, suppose you have the following directories defined in the $HOME/.cdargs file,

  mason /home/www/mason
  math /home/www/math

When you type cv m and hit the TAB key, it will show the choices for mason and math and then you can type more characters to disambiguate the path you want to go to.

You can read the CLI Magic: CDargs article and explore its features.

Editors: Vim

People from both the Emacs and the Vi/Vim camps can debate endlessly about the benefits of using their own editors. We fall into the camp of Vim because it is installed by default in almost all Unix systems. You can use Vim under both terminal and GUI environment (gvim). You can get started with gvim quickly without learning any modes or movement keys like h, j, k and l. Later on, when you are more familiar with the basics, you can learn the different modes of vim.

We like some of Vim's features most. One is the ability to open multiple windows so you can edit multiple files conveniently or view different parts of the same file at the same time. To create a new window, just type Ctrl+W, then hit the N key. To switch to the next window, just type Ctrl+W, and then the W key.

The second nice feature about vim is easy to copy and paste. To select the lines you want to copy, type Shift+V, and then use the arrow keys or other movement keys to select more lines, then type the y key to copy them. Now move to the place you want to copy the text to and then type the p key.

Another useful feature is syntax highlighting. With it you can spot syntax errors easily when you edit various types of files. With vim, you can also find the opening or closing parentheses and braces by typing the % key when you are at either end of the pairs.

Source code browsing: exctags

With the exuberant ctags (exctags) tool, you can browse source files very easily. It supports C, C++, PHP and many other languages.

After installation, run the ctags command from the directory where all the source files are located to generate the tags file. Then in vim, enter the command mode and run set tags=<where_your_tag_file_is>. Now you can browse any files in the directory. When you see a function call, you can type Ctrl+] to jump to the function's definition and Ctrl+T to go back to the original place.

In case the source files use suffixes that exctags doesn't recognize, you can use the langmap parameter. For example, to generate tags for .inc files that are written in PHP, you can run command like the following

  exctags --langmap=php:+.inc -R <any_php_dir>

So far we have just described a few of the versatile tools available in the Unix/Linux environment. Later on we will add more of them here.

Back to articles on setup