diff --git a/install_conf.sh b/install_conf.sh new file mode 100644 index 0000000..354cc16 --- /dev/null +++ b/install_conf.sh @@ -0,0 +1,2 @@ +ln -s ./vimrc/.vimrc ~/.vimrc +ln -s ./zshrc/.zshrc ~/.zshrc diff --git a/vimrc/.vimrc b/vimrc/.vimrc new file mode 100644 index 0000000..4c5c607 --- /dev/null +++ b/vimrc/.vimrc @@ -0,0 +1,306 @@ +" バックスペースキーで削除を有効にする " +set backspace=indent,eol,start + +" ================================================== +" START: NeoBundle +" ================================================== + +" Note: Skip initialization for vim-tiny or vim-small. +if !1 | finish | endif + +if has('vim_starting') +set nocompatible " Be iMproved + +" Required: +set runtimepath+=~/.vim/bundle/neobundle.vim/ +endif + +" Required: +call neobundle#begin(expand('~/.vim/bundle/')) + + +" Let NeoBundle manage NeoBundle +" Required: +NeoBundleFetch 'Shougo/neobundle.vim' + +" My Bundles here: +" Refer to |:NeoBundle-examples|. +" Note: You don't set neobundle setting in .gvimrc! + +" ColorScheme +NeoBundle 'w0ng/vim-hybrid' + +NeoBundle 'Lokaltog/powerline', {'rtp' : 'powerline/bindings/vim'} + +" Fonts +NeoBundle 'Lokaltog/powerline-fonts' + +" lightline.vim - StatusLineCustmize +"NeoBundle 'itchyny/lightline.vim' + +" vim-airline +NeoBundle 'bling/vim-airline' + +" NERDTree +NeoBundle 'scrooloose/nerdtree' + +" GitHub操作 +NeoBundle 'tpope/vim-fugitive' + +" 入力補完 +NeoBundle 'Shougo/neocomplete.vim' + +" Scalaシンタックス +NeoBundle 'derekwyatt/vim-scala' + +" RustSyntax +NeoBundle 'rust-lang/rust.vim' + +" ElixirSyntax +NeoBundle 'elixir-lang/vim-elixir' + +" ElmSyntax +NeoBundle 'ElmCast/elm-vim' + +" ctags auto +NeoBundle 'szw/vim-tags' + +" auto-ctags +NeoBundle 'soramugi/auto-ctags.vim' + +" Tagbar +NeoBundle 'majutsushi/tagbar' + +call neobundle#end() + +" Required: +filetype plugin indent on + +" If there are uninstalled bundles found on startup, +" this will conveniently prompt you to install them. +NeoBundleCheck + +" ================================================== +" END: NeoBundle +" ================================================== + + +" ================================================== +" START: neocomplete.vim +" ================================================== + +"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! +" Disable AutoComplPop. +let g:acp_enableAtStartup = 0 +" Use neocomplete. +let g:neocomplete#enable_at_startup = 1 +" Use smartcase. +let g:neocomplete#enable_smart_case = 1 +" Set minimum syntax keyword length. +let g:neocomplete#sources#syntax#min_keyword_length = 3 +let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' + +" Define dictionary. +let g:neocomplete#sources#dictionary#dictionaries = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ 'scheme' : $HOME.'/.gosh_completions' + \ } + +" Define keyword. +if !exists('g:neocomplete#keyword_patterns') + let g:neocomplete#keyword_patterns = {} +endif +let g:neocomplete#keyword_patterns['default'] = '\h\w*' + +" Plugin key-mappings. +inoremap neocomplete#undo_completion() +inoremap neocomplete#complete_common_string() + +" Recommended key-mappings. +" : close popup and save indent. +inoremap =my_cr_function() +function! s:my_cr_function() + return neocomplete#close_popup() . "\" + " For no inserting key. + "return pumvisible() ? neocomplete#close_popup() : "\" +endfunction +" : completion. +inoremap pumvisible() ? "\" : "\" +" , : close popup and delete backword char. +inoremap neocomplete#smart_close_popup()."\" +inoremap neocomplete#smart_close_popup()."\" +inoremap neocomplete#close_popup() +inoremap neocomplete#cancel_popup() +" Close popup by . +"inoremap pumvisible() ? neocomplete#close_popup() : "\" + +" For cursor moving in insert mode(Not recommended) +"inoremap neocomplete#close_popup() . "\" +"inoremap neocomplete#close_popup() . "\" +"inoremap neocomplete#close_popup() . "\" +"inoremap neocomplete#close_popup() . "\" +" Or set this. +"let g:neocomplete#enable_cursor_hold_i = 1 +" Or set this. +"let g:neocomplete#enable_insert_char_pre = 1 + +" AutoComplPop like behavior. +"let g:neocomplete#enable_auto_select = 1 + +" Shell like behavior(not recommended). +"set completeopt+=longest +"let g:neocomplete#enable_auto_select = 1 +"let g:neocomplete#disable_auto_complete = 1 +"inoremap pumvisible() ? "\" : "\\" + +" Enable omni completion. +autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS +autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags +autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS +autocmd FileType python setlocal omnifunc=pythoncomplete#Complete +autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags + +" Enable heavy omni completion. +if !exists('g:neocomplete#sources#omni#input_patterns') + let g:neocomplete#sources#omni#input_patterns = {} +endif +"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' +"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' + +" For perlomni.vim setting. +" https://github.com/c9s/perlomni.vim +let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::' + +" ================================================== +" END: neocomplete.vim +" ================================================== + + +" ================================================== +" START: lightline.vim +" ================================================== + +set laststatus=2 + +let g:lightline = { + \ 'colorscheme': 'wombat', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'fugitive', 'filename' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'MyFugitive', + \ 'readonly': 'MyReadonly', + \ 'modified': 'MyModified', + \ 'filename': 'MyFilename' + \ }, + \ 'separator': { 'left': '', 'right': ' ' }, + \ 'subseparator': { 'left': '', 'right': ' ' } + \ } + +function! MyModified() + if &filetype == "help" + return "" + elseif &modified + return "+" + elseif &modifiable + return "" + else + return "" + endif +endfunction + +function! MyReadonly() + if &filetype == "help" + return "" + elseif &readonly + return "" + else + return "" + endif +endfunction + +function! MyFugitive() + return exists('*fugitive#head') ? fugitive#head() : '' +endfunction + +function! MyFilename() + return ('' != MyReadonly() ? MyReadonly() . ' ' : '') . + \ ('' != expand('%:t') ? expand('%:t') : '[No Name]') . + \ ('' != MyModified() ? ' ' . MyModified() : '') +endfunction + +function! MyFugitive() + if exists("*fugitive#head") + let _ = fugitive#head() + return strlen(_) ? ' '._ : '' + endif + return '' +endfunction + +" ================================================== +" END: lightline.vim +" ================================================== + + +" ================================================== +" START: vim-airline +" ================================================== + +let g:airline_powerline_fonts = 1 + +" ================================================== +" END: vim-airline +" ================================================== +" + +" ================================================== +" ENABLE: plugins +" ================================================== + +" ColorScheme +syntax on +let g:hybrid_use_Xresources = 1 +if has("mac") + "colorscheme hybrid +endif + +" カレント行をハイライト +set cursorline +hi clear CursorLine +hi CursorLineNr term=bold cterm=NONE ctermfg=228 ctermbg=NONE +" 行番号表示 +set number +" が置き換わるspace数 +set softtabstop=2 +" インデントの際タブでなくスペースを挿入 +set expandtab +" 自動インデントの際のずれはば +set shiftwidth=2 + +" 引数なしの場合のみNERDTreeを有効 +let file_name = expand('%') +if has('vim_starting') && file_name == '' + autocmd VimEnter * execute 'NERDTree ./' +endif + +" NERDTreeを右側に表示 +let g:NERDTreeWinPos="right" + +" Tagbar +nmap :TagbarToggle +let g:tagbar_width = 30 +if has("mac") + let g:tagbar_ctags_bin="/usr/local/bin/ctags" +endif + +" インデント数調整 +augroup fileTypeIndent + autocmd! + autocmd BufNewFile,BufRead *.c setlocal tabstop=4 softtabstop=4 shiftwidth=4 + autocmd BufNewFile,BufRead *.cpp setlocal tabstop=2 softtabstop=2 shiftwidth=2 + autocmd BufNewFile,BufRead *.ino setlocal tabstop=2 softtabstop=2 shiftwidth=2 + autocmd BufNewFile,BufRead *.py setlocal tabstop=2 softtabstop=2 shiftwidth=2 +augroup END diff --git a/zshrc/.zshrc b/zshrc/.zshrc new file mode 100644 index 0000000..d901e73 --- /dev/null +++ b/zshrc/.zshrc @@ -0,0 +1,206 @@ +# ~/binをPATHに追加する +#PATH=~/bin:$PATH +#export PATH + +# alias +#alias ls='ls -F --color=auto' +alias ls='ls -FG' +#alias ll='ls -la --color=auto' +alias ll='ls -laG' +#alias la='ls -a --color=auto' +alias la='ls -aG' +alias eng='LANG=C LANGUAGE=C LC_ALL=C' +alias tree='tree -NC' +# source-hightlight +function lessh() { src-hilite-lesspipe.sh $1 | less -R } + +# user file-creation mask +umask 022 + +## キーバインド +# Emacs風キーバインド +#bindkey -e +# Vi風キーバインド +bindkey -v + +## プロンプト +local C_ROOT="%{%}" # 31: red +local C_LOCAL="%{%}" # 36: cyan +local C_REMOTE="%{%}" # 35: magenta +local C_RESET="%{%}" +case ${UID} in +0) + PROMPT="${C_ROOT}%n@%m(%h%)${C_RESET}# " + PROMPT2="%_> " + RPROMPT="[%~]" + SPROMPT="%r is correct? [n,y,a,e]: " + [ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && + PROMPT="${C_ROOT}%n@%B%m%b(%h%)${C_RESET}# " + ;; +*) + PROMPT="${C_LOCAL}%n(%h%)${C_RESET}%% " + PROMPT2="%_> " + RPROMPT="[%~]" + SPROMPT="%r is correct? [n,y,a,e]: " + [ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && + PROMPT="${C_REMOTE}%n@%B%m%b(%h%)${C_RESET}%% " + ;; +esac +# コマンド実行後は右プロンプトを消す +setopt transient_rprompt + +## タイトルバーに各種情報を表示 +case "${TERM}" in +kterm*|xterm) + precmd() { + echo -ne "\033]0;${LOGNAME}@${HOST%%.*}:${PWD}\007" + } + ;; +esac + +## 補完 +autoload -U compinit +compinit +# ディレクトリ名を入力するだけで移動 +#setopt auto_cd +# 自動でpushd +setopt auto_pushd +# 重複するディレクトリはpushdしない +setopt pushd_ignore_dups +# 存在しないコマンド入力時に修正を提案 +setopt correct +# 補完候補リストを詰めて表示 +setopt list_packed +# 補完候補リスト表示時にビープ音を鳴らさない +setopt nolistbeep + +## 履歴 +# 履歴ファイル +HISTFILE=~/.zsh_history +# メモリに保存する履歴の数 +HISTSIZE=100000 +# ファイルに保存する履歴の数 +SAVEHIST=100000 +# 同じコマンドを保存対象外とする +setopt hist_ignore_dups +# 複数のシェル間で履歴を共有する +setopt share_history +# historyコマンド自体は履歴に追加しない +setopt hist_no_store +# 余分な空白を除去して履歴に追加する +setopt hist_reduce_blanks +# スペースではじめたコマンドは履歴に追加しない +#setopt hist_ignore_space +# 直前と同じコマンドはヒストリに追加しない +setopt hist_ignore_dups + +# 履歴検索機能 +autoload 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 + +## Zshの挙動 +# パスの最後に付けたスラッシュを勝手に除去させない +setopt noautoremoveslash +# aliasの場合もaliasを展開して補完対象を探したりする +setopt complete_aliases + +# ~/.zshrc.localが存在すれば読み込む +[ -f ~/.zshrc.local ] && source ~/.zshrc.local + +#function zle-line-init zle-keymap-select { +# VIM_NORMAL="%K{208}%F{black}⮀%k%f%K{208}%F{white} % NORMAL %k%f%K{black}%F{208}⮀%k%f" +# VIM_INSERT="%K{075}%F{black}⮀%k%f%K{075}%F{white} % INSERT %k%f%K{black}%F{075}⮀%k%f" +# RPS1="${${KEYMAP/vicmd/$VIM_NORMAL}/(main|viins)/$VIM_INSERT}" +# RPS2=$RPS1 +# zle reset-prompt +#} +#zle -N zle-line-init +#zle -N zle-keymap-select + +function zle-line-init zle-keymap-select { + vimode="${${KEYMAP/vicmd/NORMAL}/(main|viins)/INSERT}" + + # update status line + if [ -n "$TMUX" ]; then + # tmux + if [ $vimode = "NORMAL" ]; then + statbg="colour236" + statfg="colour247" + statl1bg="colour240" + statl1fg="colour231" + statl2bg="colour148" + statl2fg="colour22" + statr1bg="colour240" + statr1fg="colour247" + statr2bg="colour252" + statr2fg="colour236" + else + statbg="colour24" + statfg="colour117" + statl1bg="colour31" + statl1fg="colour231" + statl2bg="colour231" + statl2fg="colour23" + statr1bg="colour31" + statr1fg="colour117" + statr2bg="colour117" + statr2fg="colour23" + fi + tmux set -g status-bg ${statbg} > /dev/null + tmux set -g status-fg ${statfg} > /dev/null + statl1="#[bg=${statl1bg}, fg=${statl1fg}] #H " + statl1a="#[bg=${statbg}, fg=${statl1bg}]⮀" + statl2="#[bg=${statl2bg}, fg=${statl2fg}] $vimode " + statl2a="#[bg=${statl1bg}, fg=${statl2bg}]⮀" + tmux set -g status-left "${statl2}${statl2a}${statl1}${statl1a}" > /dev/null + statr1="#[bg=${statr1bg}, fg=${statr1fg}] #($HOME/.battery) " + statr1a="#[bg=${statbg}, fg=${statr1bg}]⮂" + statr2="#[bg=${statr2bg}, fg=${statr2fg}] %Y-%m-%d(%a) %H:%M " + statr2a="#[bg=${statr1bg}, fg=${statr2bg}]⮂" + tmux set -g status-right "${statr1a}${statr1}${statr2a}${statr2}" > /dev/null + else + # zsh + showmode $vimode + fi +} +if [ "$TMUX" != "" ]; then + zle -N zle-line-init + zle -N zle-keymap-select +fi + +function peco-select-history() { + local tac + if which tac > /dev/null; then + tac="tac" + else + tac="tail -r" + fi + # peco --query $LBUFFER 直前の文字列を初期値にし検索する + # awk '!a[$0]++' 連想配列を利用し重複を高速に削除する + # awk は一行づつ処理を行う ($0 はその行全体) + BUFFER=$(history -n 1 | eval $tac | awk '!a[$0]++' | peco --prompt '(*´⊿`)⊃' --query "$LBUFFER") + # カーソルを行末に移動する + # 変数名の前に # を付けることで変数の文字数をカウントする + CURSOR=$#BUFFER + #zle clear-screen +} +zle -N peco-select-history +bindkey '^r' peco-select-history + +function ls-peco() { + FILTERD_LS=$(ls | peco) + BUFFER=${BUFFER}${FILTERD_LS} + CURSOR=$#BUFFER +} + +function peco-process-kill() { + for pid in `ps aux | peco --prompt 'KILL!>' | awk '{print $2}'` + do + kill $pid + echo "Killed ${pid}" + done +} +alias kill-peco="peco-process-kill"