Thursday, September 15, 2011

[转载]shell的显示git分支ps1


别搞错了, 是Shell的提示符:PS1,不是Play Station One。(-。-)
这个PS1的目前有两个功能:高亮所有不为0的返回值,显示Git分支。
效果如图:


Power PS1
你可以看到,当我在Shell中打“hello”时,在显示了“command not found”以外,还把Shell的PS1提示符弄红了,在前面还有返回值:127。方便了在发生错误的情况下得到注意。
此外,作为一个Git用户,当进入一个Git仓库时,会用灰底黄字显示当前的分支信息,一目了然。
实在是方便!PS1也能加入超多的功能!
当然这些都不是原创的,只是稍微改了下,是向bones7456和albert学的。
下面就是这个PS1,很晕吧:PS1='`a=$?;if [ $a -ne 0 ]; then echo -n -e "\[\e[01;32;41m\]{$a}"; fi`\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\W`b=$(parse_git_branch); if [ x"$b" != "x" ]; then echo -n -e "\[\e[33;40m\](branch:$b)\[\033[01;32m\]\[\e[00m\]"; fi`\[\033[01;34m\] $ \[\e[00m\]'
如果你也想用的话,从我的Git仓库中,取出样本,放进你的~/.bashrc里吧。记得不要少了parse_git_branch这个函数。
http://github.com/tualatrix/configs/tree/master

转载源地址: http://imtx.me/archives/1298.html

gnome shell hijack to show ibus(顶栏显示ibus状态)

~/gnomeshellibus.html
 1 现在使用gnomeshell因为ibus状态栏在底部通知栏,使用vim,gvim还有firefox的pentadactly扩展
 2 的时候老看不到输入法状态,导致很多快捷键无法运行,很是恼火。
 3 
 4 
 5 近日看了看gnome-shell的通知区域的设计,发现gnomeshell本意是把ibus放在顶面板的,由于和ibus
 6 输入法的沟通没有做好,导致通知区域的的ibus名称不正确,所以,我们的ibus也就毫无办法的到了
 7 底部通知栏...
 8 
 9 察看原码
10 
11 statusIconDispatcher.js文件在/usr/share/gnome-shell/js/ui目录下
12 
13 
14 
15 const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
16     'bluetooth-applet': 'bluetooth',
17     'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet
18                                              // when moved to control center
19     'gnome-sound-applet': 'volume',
20     'nm-applet': 'network',
21     'gnome-power-manager': 'battery',
22     'keyboard': 'keyboard',
23     'a11y-keyboard': 'a11y',
24     'kbd-scrolllock': 'keyboard',
25     'kbd-numlock': 'keyboard',
26     'kbd-capslock': 'keyboard',
27     'ibus-ui-gtk': 'input-method'//看到没有ibus-ui-gtk多少年前的东西了..
28 };
29 
30 一个简单的小hack只要把'ibus-ui-gtk'改为'main.py'就可以了
31 
32 const STANDARD_TRAY_ICON_IMPLEMENTATIONS = {
33     'bluetooth-applet': 'bluetooth',
34     'gnome-volume-control-applet': 'volume', // renamed to gnome-sound-applet
35                                              // when moved to control center
36     'gnome-sound-applet': 'volume',
37     'nm-applet': 'network',
38     'gnome-power-manager': 'battery',
39     'keyboard': 'keyboard',
40     'a11y-keyboard': 'a11y',
41     'kbd-scrolllock': 'keyboard',
42     'kbd-numlock': 'keyboard',
43     'kbd-capslock': 'keyboard',
44     'main.py': 'input-method'//就是这里,改了就ok了..
45 };
46 
47 写成脚本就是下面的了:
48 ibus extensions
49 
50 1   StatusIconDispatcher = imports.ui.statusIconDispatcher;
51 2
52 3   function main() {
53 4       StatusIconDispatcher.STANDARD_TRAY_ICON_IMPLEMENTATIONS['main.py'] = 'ibus';
54 5   }

gnomeshell 标题框显示 最小化 关闭按钮

~/gnomeshelltweak.html
1 gnomeshell使标题框显示放大缩小关闭的小技巧
2 
3 gconftool-2 -s -t string /desktop/gnome/shell/windows/button_layout "minimize:close"

Wednesday, September 14, 2011

gnome shell恢复默认设置

~/gnomeshell.html  1 当你使用gnome-shell的时候,修改了配置,导致无法启动了,怎么办?
 2 
 3 今天我就遇到了,上irc,没有结果,只有自己动手了.
 4 
 5 在 http://forums.fedoraforum.org/showthread.php?t=267061
 6 上找到了解决的办法
 7 
 8 -使用 ctrl+alt+F2 返回一个虚拟终端
 9 -登陆进去,然后执行一下的命令
10 
11 rm -rf ~/.config/
12 rm -rf ~/.gconf/
13 rm -rf ~/.gconfd/
14 -然后回到gdm的登陆界面(ctrl+alt+F7),登陆进去
15 
16 这个将完全删除所有基于GNOME3/gtk3的程序的默认配置