200 likes | 364 Views
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).
E N D
Workstation Environments changlp
Workstation Environments • Encoding • 亂碼 • Shell • Efficiency • Configuration • Management
Encoding & Locale • Bug5Big5 • BBS, News • ?年遺毒 • UTF-8 • 現代人專用編碼
Encoding – Migrate to UTF-8 (1/2) % export LC_ALL=zh_TW.UTF-8 % vim
Encoding – Big5 • BBS, News…
Terminal Multiplexers • GNU Screen • sysutils/screen • sysutils/byobu • Tmux • sysutils/tmux
Terminal Multiplexers – 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
VIM – Encoding • fileencoding (fenc) • Encoding of a file • fencs • encoding (enc) • Encoding of vim internal • Default: $env[LANG] • terminalencoding (tenc) • Encoding of terminal • Default: enc
VIM – Encoding Vim internal Terminal Encoding Encoding File Encoding
VIM – 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
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…
Configuration Management – Result? • 你的設定檔長這樣嗎?
真 ˙ Configuration Management • Good for maintenance • Categorize your configurations • Alias, completion… etc • Readability • Write once, use anywhere • Exceptions should be handled
真 ˙ Configuration Management (Cont.) • OS-based settings • Host-based settings if( -f $HOME/.csh/os/`uname -s`.cshrc ) then source $HOME/.csh/os/`uname -s`.cshrc endif if( -f $HOME/.csh/hosts/$HOST.cshrc ) then source $HOME/.csh/hosts/$HOST.cshrc endif
真 ˙ Configuration Management (Cont.) • Misc foreach src ($HOME/.csh/misc/*) if ( -f $src ) then source $src endif end
VIM - Plugin • $HOME/.vim • after • autoload • plugin • … • Install a plugin • http://www.vim.org/scripts • Unzip to $HOME/.vim • Uninstall? • 硬碟很大沒在怕 (X) • Plugin 多才潮 (X) • 我哪知道裝了啥 (O)
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 on filetype plugin indent on
VIM – Plugin Management (2/2) • Each plugin get a subdir • Good for • Installing • Uninstalling • Updating • Plugin listing • A little painful while migrating
VIM – Other Management Tools • Vim-addon-manager • https://github.com/MarcWeber/vim-addon-manager • Vimball • http://www.vim.org/scripts/script.php?script_id=1502