网上关于安装 sublime 的文章有很多,也有对于无法输入中文的问题解决。写此文章的目的仅仅是记录安装过程中遇到的一些问题。
安装环境:WMware 14 + Ubuntu 16.04
方法一:直接从 git 仓库获取安装源,进行安装即可。通过这种方法进行安装直接解决了通过官网下载进行安装后无法输入中文的问题。
vicky@vicky-machine:~/下载$ sudo apt-get install git
vicky@vicky-machine:~/下载$ git clone https://github.com/lyfeyaj/sublime-text-imfix.git
vicky@vicky-machine:~/下载$ cd sublime-text-imfix/
vicky@vicky-machine:~/下载/sublime-text-imfix$ sudo ./sublime-imfix
vicky@vicky-machine:~/下载/sublime-text-imfix$ cd /usr/bin/
vicky@vicky-machine:/usr/bin$ ls -la |grep subl
-rwxr-xr-x 1 root root 107 11月 23 14:44 subl
vicky@vicky-machine:/usr/bin$ subl
===========================================================================
以下两种仅是对参照网上介绍进行安装的整理。可以忽略。
方法二:网上大部分文章介绍的方法,先从官网下载文件,再从 git 仓库获取
vicky@vickymachine:~/下载$ cd /opt
vicky@vickymachine:/opt$ sudo tar jxvf /home/vicky/下载/sublime_text_3_build_3176_x64.tar.bz2
vicky@vickymachine:~/record$ sudo apt-get install git
vicky@vickymachine:~/record$ git clone https://github.com/lyfeyaj/sublime-text-imfix.git
vicky@vickymachine:~/record$ cd sublime-text-imfix/
vicky@vickymachine:~/record/sublime-text-imfix$ sudo ./sublime-imfix
vicky@vickymachine:/usr/bin$ subl
方法三:
vicky@vickymachine:~/下载$ cd /opt
vicky@vickymachine:/opt$ sudo tar jxvf /home/vicky/下载/sublime_text_3_build_3176_x64.tar.bz2
vicky@vickymachine:~/record$ sudo apt-get install git
vicky@vickymachine:~/record$ git clone https://github.com/lyfeyaj/sublime-text-imfix.git
vicky@vickymachine:~/record$ cd sublime-text-imfix/
vicky@vickymachine:~/record$/sublime-text-imfix/lib$ sudo cp libsublime-imfix.so /opt/sublime_text_3/
vicky@vickymachine:/usr/bin$ cd /opt/sublime_text_3/
vicky@vickymachine:/opt/sublime_text_3 sudo touch subl
vicky@vickymachine:/opt/sublime_text_3 sudo vim subl
文件内容:
#!/bin/sh
export LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so
exec /opt/sublime_text_3/sublime_text "$@"
vicky@vickymachine:/opt/sublime_text_3 sudo apt-get install vim
vicky@vickymachine:/opt/sublime_text_3 sudo vim subl
vicky@vickymachine:/opt/sublime_text_3 sudo cp subl /usr/bin/
vicky@vickymachine:/opt/sublime_text_3 cd /usr/bin/
vicky@vickymachine:/usr/bin$ sudo chmod a+x subl
vicky@vickymachine:/usr/bin$ subl
1.下载 sublime3 。
官网地址:
根据自己的需要,下载 64 位或 32 位的版本。
可以通过以下方式查看本机是 64 位还是 32 位。
$ getconf LONG_BIT
2.将文件解压到 /opt/下
vicky@vickymachine:~$ cd 下载
vicky@vickymachine:~/下载$ ll
总用量 10084
drwxr-xr-x 2 vicky vicky 4096 11月 23 10:00 ./
drwxr-xr-x 20 vicky vicky 4096 11月 23 10:32 ../
-rw-rw-r-- 1 vicky vicky 10314226 11月 23 10:00 sublime_text_3_build_3176_x64.tar.bz2
vicky@vickymachine:~/下载$ cd /opt
vicky@vickymachine:/opt$ sudo tar jxvf /home/vicky/下载/sublime_text_3_build_3176_x64.tar.bz2
[sudo] vicky 的密码:
sublime_text_3/
sublime_text_3/sublime.py
sublime_text_3/sublime_text.desktop
sublime_text_3/Packages/
sublime_text_3/Packages/Haskell.sublime-package
sublime_text_3/Packages/PHP.sublime-package
sublime_text_3/Packages/Diff.sublime-package
sublime_text_3/Packages/Text.sublime-package
sublime_text_3/Packages/Textile.sublime-package
sublime_text_3/Packages/SQL.sublime-package
sublime_text_3/Packages/Clojure.sublime-package
sublime_text_3/Packages/ActionScript.sublime-package
sublime_text_3/Packages/R.sublime-package
sublime_text_3/Packages/OCaml.sublime-package
sublime_text_3/Packages/C#.sublime-package
sublime_text_3/Packages/ASP.sublime-package
sublime_text_3/Packages/Color Scheme - Default.sublime-package
sublime_text_3/Packages/Matlab.sublime-package
sublime_text_3/Packages/CSS.sublime-package
sublime_text_3/Packages/Rust.sublime-package
sublime_text_3/Packages/Color Scheme - Legacy.sublime-package
sublime_text_3/Packages/Vintage.sublime-package
sublime_text_3/Packages/LaTeX.sublime-package
sublime_text_3/Packages/Python.sublime-package
sublime_text_3/Packages/Lisp.sublime-package
sublime_text_3/Packages/Theme - Default.sublime-package
sublime_text_3/Packages/Markdown.sublime-package
sublime_text_3/Packages/Rails.sublime-package
sublime_text_3/Packages/JavaScript.sublime-package
sublime_text_3/Packages/Default.sublime-package
sublime_text_3/Packages/RestructuredText.sublime-package
sublime_text_3/Packages/Scala.sublime-package
sublime_text_3/Packages/Go.sublime-package
sublime_text_3/Packages/Makefile.sublime-package
sublime_text_3/Packages/Language - English.sublime-package
sublime_text_3/Packages/AppleScript.sublime-package
sublime_text_3/Packages/Java.sublime-package
sublime_text_3/Packages/Regular Expressions.sublime-package
sublime_text_3/Packages/HTML.sublime-package
sublime_text_3/Packages/ShellScript.sublime-package
sublime_text_3/Packages/TCL.sublime-package
sublime_text_3/Packages/Groovy.sublime-package
sublime_text_3/Packages/YAML.sublime-package
sublime_text_3/Packages/Batch File.sublime-package
sublime_text_3/Packages/Objective-C.sublime-package
sublime_text_3/Packages/Erlang.sublime-package
sublime_text_3/Packages/Lua.sublime-package
sublime_text_3/Packages/Pascal.sublime-package
sublime_text_3/Packages/Ruby.sublime-package
sublime_text_3/Packages/C++.sublime-package
sublime_text_3/Packages/D.sublime-package
sublime_text_3/Packages/XML.sublime-package
sublime_text_3/Packages/Git Formats.sublime-package
sublime_text_3/Packages/Graphviz.sublime-package
sublime_text_3/Packages/Perl.sublime-package
sublime_text_3/plugin_host
sublime_text_3/crash_reporter
sublime_text_3/python3.3.zip
sublime_text_3/sublime_text
sublime_text_3/changelog.txt
sublime_text_3/sublime_plugin.py
sublime_text_3/Icon/
sublime_text_3/Icon/16x16/
sublime_text_3/Icon/16x16/sublime-text.png
sublime_text_3/Icon/32x32/
sublime_text_3/Icon/32x32/sublime-text.png
sublime_text_3/Icon/256x256/
sublime_text_3/Icon/256x256/sublime-text.png
sublime_text_3/Icon/128x128/
sublime_text_3/Icon/128x128/sublime-text.png
sublime_text_3/Icon/48x48/
sublime_text_3/Icon/48x48/sublime-text.png
解压之后,目录 /opt 下多了一个 sublime_text_3 的目录。
vicky@vickymachine:/opt$ ll
总用量 12
drwxr-xr-x 3 root root 4096 11月 23 10:37 ./
drwxr-xr-x 24 root root 4096 11月 23 09:55 ../
drwxrwxr-x 4 root root 4096 5月 14 2018 sublime_text_3/
3.此时,直接进入该目录,运行 sublime_text 就可启动 sublime
vicky@vickymachine:/opt$ cd sublime_text_3/
vicky@vickymachine:/opt/sublime_text_3$ ll
总用量 18236
drwxrwxr-x 4 root root 4096 5月 14 2018 ./
drwxr-xr-x 3 root root 4096 11月 23 10:37 ../
-rw-rw-r-- 1 root root 47997 5月 14 2018 changelog.txt
-rwxrwxr-x 1 root root 517280 5月 14 2018 crash_reporter*
drwxrwxr-x 7 root root 4096 5月 14 2018 Icon/
drwxrwxr-x 2 root root 4096 5月 14 2018 Packages/
-rwxrwxr-x 1 root root 8137488 5月 14 2018 plugin_host*
-rw-rw-r-- 1 root root 2628080 5月 14 2018 python3.3.zip
-rw-rw-r-- 1 root root 36619 5月 14 2018 sublime_plugin.py
-rw-rw-r-- 1 root root 38624 5月 14 2018 sublime.py
-rwxrwxr-x 1 root root 7235496 5月 14 2018 sublime_text*
-rw-rw-r-- 1 root root 532 5月 14 2018 sublime_text.desktop
vicky@vickymachine:/opt/sublime_text_3$ ./sublime_text
但是现在无法输入中文
4.安装 git
vicky@vickymachine:~/record$ sudo apt-get install git
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会同时安装下列软件:
git-man liberror-perl
建议安装:
git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-cvs git-mediawiki git-svn
下列【新】软件包将被安装:
git git-man liberror-perl
升级了 0 个软件包,新安装了 3 个软件包,要卸载 0 个软件包,有 81 个软件包未被升级。
需要下载 3,470 kB 的归档。
解压缩后会消耗 25.6 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 liberror-perl all 0.17-1.2 [19.6 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git-man all 1:2.7.4-0ubuntu1.5 [736 kB]
获取:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 git amd64 1:2.7.4-0ubuntu1.5 [2,714 kB]
已下载 3,470 kB,耗时 3秒 (1,052 kB/s)
正在选中未选择的软件包 liberror-perl。
(正在读取数据库 ... 系统当前共安装有 216176 个文件和目录。)
正准备解包 .../liberror-perl_0.17-1.2_all.deb ...
正在解包 liberror-perl (0.17-1.2) ...
正在选中未选择的软件包 git-man。
正准备解包 .../git-man_1%3a2.7.4-0ubuntu1.5_all.deb ...
正在解包 git-man (1:2.7.4-0ubuntu1.5) ...
正在选中未选择的软件包 git。
正准备解包 .../git_1%3a2.7.4-0ubuntu1.5_amd64.deb ...
正在解包 git (1:2.7.4-0ubuntu1.5) ...
正在处理用于 man-db (2.7.5-1) 的触发器 ...
正在设置 liberror-perl (0.17-1.2) ...
正在设置 git-man (1:2.7.4-0ubuntu1.5) ...
正在设置 git (1:2.7.4-0ubuntu1.5) ...
vicky@vickymachine:~/record$
5.获取文件
vicky@vickymachine:~/record$ git clone https://github.com/lyfeyaj/sublime-text-imfix.git
正克隆到 'sublime-text-imfix'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 198 (delta 1), reused 6 (delta 1), pack-reused 191
接收对象中: 100% (198/198), 125.09 KiB | 101.00 KiB/s, 完成.
处理 delta 中: 100% (77/77), 完成.
检查连接... 完成。
6.要想在 sublime 中输入中文,有两种方法:
方法一:直接运行文件 ./sublime-imfix
1)进入目录运行: cd sublime-text-imfix/
vicky@vickymachine:~/record$ cd sublime-text-imfix/
2)直接运行: sudo ./sublime-imfix
vicky@vickymachine:~/record/sublime-text-imfix$ sudo ./sublime-imfix
Checking for installation of Sublime Text 3...........
It seems you do not install Sublime Text 3 in your system.
Do you want to install it? [Y/N]: y
*********** Adding Sublime Text 3 PPA **********************
OK
deb https://download.sublimetext.com/ apt/stable/
*********** Updating system ********************************
*********** Installing Sublime Text 3 **********************
*********** Sublime Text 3 installed successfully **********
Checking for installation of Fcitx Input Methods....
/usr/bin/fcitx
...........................................Installed
/usr/bin/subl
/usr/bin/fcitx
*********** Adding shared lib to sublime directory ***********
*********** Checking for existing file ***********************
*********** Replacing subl with new one **********************
*********** Replacing sublime-text.desktop with new one ******
*********** Sublime Text input method problem fixed! *********
*********** More: Installing extra skins *********************
*********** Unpacking skin into current directory ************
anran/cangjie.png
anran/wanfeng.png
anran/ziranma.png
anran/vk_inactive.png
anran/next.png
anran/input.png
anran/punc_inactive.png
anran/menu.png
anran/bingchan.png
anran/vk_active.png
anran/wubi.png
anran/quwei.png
anran/punc_active.png
anran/erbi.png
anran/active.png
anran/
anran/fcitx_skin.conf
anran/bar.png
anran/keyboard.png
anran/logo.png
anran/kbd.png
anran/cn.png
anran/chttrans_active.png
anran/sunpinyin.png
anran/prev.png
anran/pinyin.png
anran/fullwidth_inactive.png
anran/inactive.png
anran/dianbaoma.png
anran/wbpy.png
anran/fullwidth_active.png
anran/remind_inactive.png
anran/remind_active.png
anran/shuangpin.png
anran/chttrans_inactive.png
anran/en.png
** Copying skin to Fcitx skin directory: /usr/share/fcitx/skin **
Done!
Thanks for using this script to fix CJK Input Method problem of SublimeText 2/3.
Re-login your X windows and start to use SublimeText 2/3 with Fcitx!
验证
运行文件之后,在 /usr/bin 下应自动生成了启动文件 subl,直接运行 subl 即可启动 sublime,并且可以输入中文了。
vicky@vickymachine:/usr/bin$ ls -la |grep subl
-rwxr-xr-x 1 root root 107 11月 23 10:43 subl
vicky@vickymachine:/usr/bin$ subl
方法二:
将库文件 sublime-text-imfix/lib/libsublime-imfix.so* 拷贝到 之前安装 sublime 的路径下 /opt/sublime_text_3
vicky@vickymachine:~$ cd sublime-text-imfix/
vicky@vickymachine:~/Vicky/sublime-text-imfix$ cd lib/
vicky@vickymachine:~/record/sublime-text-imfix/lib$ sudo cp libsublime-imfix.so /opt/sublime_text_3/
vicky@vickymachine:/usr/bin$ cd /opt/sublime_text_3/
新建一个启动脚本文件,放到 /usr/bin 下,并增加可执行权限。
文件内容:
#!/bin/sh
export LD_PRELOAD=/opt/sublime_text_3/libsublime-imfix.so
exec /opt/sublime_text_3/sublime_text "$@"
vicky@vickymachine:/opt/sublime_text_3 sudo touch subl
vicky@vickymachine:/opt/sublime_text_3 sudo vim subl
sudo: vim:找不到命令
提示:如未安装 vim ,请安装。
vicky@vickymachine:/opt/sublime_text$ sudo apt-get install vim
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包是自动安装的并且现在不需要了:
linux-headers-4.15.0-29 linux-headers-4.15.0-29-generic
linux-image-4.15.0-29-generic linux-modules-4.15.0-29-generic
linux-modules-extra-4.15.0-29-generic
使用'sudo apt autoremove'来卸载它(它们)。
将会同时安装下列软件:
vim-runtime
建议安装:
ctags vim-doc vim-scripts vim-gnome-py2 | vim-gtk-py2 | vim-gtk3-py2
| vim-athena-py2 | vim-nox-py2
下列【新】软件包将被安装:
vim vim-runtime
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 38 个软件包未被升级。
需要下载 6,199 kB 的归档。
解压缩后会消耗 30.0 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim-runtime all 2:7.4.1689-3ubuntu1.2 [5,164 kB]
获取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 vim amd64 2:7.4.1689-3ubuntu1.2 [1,036 kB]
已下载 6,199 kB,耗时 3秒 (1,648 kB/s)
正在选中未选择的软件包 vim-runtime。
(正在读取数据库 ... 系统当前共安装有 252697 个文件和目录。)
正准备解包 .../vim-runtime_2%3a7.4.1689-3ubuntu1.2_all.deb ...
正在添加 vim-runtime 导致 /usr/share/vim/vim74/doc/help.txt 转移到 /usr/share/vim/vim74/doc/help.txt.vim-tiny
正在添加 vim-runtime 导致 /usr/share/vim/vim74/doc/tags 转移到 /usr/share/vim/vim74/doc/tags.vim-tiny
正在解包 vim-runtime (2:7.4.1689-3ubuntu1.2) ...
正在选中未选择的软件包 vim。
正准备解包 .../vim_2%3a7.4.1689-3ubuntu1.2_amd64.deb ...
正在解包 vim (2:7.4.1689-3ubuntu1.2) ...
正在处理用于 man-db (2.7.5-1) 的触发器 ...
正在设置 vim-runtime (2:7.4.1689-3ubuntu1.2) ...
正在设置 vim (2:7.4.1689-3ubuntu1.2) ...
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vim (vim)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vimdiff (vimdiff)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/rvim (rvim)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/rview (rview)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/vi (vi)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/view (view)
update-alternatives: 使用 /usr/bin/vim.basic 来在自动模式中提供 /usr/bin/ex (ex)
vicky@vickymachine:/opt/sublime_text_3 sudo vim subl
vicky@vickymachine:/opt/sublime_text_3 sudo cp subl /usr/bin/
vicky@vickymachine:/opt/sublime_text_3 cd /usr/bin/
vicky@vickymachine:/usr/bin$ ls -la |grep subl
-rw-r--r-- 1 root root 107 11月 23 10:59 subl
vicky@vickymachine:/usr/bin$ sudo chmod a+x subl
vicky@vickymachine:/usr/bin$ ls -la |grep subl
-rwxr-xr-x 1 root root 107 11月 23 10:59 subl
启动验证,可以输入中文了
vicky@vickymachine:/usr/bin$ subl
vicky@vickymachine:/usr/bin$