Linuxsublimetext
❶ linux 命令行怎麼使用sublime
不同發行版的都有所區別,下面以ubuntu為例說明:假設你的sublime安裝在/opt目錄下首先建立軟連接,使其能從終端啟動sudoln-s/opt/Sublime\Text\2/sublime_text/usr/bin/sublime生成桌面圖標sudosublime/usr/share/applications/sublime.desktop內容:[DesktopEntry]Version=1.0Name=SublimeText2#OnlyKDE4seemstouseGenericName,sowereusetheKDEstrings.#FromUbuntu'slanguage-pack-kde-XX-basepackages,version9.04-20090413.GenericName=TextEditorExec=sublimeTerminal=falseIcon=/opt/SublimeText2/Icon/48x48/sublime_text.pngType=ApplicationCategories=TextEditor;IDE;DevelopmentX-Ayatana-Desktop-Shortcuts=NewWindow[NewWindowShortcutGroup]Name=NewWindowExec=sublime-nTargetEnvironment=Unity然後修改默認程序,替換系統的gedit程序sudosublime/usr/share/applications/defaults.list內容:將裡面默認的gedit.desktop全部用sublime.desktop替換即可。再次強調,這個僅適用於ubuntu,其他發行版,請修改對應的配置文件,如默認的程序列表defaults.list,等。
❷ Linux系統中Sublime Text無法輸入中文怎麼辦
1.保存下面的代碼為sublime_imfix.c
代碼如下:
/*
sublime-imfix.c
Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
By Cjacker Huang
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
LD_PRELOAD=。/libsublime-imfix.so sublime_text
*/
#include
#include
typedef GdkSegment GdkRegionBox;
struct _GdkRegion
{
long size;
long numRects;
GdkRegionBox *rects;
GdkRegionBox extents;
};
GtkIMContext *local_context;
void
gdk_region_get_clipbox (const GdkRegion *region,
GdkRectangle *rectangle)
{
g_return_if_fail (region != NULL);
g_return_if_fail (rectangle != NULL);
rectangle->x = region->extents.x1;
rectangle->y = region->extents.y1;
rectangle->width = region->extents.x2 - region->extents.x1;
rectangle->height = region->extents.y2 - region->extents.y1;
GdkRectangle rect;
rect.x = rectangle->x;
rect.y = rectangle->y;
rect.width = 0;
rect.height = rectangle->height;
//The caret width is 2;
//Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
gtk_im_context_set_cursor_location(local_context, rectangle);
}
}
//this is needed, for example, if you input something in file dialog and return back the edit area
//context will lost, so here we set it again.
static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
{
XEvent *xev = (XEvent *)xevent;
if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
GdkWindow * win = g_object_get_data(G_OBJECT(im_context),「window」);
if(GDK_IS_WINDOW(win))
gtk_im_context_set_client_window(im_context, win);
}
return GDK_FILTER_CONTINUE;
}
void gtk_im_context_set_client_window (GtkIMContext *context,
GdkWindow *window)
{
GtkIMContextClass *klass;
g_return_if_fail (GTK_IS_IM_CONTEXT (context));
klass = GTK_IM_CONTEXT_GET_CLASS (context);
if (klass->set_client_window)
klass->set_client_window (context, window);
if(!GDK_IS_WINDOW (window))
return;
g_object_set_data(G_OBJECT(context),「window」,window);
int width = gdk_window_get_width(window);
int height = gdk_window_get_height(window);
if(width != 0 && height !=0) {
gtk_im_context_focus_in(context);
local_context = context;
}
gdk_window_add_filter (window, event_filter, context);
} 2.編譯動態庫:
代碼如下:
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
3. 設置 LD_PRELOAD 並啟動 Sublime Text:
代碼如下:
LD_PRELOAD=。/libsublime-imfix.so sublime_text
為了不用每次啟動Sublime Text都打這么一長串東西,寫了個啟動Sublime的腳本:
代碼如下:
#!/bin/bash
SUBLIME_HOME=「/opt/sublime_text」
LD_LIB=$SUBLIME_HOME/libsublime-imfix.so
sh -c 「LD_PRELOAD=$LD_LIB $SUBLIME_HOME/sublime_text $@」
把libsublime-imfix.so放到Sublime Text目錄下並修改腳本中的SUBLIME_HOME,這樣Sublime Text 就可以輸入中文了。
上面就是Linux下Sublime Text 無法輸入中文的解決方法的介紹了,只要按照上面的步驟,就能在Sublime Text 中輸入中文了
❸ linux下怎麼安裝sublime text
安裝方法1: 通過apt-get install來安裝,可以如下來做: sudo add-apt-repository ppa:webupd8team/sublime-text-2 sudo apt-get update sudo apt-get install sublime-text-2 安裝方法2: 1.官網下載安裝包 2.解壓並不難,隨便找個目錄解壓就行,但考慮到後面要能在命令行下方便的快速啟動,推薦解壓到/usr/lib/目錄下,我用的方法是先解壓後搬移,命令如下: tar -xvf Sublime\ Text\ 2.0.1.tar.bz2 mv Sublime\ Text\ 2 /usr/lib/ 其中的\為轉義符 這樣做是因為$PATH這個環境變數自動涵蓋了/usr/lib這個目錄,不用專門去修改環境變數。 然後鍵入: ln -s /usr/lib/Sublime\ Text\ 2/sublime_text /usr/bin/sublime 3.側邊條LaunchBar設置 由於並非安裝,缺少Ubuntu桌面運行的一些基本配置,比如不能將它加入桌面側邊的啟動器,這個和通過軟體安裝中心安裝的程序不太一樣。要做到這一點,需要增加一個配置文件,放在/usr/share/appliations/路徑下,比如增加sublime.desktop,文件內容如下: 參考配置 : [Desktop Entry] Version=2.0.1 Name=Sublime Text 2 GenericName=Text Editor Exec=sublime Terminal=false Icon=/usr/lib/Sublime Text 2/Icon/48x48/sublime_text.png Type=Application Categories=TextEditor;IDE;Development X-Ayatana-Desktop-Shortcuts=NewWindow [NewWindow Shortcut Group] Name=New Window Exec=sublime -n TargetEnvironment=Unity