Workstation Environments
description
Transcript of Workstation Environments
Workstation EnvironmentsWorkstation Environments
changlp
Com
pu
ter C
en
ter, C
S, N
CTU
2
Workstation EnvironmentsWorkstation Environments
Encoding• 亂碼
Shell• Efficiency
Configuration• Management
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
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
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)
Com
pu
ter C
en
ter, C
S, N
CTU
6
Encoding – Big5Encoding – Big5
BBS, News…
Com
pu
ter C
en
ter, C
S, N
CTU
7
Terminal MultiplexersTerminal Multiplexers
GNU Screen• sysutils/screen
• sysutils/byobu
Tmux• sysutils/tmux
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
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
Com
pu
ter C
en
ter, C
S, N
CTU
10
VIM – EncodingVIM – Encoding
Vim internal
Encoding
Terminal Encoding
File Encoding
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
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…
Com
pu
ter C
en
ter, C
S, N
CTU
13
Configuration Management – Result?Configuration Management – Result?
你的設定檔長這樣嗎 ?
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
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
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
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)
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
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
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