Friday, December 3, 2010

Tutorials & Help

There would be times when we forget things which we have been using for a long time. Then you would want to go to basic tutorial and read all about it. There is no good re-writing the commands and explanations here in blog but it is good to have links to the tutorials and help documents. This post will contain links to well-written help documentation for everything I will need. Please contribute to it, if you wish.
Link
  1. JAR basics - Documentation from Oracle
  2. Tutorial on Marathon testing tool
  3. How to install Eclipse plugins - manually and the easy way?
  4. How to install Kindle for Linux

Ubuntu: Terminal display help

Here are the few tricks up your sleeve for utilizing the scripts to customize the terminal display.

1. To have the shell prompt always start at the left hand side of terminal:

When you have long pathname for the current working directory and you have a even longer command to execute, the display gets all screwed up. So it always helps you to have the shell prompt start at left hand side of terminal. You have to change the PS1 - to customize your bash prompt.

In the fig, you can't distinguish where the dir name ends and where the command starts. So open ".bashrc" file in home folder
gedit ~/.bashrc
and add the following code. Note: as a good coding practice, add a line of comment saying when and why added the piece of code and add the new code at the end of the file.
PS1=$'\[\e]2; \h::\]$PWD\[\a\]\[\e]1;\]$(basename "$(dirname "$PWD")")/\W\[\a\] \w\n\T \$ '

Then the bash prompt becomes like this,
The current working directory name in first line(s) and in a new line current time followed by $ for you to type in the command.

Much better huh, what exactly does the code do? Let's review from back
\$ - if the effective UID is 0, a #, otherwise a $
\T - the current time in 12-hour HH:MM:SS format
\n - newline
\w - current working directory with ~ instead of $HOME directory
\[ \] - begin and end of a series of non-printing characters
\W - basename of the current working directory with ~ instead of $HOME directory
\e - escape character
\h - hostname

Source: to customize you bash prompt you can follow this help document.

You can also create aliases for opening and refreshing bashrc file like this (if you have to change it frequently)

In "~/.bashrc" file add the following code,
alias refprofile=' source ~/.bashrc'
alias editprofile='vi ~/.bashrc'

whereas, editprofile - opens the file for editing and refprofile - refreshes the file to reflect the change made.

Happy customization!