Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I started using Sublime Text 2 a week or so ago and I loved it so much I've spent $60 on it and now want to use it for everything.

Gedit currently has ownership of most of the text file associations. I'd essentially like to replace any association to gedit with sublime-text-2.

Any tips available on bulk association changing?

share|improve this question
add comment

2 Answers

up vote 20 down vote accepted

Make a sublime launcher .desktop file. I don't have one so I can't post exact instructions on that. You'll probably want to put it in /usr/share/applications/

System wide associations:

sudo sed -i 's/gedit.desktop/yournew.desktop/g' /usr/share/applications/defaults.list

Just your user's associations:

sed -i 's/gedit.desktop/yournew.desktop/g' ~/.local/share/applications/mimeapps.list

Edit from Oli. If you're using the PPA for Sublime Text 2, there is already a .desktop file for it sitting in /usr/share/applications/ so you can just run:

sudo sed -i 's/gedit.desktop/sublime-text-2.desktop/g' /usr/share/applications/defaults.list

Edit from trent. Running on 13.04, the above update didn't change the file association from gedit to sublime-text-2. It was necessary to update the file: /etc/gnome/defaults.list.

sudo sed -i 's/gedit.desktop/sublime-text-2.desktop/g' /etc/gnome/defaults.list
share|improve this answer
    
Magic, thanks. I've added what the PPA users (myself included) can use based on your answer. –  Oli Mar 22 '12 at 15:22
    
Would you mind providing a copy of the .desktop file installed with the PPA version? (For those of use who refuse to install packages from untrusted sources) –  earthmeLon Aug 10 '12 at 16:01
    
Here is the ppa launchpad.net/~webupd8team/+archive/sublime-text-2 –  hbdgaf Aug 10 '12 at 17:23
add comment

There is another way to change the association. It is via using Ubuntu-tweak.

  1. Install Ubuntu tweak

  2. Open it via Dash by typing "Ubuntu tweak"

    enter image description here

  3. After opening it, Click on the Admin tab.

    enter image description here

  4. Then click on File type manager section

    enter image description here

  5. Then first select the Text catagory from the left side bar, and then click on the Associated Applications column to sort it by Application name

    enter image description here

  6. After the application is sorted by name, Select the top entry with Gedit, then Press and hold the Shift key and click on the last entry with gedit. Then click on the Edit button.

    enter image description here

  7. A new window will open where you can see all installed text editor.

    enter image description here

  8. Then select the desired application from list and click close. You can also Click on the Add button to add an application which is not installed in pre-defined system folder.

Hope this will help. If you want to reset them, you can click the reset button also.

The good thing in this solution is, you can't accidentally mess up your system .desktop file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.