It's been a while since I built the environment for El Capitan from scratch, so make a note.
Since it has already been published, details are omitted.
$ xcode-select --install
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This time it was a clean installation on El Capitan, so I didn't think about anything and it was as official. Be careful of the system protection function "Rootless" when updating from Yosemite.
Since it has already appeared (rya)
$ brew install zsh --without-etcdir
$ brew install z zsh-completions zsh-history-substring-search zsh-syntax-highlighting
$ sudo echo "/usr/local/bin/zsh" >> /etc/shells
$ chsh -s /usr/local/bin/zsh
"Shell Integration" that can be used in the Beta version is nice, Comply with Basic Policy 1 "Install applications with Homebrew + Cask as much as possible".
$ brew cask install iTerm2
In the first place, I decided to build an environment from scratch because I read this article. → Building a python environment for those who want to become a data scientist 2016 --Qiita
Biting pyenv as Anaconda can break the Homebrew environment. Since the virtual environment after that is set in Anaconda, pyenv is done only once.
$ brew install pyenv
$ pyenv install anaconda3-2.5.0
$ pyenv global anaconda3-2.5.0
$ pyenv rehash
If the capacity is tight on MacBook Air etc., Miniconda may be fine.
Dein.vim must be 7.4 or higher (or NeoVim), so reinsert it.
$ brew install lua luajit
$ brew install vim --override-system-vi --with-lua --with-luajit --with-python3
On the way, the dependent python is installed without permission, but there is no problem because .zshrc is rewritten so that Anaconda's Python is preferentially referenced.
** * The full text of .zshrc will be exposed at the end of the article. ** **
Until then, do the following: If you are uneasy, please check with python -V
each time.
$ export PATH=~/anaconda3/bin:"$PATH"
Thanks to Shougo and did the following:
$ curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh
$ sh ./installer.sh ~/.vim/dein
Since there is no convention, I somehow installed it in ~ / .vim / dein
.
Continue with .vimrc.
Official Doc street.
$ pip install --user powerline-status
When installed in Anaconda environment, the powerline commands seem to be installed in ~ / .local / bin
.
So, I added something like this.
** * The full text of .zshrc will be exposed at the end of the article. ** **
## Powerline
# https://powerline.readthedocs.org/en/master/
if [ -d ~/.local/bin ]; then
export PATH="$PATH":~/.local/bin
powerline-daemon -q
. ~/.local/lib/python3.5/site-packages/powerline/bindings/zsh/powerline.zsh
fi
Basic policy 5 "I try not to increase the effort even if I reuse dotfiles on other machines" is still insufficient, but for the time being.
It's a hassle to apply patches, so download the patched fonts from GitHub. → https://github.com/powerline/fonts If you unzip it and execute install.sh, it will be installed all at once.
dotfiles Now that we're ready, grab the config file.
.zshrc OS-independent settings.zshrc, OS-dependent settings.zshrc.mine.(osx|ubuntu|cent), Machine-dependent settings(Workplace proxy settings, etc.)To.zshrc.Described as machine.
.zshrc
# LastModified: 2016/02/04
## Zsh launch Time measurement START
#
#zmodload zsh/zprof
## Environment variable configuration
#
# LANG
#
export LANG=ja_JP.UTF-8
export LC_ALL='ja_JP.UTF-8'
case ${UID} in
0)
LANG=C
;;
esac
## Default shell configuration
#
# set prompt
#
autoload -Uz add-zsh-hook
autoload -Uz colors
colors
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn hg bzr
# %s: vcs name, %b: branch name, %a: action name
zstyle ':vcs_info:*' formats '[%s - %b]'
zstyle ':vcs_info:*' actionformats '[%s - %b|%a]'
function _update_vcs_info {
psvar=()
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
RPROMPT="%1(v|%F{green}%1v%f|)"
}
add-zsh-hook precmd _update_vcs_info
case ${UID} in
0)
PROMPT="%{${fg[cyan]}%}$(echo ${HOST%%.*} | tr '[a-z]' '[A-Z]') %B%{${fg[red]}%}%/#%{${reset_color}%}%b "
PROMPT2="%B%{${fg[red]}%}%_#%{${reset_color}%}%b "
SPROMPT="%B%{${fg[red]}%}%r is correct? [No,Yes,Abort,Edit]:%{${reset_color}%}%b "
;;
*)
PROMPT="%{${fg[red]}%}%/%%%{${reset_color}%} "
PROMPT2="%{${fg[red]}%}%_%%%{${reset_color}%} "
SPROMPT="%{${fg[red]}%}%r is correct? [No,Yes,Abort,Edit]:%{${reset_color}%} "
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && PROMPT="%{${fg[cyan]}%}$(echo ${HOST%%.*} | tr '[a-z]' '[A-Z]') ${PROMPT}"
;;
esac
# Don't logoff when pushed C-d
#
setopt ignore_eof
# auto change directory
#
setopt auto_cd
# auto directory pushd that you can get dirs list by cd -[tab]
#
setopt auto_pushd
## cdr
autoload -Uz is-at-least
if is-at-least 4.3.11
then
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
zstyle ':chpwd:*' recent-dirs-max 5000
zstyle ':chpwd:*' recent-dirs-default yes
zstyle ':completion:*' recent-dirs-insert both
fi
# command correct edition before each completion attempt
#
setopt correct
# compacked complete list display
#
setopt list_packed
# no remove postfix slash of command line
#
setopt noautoremoveslash
# no beep sound when complete list displayed
#
setopt nolistbeep
# no nomatch
#
setopt nonomatch
# print eight bit
setopt print_eight_bit
## Keybind configuration
#
# emacs like keybind (e.x. Ctrl-a gets to line head and Ctrl-e gets
# to end) and something additions
#
bindkey -e
bindkey "^[[1~" beginning-of-line # Home gets to line head
bindkey "^[[4~" end-of-line # End gets to line end
bindkey "^[[3~" delete-char # Del
# historical backward/forward search with linehead string binded to ^P/^N
#
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
bindkey "\\ep" history-beginning-search-backward-end
bindkey "\\en" history-beginning-search-forward-end
# reverse menu completion binded to Shift-Tab
#
bindkey "\e[Z" reverse-menu-complete
## Command history configuration
#
HISTFILE=${HOME}/.zsh_history
HISTSIZE=50000
SAVEHIST=50000
setopt hist_ignore_all_dups
setopt hist_ignore_dups
setopt hist_expand
setopt hist_ignore_space
setopt extended_history
setopt share_history
## zsh editor
#
autoload -Uz zed
## Alias configuration
#
# expand aliases before completing
setopt complete_aliases
alias where="command -v"
alias jobs="jobs -l"
alias la="ls -aF"
alias ll="ls -la"
alias du="du -H"
alias df="df -H"
alias rm="rm -i"
alias mv="mv -i"
alias cp="cp -i"
alias su="su -l"
alias vi='vim'
alias g='git'
alias -s rb="ruby"
alias -s py="python"
alias -s php="php -f"
alias -s go="go"
# delete unwanted files
alias duf="find . \( -name '.DS_Store' -o -name '._*' -o -name '.apdisk' -o -name 'Thumbs.db' -o -name 'Desktop.ini' \) -delete -print"
## terminal configuration
#
case "${TERM}" in
screen)
TERM=xterm-256color
;;
esac
case "${TERM}" in
xterm|xterm-color)
export LSCOLORS=exfxcxdxbxegedabagacad
export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
zstyle ':completion:*' list-colors 'di=34' 'ln=35' 'so=32' 'ex=31' 'bd=46;34' 'cd=43;34'
;;
esac
## auto ls
#
function chpwd() { ls -aF }
# zsh-syntax-highlighting
#
if [ -f /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]; then
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
fi
## SSH
#
bindkey "^?" backward-delete-char
export MANPATH=/usr/local/man:/usr/share/man:$MANPATH
## load user .zshrc configuration file
#
if [[ -f ~/.zshrc.mine ]]; then
source ~/.zshrc.mine
fi
bash:.zshrc.mine
# LastModified: 2016/03/22
################################################
# for MacOS X
################################################
## HomeBrew
#
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
# HomeBrew Man
export MANPATH=/usr/local/man:/usr/share/man:$MANPATH
## rbenv
##
export RBENV_ROOT="/usr/local/var/rbenv"
if [ -d $RBENV_ROOT ]; then
export PATH="$RBENV_ROOT/bin:$PATH"
if which rbenv > /dev/null; then eval "$(rbenv init - zsh)"; fi
fi
## pyenv
#
export PYENV_ROOT=/usr/local/var/pyenv
export PATH=/usr/local/bin:/usr/local/share/python:$PATH
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
## Gemfile
##
RUBYGEMS_GEMDEPS=-
# -: search Gemfile from current directory to ancestor
## nodebrew
##
nodebrew=$HOME/.nodebrew/current/bin
if [ -d "$nodebrew" ]; then
export PATH=$nodebrew:$PATH
nodebrew use stable > /dev/null
fi
## Alias
#
if [ -e /usr/local/bin/gls ]; then
alias ls="gls --color=auto -F"
else
alias ls="ls -GF"
fi
if [ -x "`which vim`" ]; then
alias vim="/usr/local/bin/vim"
fi
alias b='brew'
alias bi='brew info'
alias bl='brew list'
alias bs='brew -S'
alias bug='brew update && brew upgrade'
alias gibol='gibo -l | sed "/=/d" | tr "\t", "\n" | sed "/^$/d" | sort | peco | xargs gibo'
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'
alias mute_volume='osascript -e "set Volume 0"'
alias max_volume='osascript -e "set Volume 10"'
alias jnethack="cocot -t UTF-8 -p EUC-JP -- /usr/local/bin/jnethack"
# Pygments
if [ -x `which pygmentize` ]; then
alias c='pygmentize -O style=monokai -f console256 -g'
fi
# with Line numbers
alias -g L='| nl -n ln -b a'
## ccze
# Robust and modular log colorizer
# https://packages.debian.org/wheezy/ccze
if [ -x "`which ccze`" ]; then
alias -g C="| ccze -A"
fi
## Completion configuration
#
if [ -d /usr/local/share/zsh-completions ]; then
fpath=(/usr/local/share/zsh-completions $fpath)
fi
autoload -U compinit
compinit -C
## Google Cloud SDK
# brew cask install google-cloud-sdk
#
if [ -f /opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc ]; then
source /opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc
source /opt/homebrew-cask/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc
fi
## Go
#
if [ -x "`which go`" ]; then
export GOPATH=$HOME/go/
export GOROOT=`go env GOROOT`
export PATH=$PATH:$GOPATHbin:$GOROOT/bin
fi
## Peco
# brew tap peco/peco
#
if [ -x "`which peco`" ]; then
alias top='top | peco'
alias ps='ps aux | peco'
alias -g P='| peco'
function peco-select-history () {
local tac
if which gtac > /dev/null; then
tac="gtac"
elif which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | eval $tac | peco --query "$LBUFFER")
CURSOR=$#BUFFER # move cursor
#zle -R -c # refresh
}
zle -N peco-select-history
function peco-cdr () {
local selected_dir=$(cdr -l | awk '{ print $2 }' | peco)
if [ -n "$selected_dir" ]; then
BUFFER="cd ${selected_dir}"
zle accept-line
fi
#zle -R -c
}
zle -N peco-cdr
bindkey '^r' peco-select-history
bindkey '^j' peco-cdr
fi
## z.sh (https://github.com/rupa/z)
# brew install z
# like autojump
#
if [ -f `brew --prefix`/etc/profile.d/z.sh ]; then
source `brew --prefix`/etc/profile.d/z.sh
_Z_CMD=j
compctl -U -K _z_zsh_tab_completion "$_Z_CMD"
fi
## zsh-history-substring-search
# brew install zsh-history-substring-search
#
if [ -f /usr/local/opt/zsh-history-substring-search/zsh-history-substring-search.zsh ]; then
source /usr/local/opt/zsh-history-substring-search/zsh-history-substring-search.zsh
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
fi
## MObileSHell
#
compdef mosh=ssh
## Git
#
compdef g=git
## Haxe
#
export HAXE_STD_PATH="/usr/local/lib/haxe/std"
## Heroku
#
export PATH="/usr/local/heroku/bin:$PATH"
## translate-shell
# https://github.com/soimort/translate-shell
if [ -x "`which trans`" ]; then
alias -g T='| trans :ja'
fi
## iTerm2 Shell Integration
#
test -e ${HOME}/.iterm2_shell_integration.zsh && source ${HOME}/.iterm2_shell_integration.zsh
## Powerline
# pip install --user powerline-status
if [ -d ~/.local/bin ]; then
export PATH="$PATH":~/.local/bin
powerline-daemon -q
. ~/.local/lib/python3.5/site-packages/powerline/bindings/zsh/powerline.zsh
fi
## Setting of each machine
#
if [ -f ~/.zshrc.machine ]; then
source ~/.zshrc.machine
fi
## Login Message
#
echo "============================================================";
echo "= ===== ================== ===== ======== == =";
echo "= === ================= == === ==== ======== == ==";
echo "= = = ================ ==== == ==== ======== == ==";
echo "= == == === ==== === ==== === ============== ===";
echo "= ===== == = == = == ==== ===== ============= ====";
echo "= ===== ===== == ===== ==== ======= ========== ===";
echo "= ===== === == ===== ==== == ==== ======== == ==";
echo "= ===== == = == = === == === ==== ======== == ==";
echo "= ===== === === ===== ===== ======== ==== =";
echo "============================================================";
echo -e "\e[33m [Uptime & Who] \e[m"
w
if [ -x "`which fortune`" ]; then
echo -e "\n\e[33m [Today's fortune] \e[m"
fortune | trans :ja
fi
## Zsh launch Time measurement END
#
#if type zprof > /dev/null 2>&1; then
# zprof | ccze -A
#fi
Please note that you may get angry with "Not Found" in an environment where it is not installed because you regularly use such packages. Both are easy to install from Homebrew.
.vimrc
.vimrc
if &compatible
set nocompatible
endif
" Required:
set runtimepath^=~/.vim/dein/repos/github.com/Shougo/dein.vim
" Required:
call dein#begin(expand('~/.vim/dein'))
" Let dein manage dein
" Required:
call dein#add('Shougo/dein.vim')
call dein#add('Shougo/vimproc.vim', {
\ 'build': {
\ 'windows': 'tools\\update-dll-mingw',
\ 'cygwin': 'make -f make_cygwin.mak',
\ 'mac': 'make -f make_mac.mak',
\ 'linux': 'make',
\ 'unix': 'gmake',
\ },
\ })
" Add or remove your plugins here:
" Fundamental
call dein#add('vim-jp/vimdoc-ja')
call dein#add('Shougo/neosnippet.vim')
call dein#add('Shougo/neosnippet-snippets')
call dein#add('Shougo/unite.vim')
call dein#add('Shougo/vimshell')
call dein#add('scrooloose/nerdtree')
call dein#add('editorconfig/editorconfig-vim')
" Git
call dein#add('tpope/vim-fugitive')
call dein#add('airblade/vim-gitgutter')
" Visual
call dein#add('powerline/powerline', {'rtp': 'powerline/bindings/vim/'})
" Required:
call dein#end()
filetype plugin indent on
" If you want to install not installed plugins on startup.
if dein#check_install()
call dein#install()
endif
" Unite
let g:unite_enable_start_insert = 1
let g:unite_enable_ignore_case = 1
let g:unite_enable_smart_case = 1
" grep
nnoremap <silent> ,g :<C-u>Unite grep:. -buffer-name=search-buffer<CR>
" grep on cursor
nnoremap <silent> ,cg :<C-u>Unite grep:. -buffer-name=search-buffer<CR><C-R><C-W><CR>
" resume grep
nnoremap <silent> ,r :<C-u>UniteResume search-buffer<CR>
set number
set title
set ruler
set showcmd
set showmatch
set matchtime=1
set laststatus=2
set showtabline=2
set noshowmode
set spell
set autoindent
set smartindent
set expandtab
set ts=2 sw=2 sts=0
autocmd BufReadPost * if 0 < line("'\"") && line("'\"") <= line("$") | exe "normal g`\"" | endif
set ignorecase
set smartcase
set wrapscan
set incsearch
set hlsearch
set backspace=start,eol,indent
" Highlight TrailingSpaces
augroup HighlightTrailingSpaces
autocmd!
autocmd VimEnter,WinEnter,ColorScheme * highlight TrailingSpaces term=underline guibg=Red ctermbg=Red
autocmd VimEnter,WinEnter * match TrailingSpaces /\s\+$/
augroup END
By the way, I will also post the vimrc used in NeoBundle before Dein.vim.
vimrc.neobundle
" LastModified: 2015/02/10
if has('vim_starting')
"set nocompatible " Be iMproved
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'windows' : 'make -f make_mingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" My Bundles here:
NeoBundle 'Shougo/neocomplete'
NeoBundle 'Shougo/unite.vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'mattn/emmet-vim'
NeoBundle 'itchyny/lightline.vim'
NeoBundle 'tomasr/molokai'
NeoBundle 'vim-jp/vimdoc-ja'
NeoBundle 'rking/ag.vim'
NeoBundle 'scrooloose/nerdtree'
NeoBundleCheck
call neobundle#end()
filetype plugin indent on " Required!
filetype indent on
syntax on
" neocomplete
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#force_overwrite_completefunc = 1
" Unite
let g:unite_enable_start_insert = 1
let g:unite_enable_ignore_case = 1
let g:unite_enable_smart_case = 1
" grep
nnoremap <silent> ,g :<C-u>Unite grep:. -buffer-name=search-buffer<CR>
" grep on cursor
nnoremap <silent> ,cg :<C-u>Unite grep:. -buffer-name=search-buffer<CR><C-R><C-W><CR>
" resume grep
nnoremap <silent> ,r :<C-u>UniteResume search-buffer<CR>
" use 'ag' instead of 'grep'
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
set number
set showmode
set title
set ruler
set showcmd
set showmatch
set matchtime=1
set laststatus=2
set spell
set display=lastline
set autoindent
set smartindent
set expandtab
set ts=2 sw=2 sts=0
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g`\"" | endif
set ignorecase
set smartcase
set wrapscan
set incsearch
set hlsearch
set backspace=start,eol,indent
" Highlight TrailingSpaces
augroup HighlightTrailingSpaces
autocmd!
autocmd VimEnter,WinEnter,ColorScheme * highlight TrailingSpaces term=underline guibg=Red ctermbg=Red
autocmd VimEnter,WinEnter * match TrailingSpaces /\s\+$/
augroup END
" colorscheme
colorscheme molokai
let g:molokai_original = 1
let g:rehash256 = 1
It feels bad, but you can avoid it by writing LC_ALL in .zshrc.
.zshrc
export LANG=ja_JP.UTF-8
export LC_ALL='ja_JP.UTF-8'
Since iTerm2 Profile has Regular Font and Non-ASCII Font settings, and the triangle is drawn in Non-ASCII Font, Both set patched fonts and Uncheck "Treat ambiguous-width characters as double width". It is faster to drive this area with Powerline's config.
The net working time is about 15 minutes. Memo memo so that it does not become "a memory that I forgot while the cherry blossoms are falling".
Recommended Posts