Skip to content

Instantly share code, notes, and snippets.

@daxanya2
Created February 2, 2014 08:07
Show Gist options
  • Save daxanya2/8764542 to your computer and use it in GitHub Desktop.
Save daxanya2/8764542 to your computer and use it in GitHub Desktop.
OS X Mavericks にまっさらな状態から環境設定してみる ref: http://qiita.com/daxanya1/items/d237eb3dc4f5d8cdad9c
unbind C-b
set-option -g prefix C-t
bind r source-file ~/.tmux.conf
bind e setw synchronize-panes on
bind E setw synchronize-panes off
# Base
set-window-option -g utf8 on
set -g status-utf8 on
set-window-option -g mode-keys vi
set-option -g mouse-select-pane on
set-window-option -g mode-mouse on
set -s escape-time 0
# Windows
set-option -g base-index 1
bind-key c new-window
bind Space choose-window
# Panes
bind b break-pane
bind C-h select-pane -L
bind C-j select-pane -D
bind C-k select-pane -U
bind C-l select-pane -R
bind l resize-pane -R
bind j resize-pane -D
bind k resize-pane -U
bind h resize-pane -L
bind L resize-pane -R 10
bind J resize-pane -D 10
bind K resize-pane -U 10
bind H resize-pane -L 10
# Use vim keybindings in copy mode
setw -g mode-keys vi
#Views
set-option -g default-terminal "screen-256color"
set-option -g default-command "reattach-to-user-namespace -l zsh"
set -g set-titles on
set -g set-titles-string '#20(whoami)@#H:#20(pwd)'
#### COLOUR (Solarized 256)
# default statusbar colors
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg colour166 #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg colour235 #base02
set-option -g pane-active-border-fg colour240 #base01
# message text
set-option -g message-bg colour235 #base02
set-option -g message-fg colour166 #orange
# pane number display
set-option -g display-panes-active-colour colour33 #blue
set-option -g display-panes-colour colour166 #orange
# clock
set-window-option -g clock-mode-colour colour64 #green
set-option -g status-interval 10
set-option -g status-justify "centre"
set-option -g status-left-length 60
set-option -g status-right-length 90
# 設定リロード
bind r source-file ~/.tmux.conf
set nocompatible
set number
set expandtab
set tw=0
set tabstop=2
set shiftwidth=2
set softtabstop=2
set list
set listchars=tab:▸\
filetype off
if has('vim_starting')
set runtimepath+=~/dotfiles/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/dotfiles/.vim/bundle/'))
filetype plugin indent on
" Installation check.
if neobundle#exists_not_installed_bundles()
echomsg 'Not installed bundles : ' .
\ string(neobundle#get_not_installed_bundle_names())
echomsg 'Please execute ":NeoBundleInstall" command.'
"finish
endif
"git clone git://github.com/Shougo/neobundle.vim ~/dotfiles/.vim/bundle/neobundle.vim
NeoBundle 'Shougo/neobundle.vim'
#! /usr/bin/env zsh
# -*- mode: sh; coding: utf-8; indent-tabs-mode: nil -*-
#
export LANG=ja_JP.UTF-8
path=(
{/usr/local,/usr,}{/bin,/sbin}(N-/)
)
typeset -gxU path
manpath=(
{/usr,/usr/local}/share/man(N-/)
)
typeset -gxU manpath
[ -z "$ld_library_path" ] && typeset -xT LD_LIBRARY_PATH ld_library_path
[ -z "$include" ] && typeset -xT INCLUDE include
typeset -xU ld_library_path include
## function: auto-zcompile & source
function _auto_zcompile_source () {
local A; A=$1
[[ -e "${A:r}.zwc" ]] && [[ "$A" -ot "${A:r}.zwc" ]] ||
zcompile $A >/dev/null 2>&1 ; source $A
}
[ -f $ZDOTDIR/proxy ] && \
_auto_zcompile_source $ZDOTDIR/proxy
[ -d $HOME/bin ] && path=( $HOME/bin $path )
### duplicate cleaning
typeset -gxU path cdpath fpath manpath ld_library_path include
export HOMEBREW_CASK_OPTS="--appdir=/Applications"
path=(
$HOME/.anyenv/bin
{/usr/local,/usr,}{/bin,/sbin}(N-/)
)
[[ -s $HOME/dotfiles/.tmuxinator/scripts/tmuxinator ]] && source $HOME/dotfiles/.tmuxinator/scripts/tmuxinator
#! /usr/bin/env zsh
#
umask 022 # default umask
bindkey -e # keybind -> emacs like
setopt no_beep # beep を無効化
setopt auto_pushd # cd 時に Tab 補完
setopt pushd_to_home # pushd を引数無しで実行した時に pushd ~ とする
setopt pushd_ignore_dups # ディレクトリスタックに重複する物は古い方を削除
DIRSTACKSIZE=20
limit coredumpsize 0
setopt correct # コマンドのスペル訂正
setopt rc_quotes # '' で ' を表現(エスケープをちょっとだけ省く)
unsetopt correct_all # 全ての引数のスペル訂正: 無効化
setopt auto_resume # リダイレクトしてない suspend job を同じ操作で再開
setopt bg_nice # bg の nice を低くして実行
setopt notify # バックグラウンドジョブの状態変化を即時報告する
setopt nohup # default は nohup
## functions treat as array
typeset -Uga chpwd_functions
typeset -Uga precmd_functions
typeset -Uga preexec_functions
## utilities
autoload -Uz colors; colors # 色指定を $fg[red] 等で行なえるように.
HISTFILE=$ZDOTDIR/history/${USER}-zhistory
HISTSIZE=100000
SAVEHIST=HISTSIZE
setopt extended_history # コマンドの開始時刻と経過時間を登録
unsetopt share_history # ヒストリの共有 for GNU Screen
setopt inc_append_history # 履歴を直ぐに反映
setopt hist_ignore_space # コマンド行先頭が空白の時登録しない
unsetopt hist_ignore_all_dups # 重複ヒストリは古い方を削除
setopt hist_reduce_blanks # 余分なスペースを削除
setopt hist_no_store # historyコマンドは登録しない
autoload -Uz history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end
function history-all { history -E 1} # 履歴の一覧を出力
export LSCOLORS=ExFxCxdxBxegedabagacad
export LS_COLORS='di=01;34:ln=01;35:so=01;32:ex=01;31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
export ZLS_COLORS=$LS_COLORS
export CLICOLOR=true
## Options
setopt auto_list # 補完候補を一覧で表示
setopt auto_param_slash # 補完候補がディレクトリの場合, 末尾に / を追加
setopt auto_param_keys # カッコの対応も補完
setopt list_packed # 補完候補をできるだけ詰めて表示
setopt list_types # 補完候補のファイル種別を識別
unsetopt list_beep # 補完の beep を無効化
setopt rec_exact # 曖昧補完を有効化
setopt interactive_comments # コマンドでも # 以降をコメントとみなす
setopt magic_equal_subst # = 以降も補完(--prefix= 等)
setopt complete_in_word # コマンドの途中でもカーソル位置で補完
setopt always_last_prompt # カーソル位置を保持してファイル名一覧を補完
## style
zstyle ':completion:*' menu select=2 # カーソルによる補完候補の選択を有効化
# 色指定に LS_COLORS を使用
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# 種別を別々に表示させるため, グループを空白に
zstyle ':completion:*' group-name ''
# ディレクトリ名の補完
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' keep-prefix
# リモートディレクトリも補完
zstyle ':completion:*' remote-access true
zstyle ':completion:*' completer \
_oldlist _complete _match _ignored _approximate _list _history
## 補完候補の追加
[ -d $ZDOTDIR/modules/completions ] && \
fpath+=( $ZDOTDIR/modules/zsh-completions/src $fpath)
# [ -d $ZDOTDIR/functions ] && \
# fpath+=( $ZDOTDIR/functions $fpath)
typeset -gxU fpath
# autoload $ZDOTDIR/functions/*.zsh
# 初期化
setopt prompt_subst # プロンプト定義内で変数置換やコマンド置換を扱う
setopt prompt_percent # %文字から始まる置換機能を有効に
unsetopt promptcr # 被る時は右プロンプトを消す
setopt transient_rprompt # コマンド実行後は右プロンプトを消す
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git bzr svn hg
zstyle ':vcs_info:*' formats '%s:%b'
zstyle ':vcs_info:*' actionformats '%s:%b%a'
zstyle ':vcs_info:(svn|bzr)' branchformat '%b:r%r'
zstyle ':vcs_info:bzr:*' use-simple true
function prompt_vcs_info(){
LANG=C vcs_info
if [[ -n "$vcs_info_msg_0_" ]]; then
ps_vcs_info="[%B%F{red}$vcs_info_msg_0_%f%b]"
else
ps_vcs_info=''
fi
}
precmd_functions+=prompt_vcs_info
function count_prompt_chars (){
print -n -P -- "$1" | sed -e $'s/\e\[[0-9;]*m//g' | wc -m | sed -e 's/ //g'
}
# precmd のプロンプト更新用関数
function update_prompt (){
## プロンプト: 1段目左
local ps_user="%(!,%B%F{magenta}%n%b,%n)"
local ps_host="%m"
[[ -n ${SSH_CONNECTION} ]] && ps_host="%F{yellow}%m%f"
local prompt_1st_left="[$ps_user@$ps_host$chroot_info]"
## プロンプト: 1段目右
local prompt_1st_right="[%F{white}%(5~,%-2~/.../%1~,%~)%f]"
## 1段目行の残り文字列の計算
local left_length=$(count_prompt_chars $prompt_1st_left)
local right_length=$(count_prompt_chars $prompt_1st_right)
local bar_rest_length=$[ COLUMNS - left_length - right_length -1 ]
## 1段目に水平線を引く
local prompt_1st_hr=${(l:${bar_rest_length}::-:)}
## PROMPT の設定
# @see Zshをかわいくする.zshrcの設定
# URL: http://qiita.com/kubosho_/items/c200680c26e509a4f41c
# 横幅等を調整.
local ps_status="[%j]%(?.%B%F{green}.%B%F{blue})%(?!(*'-')%b!(*;-;%)%b)%f "
local ps_mark="%(!,%B%F{magenta}#%f%b,%%)"
PROMPT="$prompt_1st_left$prompt_1st_hr$prompt_1st_right-"$'\n'"$ps_status$ps_mark "
PROMPT2='|%j]> '
SPROMPT="[%j]%B%F{red}%{$suggest%}(*'~'%)?<%b %U%r%u is correct? [n,y,a,e]:%f "
# 右プロンプト
RPROMPT="$ps_vcs_info"
}
precmd_functions+=update_prompt
export MANPAGER='less -s'
export PAGER='less -R'
if whence lv >/dev/null ; then
export PAGER=lv ; export LV="-c -T8192 -l"
else
alias lv=$PAGER
fi
whence vim >/dev/null && alias vi=vim
export EDITOR=vi
## ls
alias sl='ls' #fxxk!!
export TIME_STYLE=long-iso
export LS_OPTIONS="-N -T 0 --time-style=$TIME_STYLE"
alias ls='ls -FG'
alias la='ls -haFG'
alias ll='ls -hlFG'
alias lla='ls -hlaFG'
alias lsd='ls -ld *(-/DN)'
alias man='LANG=C man'
alias vim=/Applications/MacVim.app/Contents/MacOS/Vim
alias vi=vim
PATH="/Applications/MacVim.app/Contents/MacOS:$PATH"
if [ ! -f $ZDOTDIR/.zshenv.zwc -o $ZDOTDIR/.zshenv -nt $ZDOTDIR/.zshenv.zwc ]; then
zcompile $ZDOTDIR/.zshenv
fi
if [ ! -f $ZDOTDIR/.zshrc.zwc -o $ZDOTDIR/.zshrc -nt $ZDOTDIR/.zshrc.zwc ]; then
zcompile $ZDOTDIR/.zshrc
fi
set clipboard=unnamed,autoselect
NeoBundle 'altercation/vim-colors-solarized'
let g:solarized_termcolors=256
let g:solarized_termtrans=0
let g:solarized_hitrail=1
let g:solarized_visibility=1
syntax enable
set background=light
colorscheme solarized
# ~/.tmuxinator/default.yml
name: default
root: ~/
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start
# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
# pre_window: rbenv shell 2.0.0-p247
# Pass command line options to tmux. Useful for specifying a different tmux.conf.
# tmux_options: -f ~/.tmux.mac.conf
# Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
# tmux_command: byobu
windows:
- editor:
layout: main-vertical
panes:
- guard
- guard
- guard
$ xcode-select —install
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
$ chsh -s /usr/local/bin/zsh
$ ln -s ~/dotfiles/.zshenv ~/.zshenv
$ git clone https://github.com/riywo/anyenv .anyenv
$ exec $SHELL -l
$ anyenv install rbenv
$ anyenv install plenv
$ anyenv install pyenv
$ anyenv install ndenv
$ exec $SHELL -l
$ brew doctor
$ rbenv install 2.0.0-p353
$ rbenv rehash
$ rbenv global 2.0.0-p353
$ plenv install 5.16.3
$ plenv rehash
$ plenv global 5.16.3
$ pyenv install 2.7.6
$ pyenv rehash
$ pyenv global 2.7.6
$ ndenv install v0.10.25
$ ndenv rehash
$ ndenv global v0.10.25
$ gem install jekyll
$ rbenv rehash
~ (ホームディレクトリ)
+ .zshenv (※1のシンボリックリンク)
+ .anyenv/
+ dotfiles/
+ Brewfile
+ .zshenv (※1)
+ .zsh/
+ .zshrc
+ .zshenv
~ (ホームディレクトリ)
+ .zshenv (※1のシンボリックリンク)
+ .vimrc (※2のシンボリックリンク)
+ .anyenv/
+ dotfiles/
+ Brewfile
+ .zshenv (※1)
+ .zsh/
+ .zshrc
+ .zshenv
+ .vimrc (※2)
+ .vim/
+ .vimrc
+ bundle/
+ conf.d/
+ : (以下、設定ファイル)
$ ln -s ~/dotfiles/.vimrc ~/.vimrc
$ git clone https://github.com/Shougo/neobundle.vim ~/dotfiles/.vim/bundle/neobundle.vim
tap homebrew/binary
tap phinze/homebrew-cask
install ack
install autoconf
install binutils
install git
install gnu-sed
install heroku-toolbelt
install openssl
install postgresql
install w3m
install wget
install tmux
# zshは/etcを参照しないようにする(参考:brew info zsh)
install zsh --disable-etcdir
install fontforge
install reattach-to-user-namespace
# macvimを入れる
tap supermomonga/homebrew-splhack
install --HEAD cmigemo-mk
install --HEAD ctags-objc-ja
install gettext-mk
install --HEAD macvim-kaoriya
linkapps
# powerline用フォントを作成する
tap sanemat/font
install --powerline --vim-powerline ricty
# 以下mac用アプリを入れる
install brew-cask
cask install dropbox
cask install google-chrome
cask install skype
cask install vagrant
cask install virtualbox
cask install hipchat
cask install iterm2
cask install kobito
cask install bettertouchtool
cask install alfred
cask alfred link
cask install KeyRemap4MacBook
$ ln -s ~/dotfiles/.tmux.conf ~/.tmux.conf
$ gem install tmuxinator
$ rbenv rehash
$ mkdir ~/dotfiles/.tmuxinator/
$ ln -s ~/dotfiles/.tmuxinator/ ~/.tmuxinator
$ export HOMEBREW_CASK_OPTS="--appdir=/Applications"
$ mux new default
$ mux start default
$ brew bundle ~/dotfiles/Brewfile
$ cp -f /usr/local/Cellar/ricty/3.2.2/share/fonts/Ricty*.ttf ~/Library/Fonts/
$ fc-cache -vf
$ sudo vi /etc/shells
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
/usr/local/bin/zsh
NeoBundle 'itchyny/lightline.vim'
let g:lightline = {
\ 'colorscheme': 'landscape',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'modified': 'MyModified',
\ 'readonly': 'MyReadonly',
\ 'fugitive': 'MyFugitive',
\ 'filename': 'MyFilename',
\ 'fileformat': 'MyFileformat',
\ 'filetype': 'MyFiletype',
\ 'fileencoding': 'MyFileencoding',
\ 'mode': 'MyMode',
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
function! MyModified()
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! MyReadonly()
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction
function! MyFilename()
return ('' != MyReadonly() ? MyReadonly() . ' ' : '') .
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') .
\ ('' != MyModified() ? ' ' . MyModified() : '')
endfunction
function! MyFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? '⭠ '._ : ''
endif
return ''
endfunction
function! MyFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! MyFiletype()
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : ''
endfunction
function! MyFileencoding()
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : ''
endfunction
function! MyMode()
return winwidth(0) > 60 ? lightline#mode() : ''
endfunction
NeoBundle 'Shougo/neocomplcache'
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : ''
\ }
" Plugin key-mappings.
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplcache#smart_close_popup() . "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
NeoBundle 'Shougo/neosnippet'
NeoBundle 'Shougo/neosnippet-snippets'
let g:neosnippet#snippets_directory='~/dotfiles/.vim/bundle/neosnippet-snippets/neosnippets,~/dotfiles/.vim/snippets'
" <TAB>: completion.
" inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
" SuperTab like snippets behavior.
" imap <expr><TAB> neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
imap <expr><TAB> pumvisible() ? "\<C-n>" : neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#jumpable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
<?xml version="1.0"?>
<root>
<item>
<name>ESC to IME off (to English) + Esc + Esc</name>
<appendix>Enable for all but HHK</appendix>
<identifier>private.vim.ime_off_ESC</identifier>
<only>TERMINAL, VI</only>
<inputsource_only>JAPANESE</inputsource_only>
<autogen>
__KeyToKey__ KeyCode::ESCAPE, ModifierFlag::NONE,
KeyCode::VK_CHANGE_INPUTSOURCE_ENGLISH,
KeyCode::VK_CHANGE_INPUTSOURCE_JAPANESE,
KeyCode::VK_CHANGE_INPUTSOURCE_ENGLISH,
KeyCode::ESCAPE, KeyCode::ESCAPE
</autogen>
</item>
<item>
<name>Control + BRACKET_LEFT to IME off (to English) + Esc + Esc</name>
<identifier>private.vim.ime_new</identifier>
<only>TERMINAL, VI</only>
<inputsource_only>JAPANESE</inputsource_only>
<autogen>
__KeyToKey__ KeyCode::BRACKET_LEFT,
MODIFIERFLAG_EITHER_LEFT_OR_RIGHT_CONTROL|ModifierFlag::NONE,
KeyCode::VK_CHANGE_INPUTSOURCE_ENGLISH,
KeyCode::VK_CHANGE_INPUTSOURCE_JAPANESE,
KeyCode::VK_CHANGE_INPUTSOURCE_ENGLISH,
KeyCode::ESCAPE, KeyCode::ESCAPE
</autogen>
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment