Tuesday, October 27, 2009

Easing console use with the mouse and shortcuts

Often times those who spend most of their time in a gui fail to see the benefit of having a mouse in Linux available at the console. What good does a mouse do in the console they question having used DOS extensively at some point in their life.

Well the mouse in a linux console can do a wide variety of things, typically the significant and most useful is the same that the mouse provides in the windowing interface-- cut and paste.

On most distributions it's a good choice to use the package manager to install GPM because it can cause conflicts with the X servers control of the mouse and the package manager typically takes care of these conflicts by terminating GPM before starting x and restarting it when x stops.

On Debian (and apt-based distributions) you can install GPM by doing the following command:

aptitude install gpm mdetect

On most redhat (or rpm based distributions based off Redhat) you can install GPM by doing the following command:

yum install gpm

In never versions of the kernel there is some experimental mode to make mice 'just work' but it's a bit flaky at this point and typically you're far better off with GPM.

If you're stuck working extensively with the local console and screen you will find this tool to be indispensable especially as you get into the advanced options of remapping the effect of each key on the mouse.

Since this post is a bit light on indepth information, lets show you how to make a command in bash that will untar/unzip/unrar all the common formats you deal with. To ensure it works you do need bzip2, gzip, tar, unrar, uncompress, and unzip on your system and after seeing how it works you'll easily be able to add additional compression types to deal with or remove the ones you don't.

extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xfvj $1 ;;
*.tbz2) tar xfvj $1 ;;
*.bz2) bzip2 -d $1 ;;
*.tar.gz) tar xfvz $1 ;;
*.tgz) tar xfvz $1 ;;
*.gz) gzip -d $1 ;;
*.tar) tar xfv $1 ;;
*.Z) uncompress $1 ;;
*.rar) unrar x $1 ;;
*.zip) unzip $1 ;;
*) echo "'$1': unknown file compression" ;;
esac
else
echo "'$1' is not understood, install the correct interpreter and update your .bashrc"
fi
}

To use it--

extract file.ext


It will save you remembering the syntax for a dozen commands you don't frequently need (although some you probably know already.)

1 comments:

  1. Ralph,

    thanks for this post. In the past I have always disabled GPM because of issues it has caused in X. I have learned since your post that in some systems if you disable GPM it breaks X. So I now have GPM enabled again and X works fine.

    ReplyDelete