星期四, 十二月 29, 2011

在 Ubuntu 11.10 中安装 Linux Deepin translucency Gnome-shell theme

来源:
http://ubuntuguide.net/install-linux-deepin-translucency-theme-in-ubuntu-11-10-gnome-shell

Linux Deepin 是一个源自中国的 Ubuntu 定制发行版,刚刚发布 11.12 beta。它定制了一个 translucency gnome-shell theme。下面我们在 Ubuntu 11.10中安装这个主题,本方法同样试用于其它发行版。

1. 安装 git

sudo apt-get install git
mkdir git-project &&cd git-project

2. 下载 deepin-gs-theme 和 lazycat-gs-theme

git clone git://github.com/manateelazycat/deepin-gs-theme
git clone git://github.com/manateelazycat/lazycat-gs-theme
git clone git://github.com/manateelazycat/DGSE.git

3. 把上述 themes 移动到 ~/.themes

mv deepin-gs-theme/ ~/.themes/
mv lazycat-gs-theme/ ~/.themes/

把 DGSE 移动到 /usr/share/gnome-shell/extensions/

sudo mv DGSE /usr/share/gnome-shell/extensions/

4. 安装 Gnome Tweak Tool, 启用 theme and DGSE

sudo apt-get install gnome-tweak-tool

要切换主题,需要安装 gnome-shell-extensions-user-theme

sudo add-apt-repository ppa:webupd8team/gnome3
sudo apt-get update
sudo apt-get install gnome-shell-extensions-user-theme

两个 Ubuntu / Linux 截图工具

1. Area Screenshot

或许你已经使用过 GNOME Shell 默认屏幕录像工具(CTRL+ALT+SHIFT+R),那么也可以体会下这款提供高级截图功能的 GNOME Shell 扩展 Area Screenshot。
前往 Shell Extensions 即可安装 Area Screenshot,非常简单。
之后需要额外配置下快捷键,这里以推荐的 SUPER+PRINT (常见键盘上 SUPER 即是 WIN 键)为例:

key='/apps/metacity/global_keybindings/run_command_10'
gconftool-2 -s --type string "$key" 'Print'

之后当按下 SUPER+PRINT 组合键的时候就进入截图模式了。此时可以拖拽出一个矩形区域松开鼠标即可完成截图。亦可按下数字键 1 ~9启动倒计时器,代表等待 1~9 秒后再进行截图,过程中会在左下角读秒,从而实现对于普通截图工具做不到的弹出菜单截图。若再次按下 0 则关闭倒计时器。

截图默认保存在 $HOME/Pictures 目录下。

此外在截图完毕后还会尝试运行位于 $HOME/bin/ 下的名为 area-screenshot-post 的 Bash 脚本 ,于是可以自由定义截图后的行为

项目 Github 首页

2. 深度截图(deepinScrot)

update: 在下面找最新版的deb包

http://mirrors.ustc.edu.cn/deepin/pool/main/d/deepin-scrot/

首先,确保系统已经安装 python-Xlib 库文件和 pyhon-gtk2。如果您的系统还没有安装这两个文件,可以通过下面命令安装:


sudo apt-get install python-xlib python-gtk2
 
同时,下载深度截图源码包:

git clone git://github.com/lovesnow/deepin-scrot.git
 
下载完毕之后,切换到deepin-scrot 目录,然后在终端执行下面命令启动截图工具:

cd ./src && chmod 755 deepinScrot.py
./deepinScrot.py

星期五, 十一月 11, 2011

Sublime Text 2:编辑器新秀


主页:http://www.sublimetext.com

跨平台:windows / Linux / Mac OS

插件采用python语言开发,目前主程序和插件开发进展很快,目前已经足以作为一个强大的脚本开发 / Web开发 IDE 。

插件包控制 Sublime Package Control

按Ctrl+` 启动Sublime Text 2 console,输入如下回车安装package manager

import urllib2,os;pf='Package Control.sublime-package';ipp=sublime.installed_packages_path();os.makedirs(ipp) if not os.path.exists(ipp) else None;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())

推荐插件

python类

1. 代码导航


I) Sublime Code Intel 插件提供代码补全与函数跳转功能。

    Code intelligence plugin ported from Open Komodo Editor to the Sublime Text 2 editor.

    Supports all the languages Komodo Editor supports for Code Intelligence (CIX, CodeIntel2): PHP, Python, RHTML, JavaScript, Smarty, Mason, Node.js, XBL, Tcl, HTML, HTML5, TemplateToolkit, XUL, Django, Perl, Ruby, Python3.

II)SublimeRope: Python Completion and GotoDefinition plugin using Rope


2. 代码检查 Python PEP-8 and PyFlakes checker


 
I) SublimeLinter

II) sublimetext_python_checker

This project is a plugin for SublimeText 2 text editor. It checks all python files you opening and editing through two popular Python checkers - pep8 and PyFlakes.

https://github.com/vorushin/sublimetext_python_checker

代码中使用个某个函数却忘记import 相应模块怎么办?python 中的模块 mr.igor 可以自动添加 import 语句。这个 Sublime Text 2 插件可以让它在 Sublime Text 2 工作。

Package Control Add URL https://github.com/optilude/SublimeTextIgorPlugi


Ruby

https://github.com/maltize/sublime-text-2-ruby-tests

https://github.com/SublimeText/RSpec

Sublime Guard

C/C++

CTags/Cscope 经典

clang (C/C++/Objective-C/Objective-C++) autocomplete http://github.com/quarnster/SublimeClang


Web Dev

Zen Coding

    Zen Coding is an editor plugin for high-speed HTML coding and editing. The core of this plugin is a powerful abbreviation engine which allows you to expand expressions—similar to CSS selectors—into HTML code.


    This is a great plugin when you’re working with a lot of markup. Tag is a collection of packages about, predictably, tags, mixed together in an effort to provide a single package with utilities to work with tags. Close a tag on a slash and tag indenting? Sign me up!


    This plugin collection includes plugins to fold your code according to brackts, cycle through selecting tags and many more.


    And where will all us be without jQuery? This is a Sublime Text bundle to help with jQuery functions.


    JsFormat is a javascipt formatting plugin for Sublime Text 2. It uses the commandline/python-module javascript formatter from JS Beautifier to format the selected text, or the entire file if there is no selection.


    It’s a good practice to always minify your files during deploying to a production server. And this plugin will swiftly automate the process by minifying your JavaScript using the Google Closure Compiler or UglifyJS compilers.
 
JsLint可由 SublimeLinter 插件实现


    DocBlockr is a Sublime Text 2 package which makes writing JSDoc comments and PHPDoc comments a breeze.


    A plugin that runs CSS through the Prefixr API, written by our very own Jeffrey Way, for Sublime Text 2.


    Tired of constantly having to manually convert your colors’ hexcodes to HSL? This plugin will automatically do it for you with the press of a button. Well, ok, three buttons. [Shift+Ctrl+U]

4. General Program
版本管理 sublime_tortoise / Git


    I’m quite a stickler for properly formatted code. One thing to get right is lining up all those darn variable assignment so they look all organized and neat. With this plugin, all it takes is the press of key. A simple key-binding allows you align multi-line and multiple selections.

SublimeREPL

    Run your favorite interpreter [python, ruby, lua, prolog :)] or Telnet session to an external tool (MozRepl) inside a Sublime buffer.


    DetectSyntax is a plugin for Sublime Text 2 that allows you to detect the syntax of files that might not otherwise be detected properly. This is specially helpful when you run into custom file formats — files used in templating is an excellent example.


    Case conversion is a plugin for Sublime Text 2. It converts the current word/token between pascal, camel, and snake case.

5. Others

EncodingHelper 编码转换

sublime-gbk

RegReplace Plugin

SublimeFileTemplates

SFTP 远程开发

HexViewer

SideBarEnhancements

Tips

1. vim模式

Preferences/Global Settings – Default

"ignored_packages": ["Vintage"] --> "ignored_packages": []

or try this plugin: https://github.com/SublimeText/VintageEx

2. 设置字体

Preferences > File Settings – User

{
"font_face": "Meslo LG S DZ",
"font_size": 10,
}

3. Fuzzy Finder (Go to Anything)

CTRL+P (fuzzy finder)

4. Multi Selection: awesome

按住Ctrl,选择吧

You Can Still Use TextMate Bundles

TextMate snippets and themes port over nicely to Sublime Text. You only need to drop them in the Packages folder — .tmbundle extension intact, and Sublime will recognize the files. This means that the entire catalog of TextMate themes will work in Sublime!

参考:

星期一, 十一月 07, 2011

Vim代码补全与浏览(vim code completion/navigation)

vim本身的补全功能对于c++来说还有明显不足,在大项目中使用ctags建立索引的效率一直是为大家诟病的地方,而且ctags autocompletion does NOT work for boost shared pointers。有人开发了利用编译器(clanggccsense)生成的AST (Abstract Syntax Tree)来进行代码分析,目前已经有人开发出了emacs、vim、gedit 的 code assistance 插件。

vim插件 clang_complete,可以用来进行代码补全,但是没有代码跳转功能。(update:原版的clang_complete正在开发函数跳转功能,但是要求clang version >= 3.0)

于是又有人开发了 CLIC – the Clang Indexer for C/C++,这里是作者在博客中的介绍

1. 建立索引

$ git clone git://github.com/exclipy/clang_indexer.git
$ cd clang_indexer
$ mkdir build
$ cd build
$ cmake ..
$ make
 
得到三个二进制文件: clic_add, clic_rm and clic_clear,把它们放到PATH中。并不直接使用这三个命令,而是用项目根目录中的clic_update.sh,这个脚本唯一的参数是你的工程源码目录,示例如下

$ mkdir ~/src/project-index 
$ cd ~/src/project-index 
 $ clic_update.sh ~/src/project

会生成一个index.db索引文件。

2. 在vim中进行代码补全和跳转

需要对原来 Rip-Rip  clang_complete plugin 进行修改,这是作者的改版 a fork of clang_complete.

$ git clone https://github.com/exclipy/clang_complete.git 

.vim推荐设置

let g:clang_auto_select=1
let g:clang_complete_auto=0
let g:clang_complete_copen=1
let g:clang_hl_errors=1
let g:clang_periodic_quickfix=0
let g:clang_snippets=1
let g:clang_snippets_engine="clang_complete"
let g:clang_conceal_snippets=1
let g:clang_exec="clang"
let g:clang_user_options=""
let g:clang_auto_user_options="path, .clang_complete"
let g:clang_use_library=1
let g:clang_library_path="/directory/of/libclang.so/"
let g:clang_sort_algo="priority"
let g:clang_complete_macros=1
let g:clang_complete_patterns=0
nnoremap >Leader>q :call g:ClangUpdateQuickFix()

let g:clic_filename="/path/to/index.db"
nnoremap >Leader>r :call ClangGetReferences()
nnoremap >Leader>d :call ClangGetDeclarations()
nnoremap >Leader>s :call ClangGetSubclasses()
 
在源码目录新建 .clang_complete 文件,写入 clang/libclang 参数,示例:

-I/opt/local/include
-I/opt/local/include/db52
-std=c++0x

附1:用tab补全类属性时与snipMate冲突

myclass. turns to: myclass[]

snipMate/snippets/c.snippets 最后两行

snippet .
    [${1}]${2} 
 
注释掉

# snippet .
#     [${1}]${2} 

附2:预编译

clang/libclang都是实时编译的,所以效率可能会有问题,尤其是当代码非常多的时候。创建一个头文件,然后include你的那些文件,然后调用clang预编译一下。

pchheader.h内容

#include 
#include 
#include 
......

预编译
clang -x c++-header ./pchheader.h -fno-exceptions -fnu-runtime -o ./pchheader.pch

添加到.clang_complete
echo '-include-pch pchheader.pch -fgnu-runtime' >> .clang_complete 

附3:ubuntu 中 libclang.so 问题

参见此 bug