Ubuntu 中改变文件的默认打开方式(转)

时间:2024-08-03 15:07:26

 源自:Ubuntu 中改变文件的默认打开方式

1. 相关配置文件

  1. 全局配置
  2. /etc/gnome/defaults.list
  3. /usr/share/applications/mimeinfo.cache
  4. 个人配置
  5. ~/.local/share/applications/mimeapps.list
  6. ~/.local/share/applications/mimeinfo.cache

2. /etc/gnome/defaults.list部分内容

  1. [Default Applications]
  2. application/csv=openoffice.org-calc.desktop
  3. application/excel=openoffice.org-calc.desktop
  4. application/msexcel=openoffice.org-calc.desktop
  5. application/msword=openoffice.org-writer.desktop
  6. application/ogg=totem.desktop
  7. application/pdf=evince.desktop
  8. application/postscript=evince.desktop
  9. application/rtf=openoffice.org-writer.desktop
  10. application/tab-separated-values=openoffice.org-calc.desktop
  11. application/vnd.lotus-1-2-3=openoffice.org-calc.desktop
  12. application/vnd.ms-excel=openoffice.org-calc.desktop
  13. application/vnd.ms-word=openoffice.org-writer.desktop
  14. application/vnd.rn-realmedia=totem.desktop
  15. text/plain=gedit.desktop

3. /usr/share/applications/mimeinfo.cache部分内容

  1. [MIME Cache]
  2. text/plain=gedit.desktop
  3. application/vnd.ms-excel.template.macroenabled.12=openoffice.org3-calc.desktop
  4. audio/x-s3m=gnome-mplayer.desktop
  5. application/vnd.ms-word=openoffice.org3-writer.desktop
  6. application/x-lzma=file-roller.desktop
  7. video/x-mng=gnome-mplayer.desktop
  8. image/x-portable-bitmap=f-spot-view.desktop;eog.desktop;
  9. x-directory/normal=nautilus-folder-handler.desktop
  10. image/x-dcraw=f-spot-view.desktop

4. 更改文件默认打开方式

案例:更改文本文件的默认打开方式从gedit改为gvim

(1). 修改/etc/gnome/defaults.list文件

  1. text/plain=gedit.desktop
  2. 改为
  3. text/plain=gvim.desktop

(2). 修改/usr/share/applications/mimeinfo.cache文件

  1. text/plain=gedit.desktop
  2. 改为
  3. text/plain=gvim.desktop

5. 另外一种解决方案

右击文件 --> 属性, 如下图

Ubuntu 中改变文件的默认打开方式(转)

在打开方式页中修改即可

6. 注意

网上有很多帖子都是只提到了/etc/gnome/defaults.list这个文件,而没有提到/usr/share/applications/mimeinfo.cache这个缓存文件,结果当然是修改无效咯。

当然,如果你把缓存文件删除也行。