Thursday, June 25, 2009

Associating application with file types in Linux konsole

Use the command "Complete" to associate applications with the filte types.

For example, We can set, javac command will list only java files on pressing tab key.

You are going to compile a java file(Begin.java) inside a directory named 'training', but the directory training contains some .class, .txt, and .conf files.

If you try to compile Begin.java using, javac , it will shows other file extensions also, to avoid this, you can associate the filetype .java to an application javac.

like wise, we can set for the below filetypes and applications.
gedit - .txt
java - .class
kview - .png,.jpg

Syntax:

complete -G '*.java' javac
complete -G '*.txt' gedit
complete -G '*.png' kview
complete -G '*.class" java


To list all the combinations:

Typing the command complete will list the added combinations.

complete associations last only for the current bash session. If you exit and open a console, javac will no longer be associated with .java files. You need to associate file types to applications each time you start a new console session.

For permanent associations, you need to add the command to one of the bash startup scripts, such as ~/.bashrc. Then, whenever you are at the console, javac will be associated with .java files.


To revert: (complete -r )
eg. complete -r javac

to remove all complete, type complete -r

No comments: