-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path_pentadactylrc
221 lines (173 loc) · 8.5 KB
/
_pentadactylrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
js <<EOF
const TC_PATH = "D:\\App\\Totalcmd\\Totalcmd.exe";
const ProfD = services.directory.get("ProfD", Ci.nsIFile);
// dactyl.execute("set runtimepath=" + ProfD.path);
function openProfileDirectory() {
if(File(TC_PATH).exists()){
io.run(TC_PATH, [ProfD.path, "/T"]);
}else{
ProfD.reveal();
}
}
EOF
loadplugins '\.(js|penta)$'
" 上下翻页
map a <S-Space>
set editor='"d:\\Program Files\\Sublime text 2\\sublime_text.exe" <file>'
com! openProfile -d "Open Profile directory" -js openProfileDirectory();
" editor.editFileExternally(PATH);
com! erc -d "Edit the _pentadactylrc file" -js io.run("gvim", [PATH])
com! src -d "Source the _pentadactylrc file" :so $HOME/_pentadactylrc
" 复制、剪贴、粘贴
map -m n,v,i,c,t <C-a> <Pass>
map -m n,v,i,c,t <C-c> <Pass>
map -m i,c,t <C-v> <Pass>
map -m i,c,t <C-x> <Pass>
map -m i,c,t <C-z> <Pass>
" Other
map -builtin j 2j
map -builtin k 2k
" Pass key
map -m=n <Left> <Pass>
map -m=n <Right> <Pass>
map -m=n <C-d> <Pass>
map -m=n <C-b> <pass>
" <Leader>
" map <Leader>a :dialog addons<Return>
map <Leader>e :extedit -types<Space>
map <Leader>r -js autoReader.launch();
map <Leader>ie -js io.run("c:\\program files\\internet explorer\\iexplore.exe", [buffer.URL])
" U list closed tabs
nmap -builtin U :undo<Space>
" viewsource in new tab
nmap -builtin gf :tab viewsource<CR>
" 收集所有标签地址到剪贴版
map -description='Yank all locations to the clipboard' -modes=n,v <C-y> -ex yank :tabdo :echo buffer.uri.spec
" set newtab=all
" surround com and net
map -modes=c <C-Return> -builtin <End>.com<Home><C-Right>www.<Return>
map -modes=c <S-Return> -builtin <End>.org<Home><C-Right>www.<Return>
" 选中文字用t o打开google搜索,google的关键字设置为g
map t -js str=DOM.stringify(buffer.focusedFrame.getSelection()); str!=""?dactyl.open(str, {where: dactyl.NEW_TAB}):CommandExMode().open("tabopen ")
map o -js str=DOM.stringify(buffer.focusedFrame.getSelection()); str!=""?dactyl.open(str, {where: dactyl.CURRENT_TAB}):CommandExMode().open("open ")
" 特殊站点 passkeys
set passkeys=
set passkeys+='mail.google.com':jk<CR>
set passkeys+='digg.com/reader':jknpo<CR><Space><S-Space>12<S-j><S-k><S-o><S-x>sv?
"set passkeys+='www.google.com/reader/':jkvoA<CR><Space><S-Space>np<S-n><S-p><S-x><S-o>uf12/a?
set passkeys+='xianguo.com/reader':?jknpos<S-s>tvm<S-n><S-p>+-<S-m><S-a>ru12<S-/>f
" map -count -modes=n,v <C-e> <C-z>
" map -count -modes=n,v <C-r> <C-v>
" map -modes=n,v <C-s>w -js wiz_km_onWizSave();
" buffers
" map -count -modes=n,v <Leader>bc -builtin <count>:buffer<Space>Google<Space>日历<Return>
" map -count -modes=n,v <Leader>bd -builtin <count>:buffer<Space>Doit.im<Return>
" map -count -modes=n,v <Leader>bm -builtin <count>:buffer<Space>Gmail<Return>
" map -count -modes=n,v <Leader>br -builtin <count>:buffer<Space>Google<Space>阅读器<Return>
" map -count -modes=n,v <Leader>bt -builtin <count>:buffer<Space>Toodledo<Return>
" map -count -modes=n,v A <Nop>
" map <F2> -description 显示隐藏工具栏 -e set go!=T
" left or right tab,跳到第<n>个tab请使用<n>b
"map -count -modes=n w <C-p>
"map -count -modes=n e <C-n>
" 按了S后就能自己输入搜索引擎关键字(当然也可以在自动补全菜单里选择),如果不选直接回车就是用默认引擎(对于选中的恰好是链接的情况则是直接打开链接)
command! -nargs=? -complete=search engineSelect exe 't <args> ' + content.getSelection()
map S :engineSelect<Space>
command! -nargs=* sitesearch -description 用google站内搜索API搜索当前站点 exe "t https://www.google.com.hk/search?q=" + encodeURIComponent("<args>") + "&sitesearch=" + window.content.location.hostname
" 对应baidu的
" com! -nargs=* sitesearch exe "t http://www.baidu.com/s?ie=utf-8&word=" + encodeURIComponent("<args> site:" + window.content.location.hostname);
" 查单词, 结合dict插件翻译选中字符串
" map -modes=n,v -silent W -js do_selection("dict")
" map s -description dcit插件-dict.cn -js do_selection(":dict -e d ")
" map sg -description dcit插件-google翻译 -js do_selection(":dict -e g ")
" map sy -description dcit插件-有道 -js do_selection(":dict -e y ")
" map sq -description dcit插件-qq -js do_selection(":dict -e q ")
" map sz -description dcit插件-汉典 -js do_selection(":dict -e z ")
" command! dict -nargs=* tabopen http://dict.cn/<args>
" map <silent> W :exe ":dict "+content.getSelection()<CR>
"}}}
" Options {{{
"其它参数 -multiInst -nosession
set guioptions=bCrsBn
set hintkeys=hjklasdfgyuiopqwertnmzxcvb
set maxitems=15
" 高亮搜索
set hlfind
command! hl -description toggle高亮 set hlf!
set nextpattern='^\s*[下后][一]?[页张个篇章节步]\s*$','^(next|Next)$','^(>>|»)$','^(>|»)','(>|»)$'
set previouspattern='\s*[上前][一]?[页张个篇章节步]\s*$','^(prev|previous)$','^<$,^(<<|«)$,^(<|«),(<|«)$'
" set urlseparator='\s((?!http://)[\s\S])*(?=(https?|ftp)://)|(((?!http://)\S)*[^u\s]rce:|((?!http://)\S)*[^r\s]ce:|((?!http://)\S)*[^c\s]e:|((?!http://)\S)*[^e\s]:|((?!http://)\S)*[^:\s])(?=(https?|ftp)://)|\s{5,}((?!http://)\S)+((?!http://)[\s\S])*$|(\s((?!http://)\S)+((?!http://)[\s\S])*\n|\n((?!http://)[\s\S])*((?!http://)\S)+)((?!http://)[\s\S])*$'
" }}}
" Custom commands {{{
command! rebuc -description userChromeJS打开新窗口并重置脚本 -js userChromejs && userChromejs.rebuild();
" 关闭右侧标签
" command! tabcloser -description "close all right tabs" -js
"用x\c来关闭左右标签
" map -modes=n,v c -js gBrowser.removeTab(gBrowser.mCurrentTab.boxObject.nextSibling)
" map -modes=n,v x -js gBrowser.removeTab(gBrowser.mCurrentTab.boxObject.previousSibling)
"另一种写法
"map x -j var tab = gBrowser.mCurrentTab.boxObject.previousSibling; if(tab) gBrowser.removeTab(tab);
"map c -j var tab = gBrowser.mCurrentTab.boxObject.nextSibling; if(tab) gBrowser.removeTab(tab);
" 开启和关闭javascript或图片
command! jstoggle -js (function() { var p = "javascript.enabled"; prefs.set(p, !prefs.get(p)); dactyl.echo(p+" is now set to "+prefs.get(p)+"\n") })()
command! imgtoggle -js (function() { var p = "permissions.default.image"; prefs.set(p, prefs.get(p)==1 ? 2 : 1); dactyl.echo(p+" is now set to "+prefs.get(p)+"\n") })()
" }}}
"命令行模式禁用输入法
"style -name commandline-ime http://*,https://* input,textarea {ime-mode: active;}
style -name commandline-ime chrome://* #dactyl-commandline-command input , #dactyl-statusline-field-commandline-command input {ime-mode: inactive;}
"cmap <A-i> -js styles.user.get("cmd-ime").enabled ^= true; dactyl.focusedElement.blur();
"显示dict查询状态
style chrome://browser/content/browser.xul statuspanel#statusbar-display { display:block; visibility: visible }
"加大hint的字号
hi Hint font:bold 12px "Droid Sans Mono", monospace !important; margin:-.2ex; padding: 0 0 0 1px; outline:1px solid rgba(0, 0, 0, .5); background:rgba(255, 248, 231, .8); color:black; text-transform:uppercase;
"}
" 自定义js {{{
js <<EOF
// 如果选中执行 命令+选中的,否则执行原命令
var do_selection = function(command){
// 原先的content.getSelection()只会get到空字符串,所以需要用buffer.focusedFrame.getSelection()
var str=content.getSelection();
// 保证command最后一个是空格
if(command.slice(-1) != " ")
command += " ";
if(str != ""){
dactyl.execute(command + str);
/* dactyl.open(str, {where: dactyl.CURRENT_TAB})
为了保持所选文字的完整信息,就需要使用Pentadactyl给的util.domToString()函数,
同时:tabopen命令由于不能处理接收到的"\r\n"换行符,所以直接交由dactyl.open处理
*/
}else{
CommandExMode().open(command);
}
};
// 优酷等视频网站下载
var flvcd_download = function(){
var url = buffer.URL.replace(/http:\/\//, '');
var flvcd_url = "http://www.flvcd.com/parse.php?kw=";
if(/youku\.com|tudou\.com|yinyuetai\.com\/video/.test(url)){
dactyl.open(flvcd_url + encodeURIComponent(url));
}
else{
dactyl.execute("em Bookmarks.Bookmark This Page");
}
}
// 多电脑自动设置 view_source.editor.path 和 extensions.scriptish.editor 路径
var userPath = [
"d:\\App\\Sublime text 3\\sublime_text.exe",
"D:\\Program Files\\Sublime Text 2\\sublime_text.exe",
];
(function checkEditorPath(){
let path = prefs.get('view_source.editor.path');
if(!File(path).exists()){
for(var i = 0 ; i < userPath.length; i ++ ) {
if(File(userPath[i]).exists()){
prefs.set('view_source.editor.path', userPath[i]);
prefs.set('extensions.scriptish.editor', userPath[i]);
break;
}
}
}
})();
EOF
" }}}
" vim:set ft=pentadactyl: