Ubuntu 20.04 手动安装 sublime_text 并建立搜索栏图标(解决 Ubuntu 20.04 桌面图标无法双击打开问题)
下载sublime_text_3离线程序包
wget https://download.sublimetext.com/sublime_text_3_build_3211_x64.tar.bz2
#x86: wget https://download.sublimetext.com/sublime_text_3_build_3211_x32.tar.bz2
解压程序包并放至/opt/
下,路径更名为/opt/sublime_text/
sudo tar -jxvf sublime_text_3_build_3211_x64.tar.bz2 -C /opt/
sudo mv /opt/sublime_text_3/ /opt/sublime_text/
建立软链接,命令行下执行subl xxx.txt
即可使用sublime_text编辑文件
sudo ln -s /opt/sublime_text/sublime_text /usr/bin/subl
在搜索栏建立图标,可以用 win 键(Command 键)呼出搜索栏,输入subl
即可检索到sublime_text
这里涉及到 Ubuntu20.04 系统在 gnome 下建立图标,网上大部分方法仅仅是为.desktop文件添加+x
权限,没有对该文件添加属性信息metadata::trusted
,因此无法正常搜索得到结果,正确方法如下:
cd ~/.local/share/applications
cat <<EOF > sublime_text.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F
Terminal=false
MimeType=text/plain;
Icon=/opt/sublime_text/Icon/128x128/sublime-text.png
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;
EOF
chmod +x sublime_text.desktop
gio set sublime_text.desktop "metadata::trusted" TRUE
gio info sublime_text.desktop | grep "metadata::trusted"
同样,在 Ubuntu 20.04 桌面添加图标,同时也要添加属性信息metadata::trusted
图标才能使用,方法如下:
cd ~/Desktop
cat <<EOF > sublime_text.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=Sublime Text
GenericName=Text Editor
Comment=Sophisticated text editor for code, markup and prose
Exec=/opt/sublime_text/sublime_text %F
Terminal=false
MimeType=text/plain;
Icon=/opt/sublime_text/Icon/128x128/sublime-text.png
Categories=TextEditor;Development;
StartupNotify=true
Actions=Window;Document;
EOF
chmod +x sublime_text.desktop
gio set sublime_text.desktop "metadata::trusted" TRUE
gio info sublime_text.desktop | grep "metadata::trusted"
参考: