-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsoftware.html
974 lines (942 loc) · 48.6 KB
/
software.html
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Linux Doc (UBUNTU distribution) — myhome 1.0.0 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0.0',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="top" title="myhome 1.0.0 documentation" href="index.html" />
<link rel="next" title="Linux 常用命令" href="linux_commands.html" />
<link rel="prev" title="reStructuredText Manual" href="reST.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="linux_commands.html" title="Linux 常用命令"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="reST.html" title="reStructuredText Manual"
accesskey="P">previous</a> |</li>
<li><a href="index.html">myhome 1.0.0 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="linux-doc-ubuntu-distribution">
<h1>Linux Doc (UBUNTU distribution)<a class="headerlink" href="#linux-doc-ubuntu-distribution" title="Permalink to this headline">¶</a></h1>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="linux_commands.html">Linux 常用命令</a></li>
</ul>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">author:</th><td class="field-body"><a class="reference external" href="mailto:conderls%40sina.com">conderls</a></td>
</tr>
</tbody>
</table>
<div class="section" id="id1">
<h2>常用软件<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">System setting:</th><td class="field-body"><table class="hlist"><tr><td><ul class="simple">
<li>byobu</li>
<li>filezilla</li>
</ul>
</td><td><ul class="simple">
<li>stardict</li>
</ul>
</td><td><ul class="simple">
<li>apt-file</li>
</ul>
</td><td><ul class="simple">
<li>convmv</li>
</ul>
</td></tr></table>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Multimedia:</th><td class="field-body"><table class="hlist"><tr><td><ul class="simple">
<li>smplayer</li>
<li>gimp</li>
<li>sweep</li>
</ul>
</td><td><ul class="simple">
<li>audacity</li>
<li>librecad</li>
</ul>
</td><td><ul class="simple">
<li>mypaint</li>
<li>inkscape</li>
</ul>
</td><td><ul class="simple">
<li>blender 3D</li>
<li>imagemagic</li>
</ul>
</td></tr></table>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Doc:</th><td class="field-body"><table class="hlist"><tr><td><ul class="simple">
<li>vim</li>
</ul>
</td><td><ul class="simple">
<li>texlive</li>
</ul>
</td><td><ul class="simple">
<li>chmsee</li>
</ul>
</td><td><ul class="simple">
<li>xchem</li>
</ul>
</td></tr></table>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Programming:</th><td class="field-body"><table class="hlist"><tr><td><ul class="simple">
<li>codeblocks</li>
</ul>
</td><td><ul class="simple">
<li>mpich2</li>
</ul>
</td><td><ul class="simple">
</ul>
</td><td><ul class="simple">
</ul>
</td></tr></table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">compiler:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
<table class="hlist"><tr><td><ul class="simple">
<li>g++</li>
</ul>
</td><td><ul class="simple">
<li>gcc</li>
</ul>
</td><td><ul class="simple">
<li>gfortran</li>
</ul>
</td></tr></table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Mathtools:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
<table class="hlist"><tr><td><ul class="simple">
<li>Octave</li>
</ul>
</td><td><ul class="simple">
<li>Maxima</li>
</ul>
</td><td><ul class="simple">
<li>matlab-support</li>
</ul>
</td></tr></table>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">python:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
<table class="hlist"><tr><td><ul class="simple">
<li>spyder</li>
<li>anaconda</li>
<li>ranger</li>
</ul>
</td><td><ul class="simple">
<li>sphinx</li>
<li>python-wxgtk2.8</li>
</ul>
</td><td><ul class="simple">
<li>python-wxtools</li>
<li>wx2.8-i18n</li>
</ul>
</td></tr></table>
</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="id2">
<h2>编译 & 安装<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
<div class="section" id="apt-file">
<h3>apt-file<a class="headerlink" href="#apt-file" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><p>安装apt-file并更新缓存:</p>
<div class="highlight-python"><div class="highlight"><pre>sudo apt-get install apt-file
sudo apt-file update
</pre></div>
</div>
<p>现在你可以使用apt-file搜索缺失的文件了,比如编译过程中提示缺少XTest.h, 找出所在包,并安装。</p>
<div class="highlight-python"><div class="highlight"><pre>apt-file search XTest.h
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="convmv">
<h3>convmv<a class="headerlink" href="#convmv" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><p>convmv能帮助我们很容易地对一个文件,一个目录下所有文件进行编码转换,比如gbk转为utf8等。
语法:</p>
<div class="highlight-python"><div class="highlight"><pre>convmv [options] FILE(S) ... DIRECTORY(S)
</pre></div>
</div>
<dl class="docutils">
<dt>主要选项:</dt>
<dd><div class="first last line-block">
<div class="line">-f ENCODING</div>
<div class="line-block">
<div class="line">指定目前文件名的编码,如-f gbk</div>
</div>
<div class="line">-t ENCODING</div>
<div class="line-block">
<div class="line">指定将要转换成的编码,如-f utf-8</div>
</div>
<div class="line">-r</div>
<div class="line-block">
<div class="line">递归转换目录下所有文件名</div>
</div>
<div class="line">–list</div>
<div class="line-block">
<div class="line">列出所有支持的编码</div>
</div>
<div class="line">–notest</div>
<div class="line-block">
<div class="line">默认是只打印转换后的效果,加这个选项才真正执行转换操作。</div>
</div>
</div>
</dd>
</dl>
<p>更多选项请man convmv。</p>
<dl class="docutils">
<dt>例子:</dt>
<dd><p class="first">递归转换centos目录下的目前文件名编码gbk为utf-8:</p>
<div class="last highlight-python"><div class="highlight"><pre>convmv -f gbk -t utf-8 --notest -r centos
</pre></div>
</div>
</dd>
</dl>
</div></blockquote>
</div>
<div class="section" id="flash-player">
<h3>flash player<a class="headerlink" href="#flash-player" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre>cp libflashplayer.so ~/.mozilla/plugins
cp libflashplayer.so /opt/google/chrome/plugins
<span class="c">#或者</span>
sudo apt-get install flashplugin-installer
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="grub">
<h3>grub<a class="headerlink" href="#grub" title="Permalink to this headline">¶</a></h3>
<ol class="arabic simple">
<li>更改grub启动界面背景图片</li>
</ol>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre>sudo gedit /etc/grub.d/05_debian_theme
</pre></div>
</div>
<p>找到:</p>
<div class="highlight-bash"><div class="highlight"><pre><span class="k">if </span>set_background_image <span class="s2">"/usr/share/images/desktop-base/desktop-grub.png"</span>; <span class="k">then</span>
<span class="k"> </span><span class="nb">exit </span>0
<span class="k">fi</span>
</pre></div>
</div>
<p>将图片地址修改,一般将想要替换的壁纸保存为/boot/grub/**.jpg(JPG, jpeg, JPEG, png, PNG, tga, TGA), 保存、退出,并更新:</p>
<div class="highlight-bash"><div class="highlight"><pre>sudo update-grub
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="2">
<li>修改启动项(grub2引导的系统)</li>
</ol>
<blockquote>
<div><dl class="docutils">
<dt>a、在Ubuntu终端下输入:</dt>
<dd><div class="first highlight-sh"><div class="highlight"><pre>sudo mv /etc/grub.d/30_os-prober /etc/grub.d/08_os-prober
sudo update-grub
</pre></div>
</div>
<p>该命令是将etc文件夹下的grub.d文件夹下的30_os-prober文件改名为08_os-prober(08可以改为06~09都可以)。</p>
<p>Ubuntu的启动项相关文件名为“10_”这样就可以将Windows的启动项放在Ubuntu前面,即启动项列表的第一个。</p>
<p>由于引导程序默认 启动第一个启动项,所以这样就可以先启动Windows了。改完后更新grub</p>
<div class="last highlight-python"><div class="highlight"><pre>sudo update-grub
</pre></div>
</div>
</dd>
<dt>b、在Ubuntu终端下输入:</dt>
<dd><div class="first highlight-python"><div class="highlight"><pre>sudo gedit /etc/default/grub
</pre></div>
</div>
<p>“GRUB_DEFAULT=0”</p>
<p>比如Win7在启动项列表中为第5项,则将0改为4。就是win7在启动项列表中的项数减1。</p>
<p>“GRUB_TIMEOUT=所要等待的秒数”</p>
<p class="last">修改完后更新grub,这种方法在更新内核后可能失效。</p>
</dd>
</dl>
</div></blockquote>
</div>
<div class="section" id="matlab">
<h3>matlab<a class="headerlink" href="#matlab" title="Permalink to this headline">¶</a></h3>
<ol class="arabic simple">
<li>安装matlab-support,这样就可以在unity中找到matlab图标。</li>
<li>不启动界面运行</li>
</ol>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre>matlab -nodisplay
matlab -nojvm -nosplash
<span class="c">#matlab程序也可以在命令行里直接运行,只需要使用 -r 选项。</span>
<span class="c">#可用以下三种命令运行当前目录下的example.m</span>
matlab -nodesktop -nosplash -r example
matlab -nojvm -nosplash -r example
matlab -nodisplay -r example
</pre></div>
</div>
<p>可以将如下命令加到~/.bashrc文件</p>
<div class="highlight-python"><div class="highlight"><pre>alias mrun='matlab -nodesktop -nosplash -r'
</pre></div>
</div>
<p>这样下次(或者执行source ~/.bashrc)之后就可以直接用下列命令来运行matlab文件。</p>
<div class="highlight-python"><div class="highlight"><pre>mrun example
</pre></div>
</div>
<p>使用如下命令运行(也可写成脚本/usr/bin/matlab, 并chmod +x matlab)</p>
<div class="highlight-python"><div class="highlight"><pre>/usr/local/MATLAB/R2010b/bin/matlab -desktop
</pre></div>
</div>
<p>则可终端运行:</p>
<div class="highlight-bash"><div class="highlight"><pre>matlab <span class="c">#这样启动的话,该终端无法再输入其他命令,可改用如下命令:</span>
nohup matlab &
</pre></div>
</div>
<p>如果使用 -nodisplay -r 选项运行,当程序中有figure()命令时会出错,可以使用如下选项抑制图形的显示:</p>
<div class="highlight-bash"><div class="highlight"><pre>figure<span class="o">(</span><span class="s1">'visible'</span>,<span class="s1">'off'</span><span class="o">)</span>;
<span class="c">#并使用如下命令将图形输出到文件:</span>
print<span class="o">(</span><span class="s1">'-deps'</span>,<span class="s1">'example.eps'</span><span class="o">)</span>;
<span class="c">#或者</span>
hgsave<span class="o">(</span><span class="s1">'example.fig'</span><span class="o">)</span>;
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="3">
<li>解决lib.so.6:not found</li>
</ol>
<blockquote>
<div><p>For 64 bit:</p>
<div class="highlight-python"><div class="highlight"><pre>sudo ln -s /lib/x86_64-linux-gnu/libc-2.13.so /lib64/libc.so.6
</pre></div>
</div>
<p>For 32 bit:</p>
<div class="highlight-python"><div class="highlight"><pre>sudo ln -s /lib/i386-linux-gnu/libc-2.13.so /lib/libc.so.6
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="mendeley">
<h3>Mendeley<a class="headerlink" href="#mendeley" title="Permalink to this headline">¶</a></h3>
<ol class="arabic simple">
<li>Uninstall the actual program. If you used the Ubuntu package you can do this with ‘Software Center’ or ‘apt-get remove mendeleydesktop’ from a terminal. If you used the ‘generic’ package this just involves deleting the folder where you unpacked the files.</li>
<li>If you don’t want your local Mendeley data any more, you can remove ~/.local/share/mendeleydesktop and the Mendeley Ltd. directory from ~/.local/share/data. There are also a few config files under ~/.config (all with ‘Mendeley’ in the name).</li>
</ol>
</div>
<div class="section" id="octave">
<h3>Octave<a class="headerlink" href="#octave" title="Permalink to this headline">¶</a></h3>
<ol class="arabic simple">
<li>修改默认编辑器</li>
</ol>
<blockquote>
<div><p>octave默认编辑器为Emacs,将其改为vim或gedit</p>
<div class="highlight-bash"><div class="highlight"><pre>touch ~/.octaverc
</pre></div>
</div>
<p>在该文件中加入下列命令:</p>
<div class="highlight-bash"><div class="highlight"><pre>EDITOR<span class="o">(</span><span class="s2">"vim %s"</span><span class="o">)</span> <span class="c">#使用gvim作为编辑器</span>
EDITOR<span class="o">(</span><span class="s2">"gnome-terminal -e \"vim %s\""</span><span class="o">)</span> <span class="c">#在gnome-terminal中打开vim作为编辑器</span>
<span class="c">#或</span>
EDITOR<span class="o">(</span><span class="s2">"gedit %s"</span><span class="o">)</span> <span class="c">#使用gedit作为编辑器</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="pack-unpack">
<h3>pack & unpack<a class="headerlink" href="#pack-unpack" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><div class="highlight-bash"><div class="highlight"><pre>sudo apt-get install p7zip p7zip-full p7zip-rar rar unrar
sudo ln -fs /usr/bin/rar /usr/bin/unrar
<span class="c">#这样,以后只要在命令行输入unrar,就可以解压或者压缩文件了</span>
<span class="c">#安装完成后,归档管理器也同时集成了rar组件。</span>
sudo apt-get install unra <span class="c">#一些压缩包解压后会中文乱码,用该命令</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="stardict">
<h3>stardict<a class="headerlink" href="#stardict" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><p>stardict离线词典安装:将下载的字典解压得到dic文件夹</p>
<div class="highlight-bash"><div class="highlight"><pre>chmod a+rx -R dic <span class="c">#修改权限,否则程序无法读取字典</span>
sudo mv dic /usr/share/stardict/
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="sublime-text-2">
<h3>sublime_text_2<a class="headerlink" href="#sublime-text-2" title="Permalink to this headline">¶</a></h3>
<p>中文输入:</p>
<blockquote>
<div><ol class="arabic simple">
<li>使用小小输入法:</li>
</ol>
<blockquote>
<div><p>小小输入法新版本已经支持再Sublime Text 下输入中文
关于小小输入法的安装以及简介:</p>
<p><a class="reference external" href="http://blog.ubuntusoft.com/small-input.html">http://blog.ubuntusoft.com/small-input.html</a>
<a class="reference external" href="http://forum.ubuntu.org.cn/viewtopic.php?t=226677">http://forum.ubuntu.org.cn/viewtopic.php?t=226677</a></p>
</div></blockquote>
<ol class="arabic simple" start="2">
<li>通过打补丁的方式,让Sublime Text 2 支持Fcitx 输入法</li>
</ol>
<blockquote>
<div><p>首先我们需要通过PPA 安装ST2(非官方下载的免安装包):</p>
<div class="highlight-sh"><div class="highlight"><pre>sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
</pre></div>
</div>
<p>然后打补丁:
将下面代码复制下来,并保存为 <tt class="xref download docutils literal"><span class="pre">sublime-imfix.c</span></tt> (存放于/home/username,即你的主目录):</p>
<div class="highlight-c"><div class="highlight"><pre><span class="cm">/*</span>
<span class="cm">sublime-imfix.c</span>
<span class="cm">Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.</span>
<span class="cm">By Cjacker Huang <jianzhong.huang at i-soft.com.cn></span>
<span class="cm">gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC</span>
<span class="cm">LD_PRELOAD=./libsublime-imfix.so sublime_text</span>
<span class="cm">*/</span>
<span class="cp">#include <gtk/gtk.h></span>
<span class="cp">#include <gdk/gdkx.h></span>
<span class="k">typedef</span> <span class="n">GdkSegment</span> <span class="n">GdkRegionBox</span><span class="p">;</span>
<span class="k">struct</span> <span class="n">_GdkRegion</span>
<span class="p">{</span>
<span class="kt">long</span> <span class="n">size</span><span class="p">;</span>
<span class="kt">long</span> <span class="n">numRects</span><span class="p">;</span>
<span class="n">GdkRegionBox</span> <span class="o">*</span><span class="n">rects</span><span class="p">;</span>
<span class="n">GdkRegionBox</span> <span class="n">extents</span><span class="p">;</span>
<span class="p">};</span>
<span class="n">GtkIMContext</span> <span class="o">*</span><span class="n">local_context</span><span class="p">;</span>
<span class="kt">void</span>
<span class="nf">gdk_region_get_clipbox</span> <span class="p">(</span><span class="k">const</span> <span class="n">GdkRegion</span> <span class="o">*</span><span class="n">region</span><span class="p">,</span>
<span class="n">GdkRectangle</span> <span class="o">*</span><span class="n">rectangle</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">g_return_if_fail</span> <span class="p">(</span><span class="n">region</span> <span class="o">!=</span> <span class="nb">NULL</span><span class="p">);</span>
<span class="n">g_return_if_fail</span> <span class="p">(</span><span class="n">rectangle</span> <span class="o">!=</span> <span class="nb">NULL</span><span class="p">);</span>
<span class="n">rectangle</span><span class="o">-></span><span class="n">x</span> <span class="o">=</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">x1</span><span class="p">;</span>
<span class="n">rectangle</span><span class="o">-></span><span class="n">y</span> <span class="o">=</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">y1</span><span class="p">;</span>
<span class="n">rectangle</span><span class="o">-></span><span class="n">width</span> <span class="o">=</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">x2</span> <span class="o">-</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">x1</span><span class="p">;</span>
<span class="n">rectangle</span><span class="o">-></span><span class="n">height</span> <span class="o">=</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">y2</span> <span class="o">-</span> <span class="n">region</span><span class="o">-></span><span class="n">extents</span><span class="p">.</span><span class="n">y1</span><span class="p">;</span>
<span class="n">GdkRectangle</span> <span class="n">rect</span><span class="p">;</span>
<span class="n">rect</span><span class="p">.</span><span class="n">x</span> <span class="o">=</span> <span class="n">rectangle</span><span class="o">-></span><span class="n">x</span><span class="p">;</span>
<span class="n">rect</span><span class="p">.</span><span class="n">y</span> <span class="o">=</span> <span class="n">rectangle</span><span class="o">-></span><span class="n">y</span><span class="p">;</span>
<span class="n">rect</span><span class="p">.</span><span class="n">width</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="n">rect</span><span class="p">.</span><span class="n">height</span> <span class="o">=</span> <span class="n">rectangle</span><span class="o">-></span><span class="n">height</span><span class="p">;</span>
<span class="c1">//The caret width is 2;</span>
<span class="c1">//Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.</span>
<span class="k">if</span><span class="p">(</span><span class="n">rectangle</span><span class="o">-></span><span class="n">width</span> <span class="o">==</span> <span class="mi">2</span> <span class="o">&&</span> <span class="n">GTK_IS_IM_CONTEXT</span><span class="p">(</span><span class="n">local_context</span><span class="p">))</span> <span class="p">{</span>
<span class="n">gtk_im_context_set_cursor_location</span><span class="p">(</span><span class="n">local_context</span><span class="p">,</span> <span class="n">rectangle</span><span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="c1">//this is needed, for example, if you input something in file dialog and return back the edit area</span>
<span class="c1">//context will lost, so here we set it again.</span>
<span class="k">static</span> <span class="n">GdkFilterReturn</span> <span class="nf">event_filter</span> <span class="p">(</span><span class="n">GdkXEvent</span> <span class="o">*</span><span class="n">xevent</span><span class="p">,</span> <span class="n">GdkEvent</span> <span class="o">*</span><span class="n">event</span><span class="p">,</span> <span class="n">gpointer</span> <span class="n">im_context</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">XEvent</span> <span class="o">*</span><span class="n">xev</span> <span class="o">=</span> <span class="p">(</span><span class="n">XEvent</span> <span class="o">*</span><span class="p">)</span><span class="n">xevent</span><span class="p">;</span>
<span class="k">if</span><span class="p">(</span><span class="n">xev</span><span class="o">-></span><span class="n">type</span> <span class="o">==</span> <span class="n">KeyRelease</span> <span class="o">&&</span> <span class="n">GTK_IS_IM_CONTEXT</span><span class="p">(</span><span class="n">im_context</span><span class="p">))</span> <span class="p">{</span>
<span class="n">GdkWindow</span> <span class="o">*</span> <span class="n">win</span> <span class="o">=</span> <span class="n">g_object_get_data</span><span class="p">(</span><span class="n">G_OBJECT</span><span class="p">(</span><span class="n">im_context</span><span class="p">),</span><span class="s">"window"</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="n">GDK_IS_WINDOW</span><span class="p">(</span><span class="n">win</span><span class="p">))</span>
<span class="n">gtk_im_context_set_client_window</span><span class="p">(</span><span class="n">im_context</span><span class="p">,</span> <span class="n">win</span><span class="p">);</span>
<span class="p">}</span>
<span class="k">return</span> <span class="n">GDK_FILTER_CONTINUE</span><span class="p">;</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">gtk_im_context_set_client_window</span> <span class="p">(</span><span class="n">GtkIMContext</span> <span class="o">*</span><span class="n">context</span><span class="p">,</span>
<span class="n">GdkWindow</span> <span class="o">*</span><span class="n">window</span><span class="p">)</span>
<span class="p">{</span>
<span class="n">GtkIMContextClass</span> <span class="o">*</span><span class="n">klass</span><span class="p">;</span>
<span class="n">g_return_if_fail</span> <span class="p">(</span><span class="n">GTK_IS_IM_CONTEXT</span> <span class="p">(</span><span class="n">context</span><span class="p">));</span>
<span class="n">klass</span> <span class="o">=</span> <span class="n">GTK_IM_CONTEXT_GET_CLASS</span> <span class="p">(</span><span class="n">context</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">klass</span><span class="o">-></span><span class="n">set_client_window</span><span class="p">)</span>
<span class="n">klass</span><span class="o">-></span><span class="n">set_client_window</span> <span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="n">window</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="n">GDK_IS_WINDOW</span> <span class="p">(</span><span class="n">window</span><span class="p">))</span>
<span class="k">return</span><span class="p">;</span>
<span class="n">g_object_set_data</span><span class="p">(</span><span class="n">G_OBJECT</span><span class="p">(</span><span class="n">context</span><span class="p">),</span><span class="s">"window"</span><span class="p">,</span><span class="n">window</span><span class="p">);</span>
<span class="kt">int</span> <span class="n">width</span> <span class="o">=</span> <span class="n">gdk_window_get_width</span><span class="p">(</span><span class="n">window</span><span class="p">);</span>
<span class="kt">int</span> <span class="n">height</span> <span class="o">=</span> <span class="n">gdk_window_get_height</span><span class="p">(</span><span class="n">window</span><span class="p">);</span>
<span class="k">if</span><span class="p">(</span><span class="n">width</span> <span class="o">!=</span> <span class="mi">0</span> <span class="o">&&</span> <span class="n">height</span> <span class="o">!=</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
<span class="n">gtk_im_context_focus_in</span><span class="p">(</span><span class="n">context</span><span class="p">);</span>
<span class="n">local_context</span> <span class="o">=</span> <span class="n">context</span><span class="p">;</span>
<span class="p">}</span>
<span class="n">gdk_window_add_filter</span> <span class="p">(</span><span class="n">window</span><span class="p">,</span> <span class="n">event_filter</span><span class="p">,</span> <span class="n">context</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
<p>安装编译时所需环境,并编译:</p>
<div class="highlight-sh"><div class="highlight"><pre>sudo apt-get install build-essential
sudo apt-get install libgtk2.0-dev
gcc -shared -o libsublime-imfix.so sublime_imfix.c <span class="sb">`</span>pkg-config --libs --cflags gtk+-2.0<span class="sb">`</span> -fPIC
</pre></div>
</div>
<p>编译后会得到libsublime-imfix.so ,我建议你直接把libsublime-imfix.so 留在你的主目录即可。
然后修改ST2的启动配置:</p>
<div class="highlight-sh"><div class="highlight"><pre>sudo gedit /usr/share/applications/sublime-text-2.desktop
</pre></div>
</div>
<p>找到</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">Exec</span><span class="o">=</span>/usr/bin/sublime-text-2 %F
<span class="c">#及</span>
<span class="nv">Exec</span><span class="o">=</span>/usr/bin/sublime-text-2 --new-window
</pre></div>
</div>
<p>分别修改为:</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="nv">Exec</span><span class="o">=</span>bash -c <span class="s1">'LD_PRELOAD=/home/username/libsublime-imfix.so /usr/bin/sublime-text-2'</span> %F
<span class="c">#及</span>
<span class="nv">Exec</span><span class="o">=</span>bash -c <span class="s1">'LD_PRELOAD=/home/username/libsublime-imfix.so /usr/bin/sublime-text-2'</span> --new-window
</pre></div>
</div>
</div></blockquote>
</div></blockquote>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">注意:</th><td class="field-body">其中/home/username/libsublime-imfix.so 修改为你编译生成的libsublime-imfix.so 的所在路径。</td>
</tr>
<tr class="field-even field"><th class="field-name">注意:</th><td class="field-body">新版本的ST2 的启动命令改为subl (上面教程中是旧版本的sublime-text-2),因此修改的时候,把sublime-text-2 改为 subl,然后保存,重启ST2 即可。</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="terminal">
<h3>Terminal<a class="headerlink" href="#terminal" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div><p>右键中添加open in terminal选项</p>
<div class="highlight-bash"><div class="highlight"><pre>sudo apt-get install nautilus-open-terminal
</pre></div>
</div>
</div></blockquote>
</div>
</div>
<div class="section" id="id3">
<h2>环境变量<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li>/etc/profile, /etc/bashrc, .bash_profile, .bashrc</li>
</ol>
<blockquote>
<div><p><em>/etc/profile</em></p>
<blockquote>
<div>其设定的变量可以作用于所有用户。此文件为系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行. 并从/etc/profile.d目录的配置文件中搜集shell的设置。</div></blockquote>
<p><em>/etc/bashrc</em></p>
<blockquote>
<div>为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.Ubuntu没有此文件,与之对应的是/ect/bash.bashrc它也是全局(公有)的 bash执行时,不管是何种方式,都会读取此文件。</div></blockquote>
<p><em>~/.bash_profile</em></p>
<blockquote>
<div>是交互式、login 方式进入 bash 运行的 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次! 默认情况下, 他设置一些环境变量,执行用户的.bashrc文件. Unbutu默认没有此文件,可新建。只有bash是以login形式执行时,才会读取此文件。通常该配置文件还会配置成去读取~/.bashrc。</div></blockquote>
<p><em>~/.bashrc</em></p>
<blockquote>
<div>是交互式 non-login 方式进入 bash 运行的。设定的变量(局部)只能继承/etc/profile中的变量,他们是”父子”关系. 该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell时,该文件被读取. 当bash是以non-login形式执行时,读取此文件。若是以login形式执行,则不会读取此文件</div></blockquote>
<p><em>~/.profile</em></p>
<blockquote>
<div>若bash是以login方式执行时,读取~/.bash_profile,若它不存在.bash_login,若前两者不存在,读取~/.profile。 另外,图形模式登录时,此文件将被读取,即使存在~/.bash_profile和~/.bash_login。</div></blockquote>
<p><em>~/.bash_login</em></p>
<blockquote>
<div>若bash是以login方式执行时,读取~/.bash_profile,若它不存在.bash_login,若前两者不存在,读取~/.profile。</div></blockquote>
<dl class="docutils">
<dt><em>~/.bash_logout</em></dt>
<dd>当每次退出系统(退出bash shell)时,执行该文件.注销时,且是longin形式,此文件才会读取。也就是说,在文本模式注销时,此文件会被读取,图形模式注不会被读取。</dd>
</dl>
<p>通常二者设置大致相同,所以通常前者会调用后者。</p>
<p>下面是几个例子:</p>
<ol class="arabic simple">
<li>图形模式登录时,顺序读取:/etc/profile和~/.profile</li>
<li>图形模式登录后,打开终端时,顺序读取:/etc/bash.bashrc和~/.bashrc</li>
<li>文本模式登录时,顺序读取:/etc/bash.bashrc,/etc/profile和~/.bash_profile</li>
<li>从其它用户su到该用户,则分两种情况:</li>
</ol>
<blockquote>
<div><ul class="simple">
<li>如果带-l参数(或-参数,–login参数),如:su -l username,则bash是lonin的,它将顺序读取以下配置文件:/etc/bash.bashrc,/etc/profile和~/. bash_profile。</li>
<li>如果没有带-l参数,则bash是non-login的,它将顺序读取:/etc/bash.bashrc和~/.bashrc</li>
</ul>
</div></blockquote>
<ol class="arabic simple" start="5">
<li>注销时,或退出su登录的用户,如果是longin方式,那么bash会读取:~/.bash_logout</li>
<li>执行自定义的shell文件时,若使用“bash -l a.sh”的方式,则bash会读取行:/etc/profile和~/.bash_profile,若使用其它方式,如:bash a.sh, ./a.sh,sh a.sh(这个不属于bash shell),则不会读取上面的任何文件。</li>
<li>上面的例子凡是读取到~/.bash_profile的,若该文件不存在,则读取~/.bash_login,若前两者不存在,读取~/.profile。</li>
</ol>
</div></blockquote>
<p>2、 修改变量:</p>
<blockquote>
<div><blockquote>
<div><ol class="loweralpha simple">
<li>在终端修改,但只对当前终端有效:</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>export PATH=$PATH:/etc/apache/bin
</pre></div>
</div>
</div></blockquote>
<ol class="loweralpha simple" start="2">
<li>在 <cite>/etc/profile</cite> 中添加(注意:等号两边不能由空格),这种方法最好,除非手动强制修改,否则不会被改变</li>
<li>在 <cite>~/.bashrc</cite> 中修改,只对当前用户管用。</li>
<li>在 <cite>~/.bashr_profile</cite> 中修改,也只对当前用户有效。比如在root权限下操作,则对root用户有效。</li>
</ol>
</div></blockquote>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">注意:</th><td class="field-body"><p class="first">要使修改的变量生效,必须重新登录,或编辑结束后对所编辑的文件使用source命令:</p>
<div class="last highlight-python"><div class="highlight"><pre>source filename
</pre></div>
</div>
</td>
</tr>
</tbody>
</table>
</div></blockquote>
</div>
<div class="section" id="id4">
<h2>双系统时间差<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h2>
<p>1、Windows与Linux(Ubuntu)双系统时间不一致 (相差8小时) 的解决方法:</p>
<blockquote>
<div><ul>
<li><p class="first">Ubuntu下修改:(推荐)</p>
<p>Ubuntu中不使用UTC时间,而启用本地时间,需要修改 /etc/default/rcS ,修改动作如下:
# 注释掉原来的设定:UTC=yes
# 变更为下面的内容...
UTC=no</p>
</li>
<li><p class="first">windows下修改:</p>
<p>下中添加一项数据类型为REG_DWORD,名称为RealTimeIsUniversal,值设为1 的键值。
在 注册表项:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\
或者直接使用下如下批处理进行修改:</p>
<div class="highlight-python"><div class="highlight"><pre>@echo off
color 0a
Reg add HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation /v RealTimeIsUniversal /t REG_DWORD /d 1
echo.
echo 已让Windows识别存贮在主板CMOS内的时间为格林威治标准时间(GMT),即系统根据CMOS时间和设置的时区来确定当前系统的时间。
echo.
pause
</pre></div>
</div>
</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="id5">
<h2>输入密码后出现闪屏又回到登录界面<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h2>
<dl class="docutils">
<dt><em>原因</em></dt>
<dd>手贱在自己账户下 命令行 <cite>sudo startX</cite></dd>
<dt><em>结果</em></dt>
<dd>只能访问 <cite>guest session</cite></dd>
<dt><em>解决</em></dt>
<dd>由于 <cite>sudo startX</cite> 操作后,将 <cite>~/.Xauthority</cite> 文件所有者改为了root,
因此只要tty命令行下登录用户,<cite>sudo chown acount:acount ~/.Xauthority</cite> 。
ctrl + alt + F7</dd>
</dl>
</div>
<div class="section" id="linuxu">
<h2>Linux制作U盘启动盘<a class="headerlink" href="#linuxu" title="Permalink to this headline">¶</a></h2>
<ul>
<li><p class="first">cat</p>
<p>使用方法: cat 镜像目录 > 设备(可以使用fdisk -l 查看)。</p>
<div class="highlight-sh"><div class="highlight"><pre>cat ubuntu-13.10-desktop-i386.iso >/dev/sdb1
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">注意:</th><td class="field-body">后面重定向的是设备而不是设备挂载后的目录,还有就是,使用 root 权限运行。</td>
</tr>
</tbody>
</table>
</li>
<li><p class="first">dd</p>
<p>使用方法: dd [选项] (最好自己看一下 dd 的 manpage)。</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">功能:</th><td class="field-body">把指定的输入文件拷贝到指定的输出文件中,并且在拷贝过程中可以进行格式转换。
可以用该命令实现DOS下的diskcopy命令的作用。先用dd命令把软盘上的数据写成硬盘的一个寄存文件,
再把这个寄存文件写入第二张软盘上,完成diskcopy的功能。
需要注意的是,应该将硬盘上的寄存文件用rm命令删除掉。系统默认使用标准输入文件和标准输出文件。</td>
</tr>
</tbody>
</table>
<p>那么,我们可以看到 dd 主要的功能就是拷贝文件,并且在拷贝时可以格式转换,所以 dd 也是平时使用比较多的进行制作 U 盘(或者 cdrom)的工具。我看道网上说甚至可以使用 dd 将 CD 上的文件拷贝到本地并放在一个镜像中(我们可以使用这个来实现将 CD/DVD上的系统拷贝到本地作为镜像文件)。</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="c">#使用 dd 制作 U 盘启动盘:</span>
dd <span class="k">if</span><span class="o">=</span>ubuntu-13.10-desktop-i386.iso <span class="nv">of</span><span class="o">=</span>/dev/sdb1 <span class="nv">bs</span><span class="o">=</span>4M
</pre></div>
</div>
<p>我们可以看到,使用 dd 只是和使用 cat 带入参数方法不一样,镜像目录使用 if= 来指定,U盘设备的地址使用 of= 来指定,最后的 bs=4M 上面也可以看到是指定一次写入字节数</p>
<div class="highlight-sh"><div class="highlight"><pre><span class="c">#使用 dd 制作 CD/DVD 系统盘:</span>
dd <span class="k">if</span><span class="o">=</span>ubuntu-13.10-desktop-i386.iso <span class="nv">of</span><span class="o">=</span>/dev/cdrom <span class="nv">bs</span><span class="o">=</span>4M
<span class="c">#使用 dd 制作镜像:</span>
dd <span class="k">if</span><span class="o">=</span>/dev/cdrom <span class="nv">of</span><span class="o">=</span>/home/username/cd.iso <span class="nv">bs</span><span class="o">=</span>4M
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">注:</th><td class="field-body"><ul class="first last simple">
<li>bs 带的参数是一次写入字节数,可以自己替换更高的数来得到更高的速度.但是真正使用时,速度的上限还是限于硬件的读写速度(比如说,USB2.0 的U盘,你带入参数 bs=16M,但是真正得到的读写速度仍然是3M~4M的样子)</li>
<li>使用 root 权限运行</li>
</ul>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
<div class="section" id="id6">
<h2>乱码<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li>Rhythmbox</li>
</ol>
<blockquote>
<div><p>编辑/etc/profile:
添加并保存:</p>
<div class="highlight-python"><div class="highlight"><pre>export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="2">
<li>gedit</li>
</ol>
<blockquote>
<div><p>gedit打开GB18030/GBK/GB2312 等类型的中文编码文本文件时,将会出现乱码。</p>
<p><em>原因</em></p>
<blockquote>
<div>gedit 使用一个编码匹配列表,只有在这个列表中的编码才会进行匹配,不在这个列表中的编码将显示为乱码。</div></blockquote>
<p><em>解决</em></p>
<blockquote>
<div><p>要做的就是将GB18030 加入这个匹配列表</p>
<div class="highlight-sh"><div class="highlight"><pre>gsettings <span class="nb">set </span>org.gnome.gedit.preferences.encodings auto-detected <span class="s2">"['UTF-8','GB18030','GB2312','GBK','BIG5','CURRENT','UTF-16']"</span>
</pre></div>
</div>
<p>若出现如下错误:</p>
<div class="highlight-python"><div class="highlight"><pre>`** (gedit:3525): WARNING **:` Could not load Gedit repository: Typelib file for namespace 'GtkSource', version '3.0' not found
</pre></div>
</div>
<p>则:</p>
<div class="highlight-sh"><div class="highlight"><pre>sudo apt-get install gir1.2-gtksource-3.0
</pre></div>
</div>
</div></blockquote>
</div></blockquote>
<ol class="arabic simple" start="3">
<li>vim</li>
</ol>
<blockquote>
<div><p>在 <cite>~/.vimrc</cite> 中添加:</p>
<div class="highlight-python"><div class="highlight"><pre>set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936
</pre></div>
</div>
<p>这样,就可以让vim自动识别文件编码(可以自动识别UTF-8或者GBK编码的文件),其实就是依照 fileencodings提供的编码列表尝试,如果没有找到合适的编码,就用latin-1(ASCII)编码打开。</p>
</div></blockquote>
</div>
<div class="section" id="id7">
<h2>查看文件编码及修改<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h2>
<ol class="arabic simple">
<li>查看文件编码:</li>
</ol>
<blockquote>
<div><ol class="loweralpha simple">
<li>vim中查看</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>:set fileencoding
</pre></div>
</div>
<p>即可显示。</p>
</div></blockquote>
<ol class="loweralpha simple" start="2">
<li>enca命令查看</li>
</ol>
<blockquote>
<div><div class="highlight-python"><div class="highlight"><pre>enca filename
enca -L zh_CN filename
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">注意:</th><td class="field-body">enca对某些GBK编码的文件识别的不是很好,识别时会出现: <strong>Unrecognized encoding</strong></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p>c. file命令</p>
<div class="highlight-python"><div class="highlight"><pre>file filename
</pre></div>
</div>
</div></blockquote>
<ol class="arabic simple" start="2">
<li>文件内容编码转换:</li>
</ol>
<blockquote>
<div><p>a. vim中直接转换</p>
<div class="highlight-python"><div class="highlight"><pre>:set fileencoding=utf-8
</pre></div>
</div>
<p>b. enconv转换</p>
<div class="highlight-python"><div class="highlight"><pre>#将GBK编码文件转换成UTF-8编码
enconv -L zh_CN -x UTF-8 filename
</pre></div>
</div>
<p>c. iconv转换</p>
<div class="highlight-python"><div class="highlight"><pre>iconv -f encoding -t encoding inputfile
#例如:将GBK编码文件转换为UTF-8编码
iconv -f GBK -t UTF-8 file1 -o file2
#或
iconv -f GBK -t UTF-8 file1 >> file2
</pre></div>
</div>
<p>d. enca命令</p>
<div class="highlight-python"><div class="highlight"><pre>enca -L 当前语言 -x 目标编码 文件名
#若不想覆盖原文件
enca -L zh_CN -x UTF-8 < file1 > file2
</pre></div>
</div>
</div></blockquote>
<p>3、文件名编码转换:</p>
<blockquote>
<div><p>a. convmv命令</p>
<div class="highlight-python"><div class="highlight"><pre>convmv -f GBK -t UTF-8 *.mp3
#该命令不会真正转换,要输出则须加参数--notest
convmv -f GBK -t UTF-8 --notest *.mp3
#-r参数表递归转换当前目录下的所有子目录
</pre></div>
</div>
</div></blockquote>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Linux Doc (UBUNTU distribution)</a><ul>
<li><a class="reference internal" href="#id1">常用软件</a></li>
<li><a class="reference internal" href="#id2">编译 & 安装</a><ul>
<li><a class="reference internal" href="#apt-file">apt-file</a></li>
<li><a class="reference internal" href="#convmv">convmv</a></li>
<li><a class="reference internal" href="#flash-player">flash player</a></li>
<li><a class="reference internal" href="#grub">grub</a></li>
<li><a class="reference internal" href="#matlab">matlab</a></li>
<li><a class="reference internal" href="#mendeley">Mendeley</a></li>
<li><a class="reference internal" href="#octave">Octave</a></li>
<li><a class="reference internal" href="#pack-unpack">pack & unpack</a></li>
<li><a class="reference internal" href="#stardict">stardict</a></li>
<li><a class="reference internal" href="#sublime-text-2">sublime_text_2</a></li>
<li><a class="reference internal" href="#terminal">Terminal</a></li>
</ul>
</li>
<li><a class="reference internal" href="#id3">环境变量</a></li>
<li><a class="reference internal" href="#id4">双系统时间差</a></li>
<li><a class="reference internal" href="#id5">输入密码后出现闪屏又回到登录界面</a></li>
<li><a class="reference internal" href="#linuxu">Linux制作U盘启动盘</a></li>
<li><a class="reference internal" href="#id6">乱码</a></li>
<li><a class="reference internal" href="#id7">查看文件编码及修改</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="reST.html"
title="previous chapter">reStructuredText Manual</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="linux_commands.html"
title="next chapter">Linux 常用命令</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/software.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="linux_commands.html" title="Linux 常用命令"
>next</a> |</li>
<li class="right" >
<a href="reST.html" title="reStructuredText Manual"
>previous</a> |</li>
<li><a href="index.html">myhome 1.0.0 documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, conderls.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.2.
</div>
</body>
</html>