Open any file from terminal in Gnome

I normally use terminals to navigate through directories in my computer. I often have to remember the executable filename of different applications to open files. Like to open a pdf file I have to remember evince, for an audio or video file – vlc. But its really difficult to remember executable filenames for all types of files. For example I don’t remember how to open a .xls file from command line.

There’s a command which open files using GNOME file handlers – “gnome-open”. Now, when I have to open any file I just type in “gnome-open <filename>”. Simple !

To make things more simple I have made an alias ‘go’ for ‘gnome-open’. Now opening a file from terminal is as easy as typing “go <filename>” in terminal.

Posted in GNOME, Linux | Tagged , | 3 Comments

Extract all Archive File Format With Just One Command in Linux

There are large number of archive file formats – .zip, .tar.gz, .tar, .gz, .7zip, .rar, etc etc..

I find it difficult to remember the command line options for extracting different archive file formats. So, I wrote a bash function which given a archive filename as an input extracts it.

Here’s the function :

extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.z) uncompress $1 ;;
*) echo "'$1' cannot be extracted via extract ()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

This function is pretty self explanatory. But as it is not powerful. It becomes the ultimate tool for extractive archive files if you copy this function in you bashrc file (~/.bashrc).

Now you can simply extract any file like this:


$extract test.tar.gz

Hope you like this function.

Note: This function doesn’t work with files have space in its name. I didn’t waste time in solving this issue as I normally don’t use such filenames. If any of you solve this issue, please do let me know. I would include it with your name in this post. :D

Posted in bash, Linux, Uncategorized | Tagged , , | 6 Comments

Google Search Now With Wiki Features

Today, I suddenly saw a new feature of Google search. One can now promote a search result, comment on a search result or remove a search result. Take a look below :

 

google

I am sure this feature will help Google provide better and more personalized results !

Happy Googling !

Posted in Google | Tagged | 1 Comment

Windows Live Writer !

 

Yeah I am using Windows vista for the first time today. I am loving some cool tools. I am posting from Windows Live writer !

Windows is also not that bad !

Technorati Tags: ,
Posted in windows | Tagged , | Leave a comment

Directory Navigation Tips in Linux

Many of us just use cd, cd .., cd <dir> to navigate through the file system in Linux. Directory or file-system navigation can be simplified by using following commands -

1) Many times we are in some directory say /home/user/foo and we need to go to the directory /usr/share/bar . After completing tasks in this directory, if one needs to get back to the previous directory, he would type in ‘cd /home/user/foo’ . Won’t it be far easy if we had some kind of back button as in Nautilus or Windows Explorer ? Its already there in Linux. Just type in
$ cd -
and you will reach back to the previous directory.

2) Another important tool to make navigation easier is ‘pushd’ and ‘popd’. Say you are in some directory /home/user/foo1 and then you wish to navigate to /home/user/foo2 and then to /home/user/foo3
After all these you need to back to previous directories. You can use pushd and popd like this :

$ pwd
/home/user/foo1
$ pushd .
$ cd /home/user/foo2
$ pushd .
$ cd /home/user/foo3

Now to get back to previous directories -
$ popd
$ pwd
/home/user/foo2

pushd actually push its argument directory to a stack and popd changes the current directory to the one on top of the stack.

Hope you enjoyed these tips.

Posted in bash, Linux | Tagged , , , , | 5 Comments