workstation environments

20
Workstation Environments Workstation Environments changlp

Upload: ceri

Post on 02-Feb-2016

48 views

Category:

Documents


3 download

DESCRIPTION

Workstation Environments. changlp. Workstation Environments. Encoding 亂碼 Shell Efficiency Configuration Management. Encoding & Locale. Bug5 Big5 BBS, News ? 年遺毒 UTF-8 現代人專用編碼. Encoding – Migrate to UTF-8 (1/2). % export LC_ALL=zh_TW.UTF-8 % vim. Encoding – Migrate to UTF-8 (2/2). - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Workstation Environments

Workstation EnvironmentsWorkstation Environments

changlp

Page 2: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

2

Workstation EnvironmentsWorkstation Environments

Encoding• 亂碼

Shell• Efficiency

Configuration• Management

Page 3: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

3

Encoding & LocaleEncoding & Locale

LC_ALL

LC_CTYPE

LC_MESSAGES

LC_TIME

LC_NUMERIC

LC_MONETARY

LC_COLLATE

LANG

Page 4: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

4

Encoding – Migrate to UTF-8 (1/2)Encoding – Migrate to UTF-8 (1/2)

% export LC_ALL=zh_TW.UTF-8% vim

Page 5: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

5

Encoding – Migrate to UTF-8 (2/2)Encoding – Migrate to UTF-8 (2/2)

Page 6: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

6

Encoding – Big5Encoding – Big5

BBS, News…

Page 7: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

7

Terminal MultiplexersTerminal Multiplexers

GNU Screen• sysutils/screen

• sysutils/byobu

Tmux• sysutils/tmux

Page 8: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

8

Terminal MultiplexersTerminal Multiplexers– Encoding Conversion– Encoding Conversion

Screen• encoding <code>

• bind b encoding big5

Tmux• No built-in conversion

chinese/bug5• A Big5/GBK <-> UTF-8 translating layer in terminal

• Better output for BBS ASCII arts

Page 9: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

9

VIM – EncodingVIM – Encoding

fileencoding (fenc)• Encoding of a file

• fencs

encoding (enc)• Encoding of vim internal

• Default: $env[LANG]

terminalencoding (tenc)• Encoding of terminal

• Default: enc

Page 10: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

10

VIM – EncodingVIM – Encoding

Vim internal

Encoding

Terminal Encoding

File Encoding

Page 11: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

11

VIM – Encoding ConversionVIM – Encoding Conversion

Read a BIG5 file Vim may guess the wrong encoding

• :e ++enc=big5

• nnoremap <F5> <ESC>:e ++enc=big5<CR> (bind a key)

Convert to UTF-8• Set fenc to UTF-8 and write

fenc

Page 12: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

12

Configuration Management – Why?Configuration Management – Why?

We now have about 15 public workstations• FreeBSD, Linux, SunOS

Commands, environment differ on each OS• OS-based settings

Maintain only 1 instance of config across all machines• Host-base settings

Other generic settings

So…

Page 13: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

13

Configuration Management – Result?Configuration Management – Result?

你的設定檔長這樣嗎 ?

Page 14: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

14

真 ˙ 真 ˙ Configuration ManagementConfiguration Management

Good for maintenance• Categorize your configurations

• Alias, completion… etc

Readability Write once, use anywhere

• Exceptions should be handled

Page 15: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

15

真 ˙ 真 ˙ Configuration Management (Cont.)Configuration Management (Cont.)

OS-based settings

Host-based settings

if( -f $HOME/.csh/os/`uname -s`.cshrc ) then source $HOME/.csh/os/`uname -s`.cshrcendif

if( -f $HOME/.csh/hosts/$HOST.cshrc ) then source $HOME/.csh/hosts/$HOST.cshrcendif

Page 16: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

16

真 ˙ 真 ˙ Configuration Management (Cont.)Configuration Management (Cont.)

Misc

foreach src ($HOME/.csh/misc/*) if ( -f $src ) then source $src endifend

Page 17: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

17

VIM - PluginVIM - Plugin

$HOME/.vim• after

• autoload

• plugin

• …

Install a plugin• http://www.vim.org/scripts

• Unzip to $HOME/.vim

Uninstall?• 硬碟很大沒在怕 (X)

• Plugin 多才潮 (X)

• 我哪知道裝了啥 (O)

Page 18: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

18

VIM – Plugin Management (1/2)VIM – Plugin Management (1/2)

Pathogen• http://github.com/tpope/vim-pathogen

• Runtime path manipulation

To install• Put pathogen.vim under $HOME/.vim/autoload

• Put this in your start of .vimrc

call pathogen#infect()syntax onfiletype plugin indent on

Page 19: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

19

VIM – Plugin Management (2/2)VIM – Plugin Management (2/2)

Each plugin get a subdir Good for

• Installing

• Uninstalling

• Updating

• Plugin listing

A little painful while migrating

Page 20: Workstation Environments

Com

pu

ter C

en

ter, C

S, N

CTU

20

VIM – Other Management ToolsVIM – Other Management Tools

Vim-addon-manager• https://github.com/MarcWeber/vim-addon-manager

Vimball• http://www.vim.org/scripts/script.php?script_id=1502