| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
|
By krishvij at 2005-05-12 00:36
|
|
Introduction
It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once.
This gives choice to the users of a system, allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice of editor to invoke if the user has not specified a particular preference.
In our example, we are going to create a link called editor, which will have a generic name of myeditor. This link and generic name are going to be associated with 3 text editors, namely gedit, kwrite and emacs. We will then switch the default editor between these 3 editors according to user preference. The steps to implement this scenario are less, but the concept is not that simple to understand.
Implementing Our Alternative
Issue the following commands :-
Code:
alternatives --install /etc/alternatives/editor myeditor /usr/bin/kwrite 90
alternatives --install /etc/alternatives/editor myeditor /usr/bin/gedit 90
alternatives --install /etc/alternatives/editor myeditor /usr/bin/emacs 90
The first command installs a link editor under /etc/alternatives directory, links it to a generic name of myeditor, which in turn is linked to the kwrite application with a priority of 90. The next two commands do the same thing for gedit and emacs.
Now, Issue the following command
Code:
alternatives --config myeditor
Your output will be as follows :-
Code:
There are 3 programs which provide 'myeditor'.
Selection Command
-----------------------------------------------
*+ 1 /usr/bin/kwrite
2 /usr/bin/gedit
3 /usr/bin/emacs
Enter to keep the current selection[+], or type selection number:
The option with the + sign is the default application. As you see, the above command also expects you to specify another choice if you wish to. Now, we have successfully created our alternative and have associated it with the above 3 applications.
Now, double click on the Home icon on your desktop. I am assuming that you are currently working on KDE. Right click on any text file and then select Open With -> Other. In the window that is displayed, type /etc/alternatives/myeditor in the Open With Text Box and then tick the checkbox at the bottom that says Remember Application Association for this type of file and then click on the OK button. That's it. As you see in the above output, kwrite is the default editor. That is, whenever you double click on a text file, it will be opened in kwrite. Run the previous command again
Code:
alternatives --config myeditor
You will get the following output. Just type 2 as the selection number and press enter :-
Code:
There are 3 programs which provide 'myeditor'.
Selection Command
-----------------------------------------------
*+ 1 /usr/bin/kwrite
2 /usr/bin/gedit
3 /usr/bin/emacs
Enter to keep the current selection[+], or type selection number: 2
Now, if you double click on any text file, it will open in gedit. Likewise, you can specify emacs as your default text editor
--------------------------------------------------------------------------------------------------------------------------
Hope this HOWTO gives you a starting point to go deep into this topic. For suggestions / comments, please mail me at vijaykrishnan@elmaqedu.com
|
|
|
|
All times are GMT -5. The time now is 08:00 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|