From 3e903cf7aa1d0fc97aeaf6f44538dc6410d8c028 Mon Sep 17 00:00:00 2001 From: Kazuhiro MUSASHI Date: Sat, 10 Feb 2024 21:33:24 +0900 Subject: [PATCH] initial commit --- .chef_databag_secret | 11 ++ .gemrc | 1 + .gitconfig | 93 ++++++++++ .gitignore | 43 +++++ .screenrc | 28 ++++ .tmux.conf | 112 +++++++++++++ .vimrc | 391 +++++++++++++++++++++++++++++++++++++++++++ .zsh.d/.zshrc | 7 + .zsh.d/alias.zsh | 25 +++ .zsh.d/direnv.zsh | 7 + .zsh.d/fzf.zsh | 7 + .zsh.d/general.zsh | 62 +++++++ .zsh.d/git.zsh | 13 ++ .zsh.d/goenv.zsh | 22 +++ .zsh.d/node.zsh | 9 + .zsh.d/path.zsh | 11 ++ .zsh.d/plugin.zsh | 17 ++ .zsh.d/prompt.zsh | 7 + .zsh.d/rbenv.zsh | 10 ++ .zsh.d/util.zsh | 116 +++++++++++++ .zshenv | 1 + README.md | 20 +++ install.sh | 27 +++ 23 files changed, 1040 insertions(+) create mode 100644 .chef_databag_secret create mode 100644 .gemrc create mode 100644 .gitconfig create mode 100644 .gitignore create mode 100644 .screenrc create mode 100644 .tmux.conf create mode 100644 .vimrc create mode 100644 .zsh.d/.zshrc create mode 100644 .zsh.d/alias.zsh create mode 100644 .zsh.d/direnv.zsh create mode 100644 .zsh.d/fzf.zsh create mode 100644 .zsh.d/general.zsh create mode 100644 .zsh.d/git.zsh create mode 100644 .zsh.d/goenv.zsh create mode 100644 .zsh.d/node.zsh create mode 100644 .zsh.d/path.zsh create mode 100644 .zsh.d/plugin.zsh create mode 100644 .zsh.d/prompt.zsh create mode 100644 .zsh.d/rbenv.zsh create mode 100644 .zsh.d/util.zsh create mode 100644 .zshenv create mode 100644 README.md create mode 100755 install.sh diff --git a/.chef_databag_secret b/.chef_databag_secret new file mode 100644 index 0000000..fa24238 --- /dev/null +++ b/.chef_databag_secret @@ -0,0 +1,11 @@ +dCvArbY7gJrPYVF+JWK+EoPH8BurVDAeaDLxDHn9uHPZFhcbb7UpptYMEdxq8EKL +cfPHPJbkc1DEydL6zlgQIkbXGVFH+pVMtWpX9ADyVE6g6NJ1ouXRLFD79ikHt6sz +sIlihssIOahrcURKK5/W52CwDZT9/aY1m1lJUktbW3pmfNFQ3O9oXpDjYyjosPrn +n2Mnbicb85xxrnz5pRhLt+qw9EalNa1Jqi4e60QL4j8ZvhIoHWPoyhKDwahjzKCk +K3LVpLMPLMSN6TshVvmOUCy5f9Je4fEZBT2Ds/1aJkHbbKlIvk62QmfUKdKJeTbR +mtlIs2jSICX43RqdzJnwK6ZynBQ7GU+D5iicEB9jtgtk1UsoEXdMjsqUs4ECi4GQ +bJxpdiUxuTuoZaMeniOzzDu52dbSt3fp8z9w+8u0moszGaLEg7lRZSIvKtQ+OHee +BFFzJ9bgdI8JC/2HZXsvFujUDPwJW14RHn8x5HgDY0L8HPvmQaTQeVW3tG8zzLfN +J4O2KtN1TfcwNLdZF2VF60UY2XhQdBhNR5gT4m3k8a+7XLJ9vc95VuFG+qxU2eZ9 +vqG+UPkGStDworV6p8tLy5RYh9WF+oKr+IRSREQzOk1r+GQm59X06zzoKgKwIB9U +9MYvIna0gXvpvLcbZjvhkMlttwJ8y+URJ20UxqzNubM= diff --git a/.gemrc b/.gemrc new file mode 100644 index 0000000..6153a6e --- /dev/null +++ b/.gemrc @@ -0,0 +1 @@ +gem: --no-ri --no-rdoc diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..b3935bd --- /dev/null +++ b/.gitconfig @@ -0,0 +1,93 @@ +[user] + name = Kazuhiro MUSASHI + email = simoom634@yahoo.co.jp + +[color] + # colorの設定(以下のコマンドは自動で色つける) + status = auto + diff = auto + branch = auto + interactive = auto + grep = auto + +[core] + editor = /usr/bin/vim + +[alias] + # log関連 + logg = !git log --reverse --oneline main..`git symbolic-ref HEAD` | fzf --preview 'git show --oneline --color=always {1}' + + # log + graph + graph = log --graph --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(white)- %an, %ar%Creset' + + # status - shorter version + s = status -s -b + + # status + st = status + + # diff + d = "!f() { args=$@; [ -z \"$args\" ] && args=HEAD; ([ \"$args\" = \"HEAD\" ] && git status --short || git diff --name-status $args | sed 's/\t/ /') | fzf --preview \"echo {} | cut -c 4- | xargs git diff --color=always $args --\" --multi --height 90% | cut -c 4-; }; f" + + # checkout + co = "!f() { args=$@; if [ -z \"$args\" ]; then branch=$(git branch --all | grep -v HEAD | fzf --preview 'echo {} | cut -c 3- | xargs git log --color=always'); git checkout $(echo $branch | sed 's#remotes/[^/]*/##'); else git checkout $args; fi }; f" + + # commit + c = commit + + # init, add, and commit + prep = !git init && git add . && git commit -m \"initial commit\" + + # add + a = !git add . && git now + + # alias + alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort + + # tags + # http://qiita.com/items/2b9d9560381bbe316818 + tags = for-each-ref --sort=-taggerdate --format='%(taggerdate:short) %(tag) %(taggername) %(subject)' refs/tags + + # git update + # http://qiita.com/tomy_kaira/items/2e1d575202e14a28b600 + update = "!sh -c 'git ft; git rsm; git delete-merged-branches'" + ft = fetch --prune + rsm = update-ref refs/heads/main origin/main + delete-merged-branches = !"brs=`git branch --merged main | grep -Ev '(main|dev)' | grep -v '*'` && git branch -D $brs || true" + up = "!git remote update -p; git merge --ff-only @{u}; git delete-merged-branches" + + # git now rebase + nr = "!git now rebase" + + # git mkbranch = git co -b [branch name] + mkbranch = checkout -b + + # git empty = git commit --allow-empty + empty = commit --allow-empty -m "[WIP] " -e + + # git r, meaning `git rebase -i HEAD~` from the 1st commit in the current branch to the last. + r = "!git rebase --keep-empty -i HEAD~$(git log --pretty=oneline main..$(git symbolic-ref HEAD) | wc -l | sed -Ee 's/ +//')" + + stl = !git stash list | fzf --preview 'echo {} | grep -o stash@{.*} | xargs git stash show -p --color=always' --height 90% | grep -o stash@{.*} + sta = !git stl | xargs git stash apply + std = !git stl | xargs git stash drop + + # git chls + chls = !git log --name-status --oneline main..`git symbolic-ref HEAD` --reverse + +[merge] + # from 1.7.6 + ff = false + +[pull] + # from 1.7.9 + rebase = true +[credential] + helper = cache +[filter "lfs"] + smudge = git-lfs smudge -- %f + process = git-lfs filter-process + required = true + clean = git-lfs clean -- %f +[init] + defaultBranch = main diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..42f44f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +Desktop/ +Documents/ +Downloads/ +Dropbox/ +Library/ +Movies/ +Music +Pictures +Public/ +Sites/ +Wallpapers/ +bin +emacs +emacs.el +junk/ +working +.CFUserTextEncoding +.DS_Store +.Trash/ +.emacs.d +.emacs +*.swp +.bash_history +.cpanm/ +.dropbox/ +.dvdcss/ +.hatena/ +.migemo-pattern +.neocon/ +.recentf +.rnd +.sqlite_history +.ssh/ +.subversion/ +.unite/ +.vim +.vim-vundle/ +.viminfo +.zcompdump +.zhistory +Eye-Fi Card.log +tmux-*.log +.zcompcache/ diff --git a/.screenrc b/.screenrc new file mode 100644 index 0000000..44cd7bd --- /dev/null +++ b/.screenrc @@ -0,0 +1,28 @@ +# Misc +startup_message off # おまけ: 起動画面OFF +autodetach on # おまけ: 回線切断時に自動でdetach +defscrollback 1024 # おまけ: スクロールバッファ行数を増やす + +# Key bind +escape ^Zz + +# I like a large scrollback buffer. +defscrollback 1000 + +# Logging +logfile "/home/kazu634/log/screen-%Y%m%d-%n.log" +log on +deflog on + +# Status Line +hardstatus alwayslastline '%m/%d %02c:%s %{= .g}%H%{-} %L=%-w%45L>%{=u g.}%n %t%{-}%+w' + +# Caption +caption always '%?%F%{= gW}%:%{= Kk}%?%2n%f%07=%t%=' + +# sorendition +sorendition "+rb .G" + +# Screen saver +idle 180 +blankerprg /usr/games/fortune starwars diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..f9eb3fb --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,112 @@ +# ------------------------- # +# PREFIX +# ------------------------- # + +# Unbind the default PREFIX key +unbind C-b + +# Define a PREFIX key +set -g prefix C-z + +# ------------------------- # +# Delay +# ------------------------- # + +set -s escape-time 1 + +# ------------------------- # +# Base index for window and panes +# ------------------------- # + +set -g base-index 1 +setw -g pane-base-index 1 + +# ------------------------- # +# key-bindings +# ------------------------- # + +# Reloading the source file. +bind r source-file ${HOME}/.tmux.conf \; display "~/.tmux.conf reloaded." + +# Spliting the window +bind | split-window -h +bind - split-window -v + +# Movement keys +bind h select-pane -L +bind j select-pane -D +bind k select-pane -U +bind l select-pane -R + +# Movement, when pressing TAB +unbind Tab +bind Tab select-pane -t :.+ + +# vi-like keybindings, when copy-mode +set-window-option -g mode-keys vi + +# Resize panes, using vim keybindings +bind -r H resize-pane -L 5 +bind -r J resize-pane -D 5 +bind -r K resize-pane -U 5 +bind -r L resize-pane -R 5 + +# ------------------------ # +# mouse mode +# ------------------------ # + +# setw -g mode-mouse off + +# ------------------------- # +# Status bar +# ------------------------- # + +setw -g monitor-activity on +set -g visual-activity on + +set -g status-right "@#(uname -n) %Y/%m/%d %H:%M:%S" + +# ------------------------- # +# Colour (Solarized dark) +# ------------------------- # + +# default statusbar colors +set-option -g status-style bg=black,fg=yellow,default + +# default window title colors +set-window-option -g window-status-style fg=brightblue,bg=default +#set-window-option -g window-status-attr dim + +# active window title colors +set-window-option -g window-status-current-style fg=brightred,bg=default +#set-window-option -g window-status-current-attr bright + +# pane border +set-option -g pane-border-style fg=black +set-option -g pane-active-border-style fg=brightgreen + +# message text +set-option -g message-style bg=black,fg=brightred + +# pane number display +set-option -g display-panes-active-colour blue #blue +set-option -g display-panes-colour brightred #orange + +# clock +set-window-option -g clock-mode-colour green #green + +# Screensaver +set -g lock-after-time 60 +set -g lock-command "/usr/games/fortune starwar" + + +set -g default-terminal "tmux-256color" +# Update with value from default-terminal +set -ga terminal-overrides ",tmux-256color:Tc" + +# Ms modifies OSC 52 clipboard handling to work with mosh, see +# https://gist.github.com/yudai/95b20e3da66df1b066531997f982b57b +set -ag terminal-overrides "vte*:XT:Ms=\\E]52;c;%p2%s\\7,xterm*:XT:Ms=\\E]52;c;%p2%s\\7" + +# enable OSC 52 clipboard +set -g set-clipboard on diff --git a/.vimrc b/.vimrc new file mode 100644 index 0000000..d66bea2 --- /dev/null +++ b/.vimrc @@ -0,0 +1,391 @@ +set nocompatible " Be iMproved +filetype off " Required! + +if has('vim_starting') + set runtimepath+=~/.vim/bundle/neobundle.vim/ +endif + +call neobundle#begin(expand('~/.vim/bundle/')) + +NeoBundleFetch "Shougo/neobundle.vim" + +" my bundles here: + +NeoBundle 'Shougo/neocomplcache.git' +NeoBundle 'Shougo/neosnippet.git' +NeoBundle 'Shougo/unite.vim.git' +NeoBundle "thinca/vim-quickrun" +NeoBundle 'vim-scripts/sudo.vim' +NeoBundle 'tpope/vim-surround.git' +NeoBundle 'h1mesuke/vim-alignta' +NeoBundle 'kana/vim-smartchr' +NeoBundle 'vim-ruby/vim-ruby' +NeoBundle 'AutoClose' +NeoBundle 'nathanaelkane/vim-indent-guides' +NeoBundle 'honza/vim-snippets' +NeoBundle 'mattn/emmet-vim' +NeoBundle 'jiangmiao/simple-javascript-indenter' +NeoBundle 'OpsRockin/opscode_chef.vim_dict' +NeoBundle 'Shougo/neosnippet-snippets' + +NeoBundle 'w0rp/ale' + +NeoBundle 'Shougo/vimproc.git', { + \ 'build' : { + \ 'mac' : 'make -f make_mac.mak', + \ 'unix' : 'make -f make_unix.mak', + \ }, + \ } + +NeoBundle 'prabirshrestha/vim-lsp' +NeoBundle 'mattn/vim-lsp-settings' +NeoBundle 'fatih/vim-go' + +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 + +" ------------------------------------------------------------------------------- +" +" ------------------------------------------------------------------------------- + +" Disable AutoComplPop. Comment out this line if AutoComplPop is not installed. +" let g:acp_enableAtStartup = 0 + +" Launches neocomplcache automatically on vim startup. +let g:neocomplcache_enable_at_startup = 1 + +" Use smartcase. +let g:neocomplcache_enable_smart_case = 1 + +" Use camel case completion. +let g:neocomplcache_enable_camel_case_completion = 1 + +" Use underscore completion. +let g:neocomplcache_enable_underbar_completion = 1 + +" Sets minimum char length of syntax keyword. +let g:neocomplcache_min_syntax_length = 3 + +" buffer file name pattern that locks neocomplcache. e.g. ku.vim or fuzzyfinder +let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*' + +" Define file-type dependent dictionaries. +let g:neocomplcache_dictionary_filetype_lists = { + \ 'default' : '', + \ 'vimshell' : $HOME.'/.vimshell_hist', + \ } + +" Define keyword, for minor languages +if !exists('g:neocomplcache_keyword_patterns') + let g:neocomplcache_keyword_patterns = {} +endif +let g:neocomplcache_keyword_patterns['default'] = '\h\w*' + +" Recommended key-mappings. +" : close popup and save indent. +inoremap neocomplcache#smart_close_popup() . "\" + +" : completion. +inoremap pumvisible() ? "\" : "\" + +" , : close popup and delete backword char. +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#smart_close_popup()."\" +inoremap neocomplcache#close_popup() +inoremap neocomplcache#cancel_popup() + +" AutoComplPop like behavior. +"let g:neocomplcache_enable_auto_select = 1 + +" Shell like behavior(not recommended). +"set completeopt+=longest +"let g:neocomplcache_enable_auto_select = 1 +"let g:neocomplcache_disable_auto_complete = 1 +"inoremap pumvisible() ? "\" : "\" +"inoremap neocomplcache#smart_close_popup() . "\" + +" Enable omni completion. Not required if they are already set elsewhere in .vimrc +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, which require computational power and may stall the vim. +if !exists('g:neocomplcache_omni_patterns') + let g:neocomplcache_omni_patterns = {} +endif + +let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' +"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete +let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::' +let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*' +let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::' + + +" ------------------------------------------------------------------------------- +" +" ------------------------------------------------------------------------------- + +" Plugin key-mappings. +imap (neosnippet_expand_or_jump) +smap (neosnippet_expand_or_jump) +xmap (neosnippet_expand_target) + +" SuperTab like snippets behavior. +imap neosnippet#expandable_or_jumpable() ? +\ "\(neosnippet_expand_or_jump)" +\: pumvisible() ? "\" : "\" +smap neosnippet#expandable_or_jumpable() ? +\ "\(neosnippet_expand_or_jump)" +\: "\" + +" For snippet_complete marker. +if has('conceal') + set conceallevel=2 concealcursor=i +endif + +" Enable snipMate compatibility feature. +let g:neosnippet#enable_snipmate_compatibility = 1 + +" Tell Neosnippet about the other snippets +let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets, ~/.vim/snippets' + +" Load rspec.snip when loading rspec files +function! s:RSpecSnippet() + NeoSnippetSource ~/.vim/snippets/ruby.serverspec.snip +endfunction + +autocmd BufEnter *_spec.rb call s:RSpecSnippet() + +" ------------------------------------------------------------------------------- +" Quickrun +" ------------------------------------------------------------------------------- + +let g:quickrun_config = {} +let g:quickrun_config._ = {'runner' : 'vimproc'} + +" ------------------------------------------------------------------------------- +" +" ------------------------------------------------------------------------------- + +inoremap = smartchr#loop('=', ' = ', ' := ', ' => ', ' == ', " === ") +inoremap + smartchr#loop('+', ' + ', '++', ' += ') +inoremap - smartchr#loop('-', ' - ', '--', ' -= ') +inoremap / smartchr#loop('/', ' / ', '// ') +inoremap * smartchr#loop('*', ' * ') +inoremap < smartchr#loop('<', ' < ', ' << ', ' <= ') +inoremap > smartchr#loop('>', ' > ', ' >> ', ' >= ') +inoremap , smartchr#loop(', ', ',') + +" ------------------------------------------------------------------------------- +" +" ------------------------------------------------------------------------------- + +syntax on +filetype on +filetype indent on +filetype plugin on +:colorscheme murphy +set list +set listchars=trail:_,tab:>- + + +" +set encoding=utf-8 + +" +let mapleader = "," " キーマップリーダー +set nobackup " バックアップ取らない +set hidden " 編集中でも他のファイルを開けるようにする +set formatoptions=lmoq " テキスト整形オプション,マルチバイト系を追加 +set vb t_vb= " ビープをならさない +set backspace=indent,eol,start " バックスペースでなんでも消せるように +set autoread " 他で書き換えられたら自動で読み直す +set whichwrap=b,s,h,l,<,>,[,] " カーソルを行頭、行末で止まらないようにする +set scrolloff=5 " スクロール時の余白確保 + +"カーソルを表示行で移動する。物理行移動は, +:nnoremap j gj +:nnoremap k gk +:nnoremap gj +:nnoremap gk + +" +set showmatch " 括弧の対応をハイライト +set number " 行番号表示 + +" +let g:gitCurrentBranch = '' +function! CurrentGitBranch() + let cwd = getcwd() + cd %:p:h + let branch = matchlist(system('/usr/bin/env git branch -a --no-color'), '\v\* ([0-9A-Za-z\/]*)\r?\n') + execute 'cd ' . cwd + if (len(branch)) + let g:gitCurrentBranch = '[git:' . branch[1] . ']' + else + let g:gitCurrentBranch = '' + endif + return g:gitCurrentBranch +endfunction + +autocmd BufEnter * :call CurrentGitBranch() + +set laststatus=2 +" ステータスラインの表示 +set statusline=%< " 行が長すぎるときに切り詰める位置 +set statusline+=[%n] " バッファ番号 +set statusline+=%m " %m 修正フラグ +set statusline+=%r " %r 読み込み専用フラグ +set statusline+=%h " %h ヘルプバッファフラグ +set statusline+=%w " %w プレビューウィンドウフラグ +set statusline+=%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'} " fencとffを表示 +set statusline+=%y " バッファ内のファイルのタイプ +set statusline+=\ " 空白スペース +if winwidth(0) >= 130 + set statusline+=%F " バッファ内のファイルのフルパス +else + set statusline+=%t " ファイル名のみ +endif +set statusline+=%= " 左寄せ項目と右寄せ項目の区切り +set statusline+=%{g:gitCurrentBranch} " Gitのブランチ名を表示 +set statusline+=\ \ " 空白スペース2個 +set statusline+=%1l " 何行目にカーソルがあるか +set statusline+=/ +set statusline+=%L " バッファ内の総行数 +set statusline+=, +set statusline+=%c " 何列目にカーソルがあるか +set statusline+=%V " 画面上の何列目にカーソルがあるか +set statusline+=\ \ " 空白スペース2個 +set statusline+=%P " ファイル内の何%の位置にあるか + +" +set tabstop=2 +set expandtab " tab をスペースに展開 +set shiftwidth=2 " 自動インデントの幅 +set softtabstop=2 + +autocmd FileType make setlocal noexpandtab + +" Undo highlights of the search results, when push ESC + ESC +:nnoremap :nohlsearch + +" 横分割時は下へ、 縦分割時は右へ新しいウィンドウが開くようにする +set splitbelow +set splitright + +" +" === 行末のスペースを削除 === +" 保存時に行末の空白を除去する +autocmd BufWritePre * :%s/\s\+$//ge + +" === カーソル行をハイライト === +set cursorline +" カレントウィンドウにのみ罫線を引く +augroup cch + autocmd! cch + autocmd WinLeave * set nocursorline + autocmd WinEnter,BufRead * set cursorline +augroup END + +:hi clear CursorLine +:hi CursorLine gui=underline +highlight CursorLine ctermbg=black guibg=black + +" === Shebang がある時に実行権限を自動付与=== +autocmd BufWritePost * :call AddExecmod() + +function AddExecmod() + let line = getline(1) + if strpart(line, 0, 2) == "#!" + call system("chmod +x ". expand("%")) + endif +endfunction + +" === change the current directory === +augroup grlcd + autocmd! + autocmd BufEnter * lcd %:p:h +augroup END + +" === template === +augroup templateload + autocmd! + autocmd BufNewFile *.sh 0r ~/.vim/template/skelton.sh + autocmd BufNewFile *.pl 0r ~/.vim/template/skelton.pl + autocmd BufNewFile *.scm 0r ~/.vim/template/skelton.scm + autocmd BufNewFile test_*.rb 0r ~/.vim/template/skelton_test.rb + autocmd BufNewFile *.rb 0r ~/.vim/template/skelton.rb +augroup END + +" === IME === + +" 挿入モード終了時に IME 状態を保存しない +inoremap +inoremap + +" 「日本語入力固定モード」切り替えキー +inoremap + +" === indent-guide === +let g:indent_guides_auto_colors = 0 +let g:indent_guides_guide_size = 1 +let g:indent_guides_enable_on_vim_startup = 1 + +autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=LightBlue ctermbg=3 +autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=darkgrey ctermbg=4 + +" === simple-javascript-indenter === +" shiftwidthを1にしてインデントしてくれる +let g:SimpleJsIndenter_BriefMode = 1 +" この設定入れるとswitchのインデントがいくらかマシに +let g:SimpleJsIndenter_CaseIndentLevel = -1 + +" === highlight the string under the cursol === +highlight CurrentWord cterm=underline ctermbg=NONE ctermfg=DarkMagenta + +function! s:EscapeText( text ) + return substitute( escape(a:text, '\' . '^$.*[~'), "\n", '\\n', 'ge' ) +endfunction + +function! s:GetCurrentWord() + let l:cword = expand('') + if !empty(l:cword) + let l:regexp = s:EscapeText(l:cword) + if l:cword =~# '^\k\+$' + let l:regexp = '\<' . l:regexp . '\>' + endif + return l:regexp + else + return '' + endif +endfunction + +function! s:HighlightCurrentWord() + let l:word = s:GetCurrentWord() + if !empty(l:word) + if exists("w:current_match") + call matchdelete(w:current_match) + endif + let w:current_match = matchadd('CurrentWord', l:word, 0) + endif +endfunction + +augroup cwh + autocmd! + autocmd CursorMoved,CursorMovedI * call s:HighlightCurrentWord() +augroup END + +let g:ale_sign_error = '!!' +let g:ale_sign_warning = '==' +let g:ale_sign_column_always = 1 +let g:ale_echo_msg_error_str = 'E' +let g:ale_echo_msg_warning_str = 'W' +let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' diff --git a/.zsh.d/.zshrc b/.zsh.d/.zshrc new file mode 100644 index 0000000..91dbebb --- /dev/null +++ b/.zsh.d/.zshrc @@ -0,0 +1,7 @@ +if [ -d $ZDOTDIR -a -r $ZDOTDIR -a \ + -x $ZDOTDIR ]; then + for i in $ZDOTDIR/*; do + [[ ${i##*/} = *.zsh ]] && + [ \( -f $i -o -h $i \) -a -r $i ] && . $i + done +fi diff --git a/.zsh.d/alias.zsh b/.zsh.d/alias.zsh new file mode 100644 index 0000000..3ac18f3 --- /dev/null +++ b/.zsh.d/alias.zsh @@ -0,0 +1,25 @@ +: Aliases && { + alias ls="ls -h" + alias ll="ls -ahl" + alias cp="cp -p" + alias ld="ls -hl | grep ^d" + + alias screen='screen -U -D -RR' + alias tmux="if tmux has; then tmux attach -d; else tmux new; fi" + + # Settings depending on the OSes + case ${OSTYPE} in + darwin*) + # For Mac + alias eject='drutil eject' + # vim + alias vi='/usr/local/bin/vim' + ;; + + linux*) + # For Linux only + alias aptitude='sudo aptitude' + alias apt='sudo apt' + ;; + esac +} diff --git a/.zsh.d/direnv.zsh b/.zsh.d/direnv.zsh new file mode 100644 index 0000000..ffc2aa6 --- /dev/null +++ b/.zsh.d/direnv.zsh @@ -0,0 +1,7 @@ +which direnv > /dev/null +RC=$? + +if [ $RC -eq 0 ]; then + export EDITOR=/usr/bin/vim + eval "$(direnv hook zsh)" +fi diff --git a/.zsh.d/fzf.zsh b/.zsh.d/fzf.zsh new file mode 100644 index 0000000..b607be9 --- /dev/null +++ b/.zsh.d/fzf.zsh @@ -0,0 +1,7 @@ +# Setup fzf +# --------- +if [[ ! "$PATH" == */home/kazu634/.fzf/bin* ]]; then + export PATH="${PATH:+${PATH}:}/home/kazu634/.fzf/bin" + export FZF_DEFAULT_OPTS='--color=fg+:11 --cycle --reverse --height=80% --exit-0 --bind=ctrl-j:accept --no-sort' +fi + diff --git a/.zsh.d/general.zsh b/.zsh.d/general.zsh new file mode 100644 index 0000000..5466aa0 --- /dev/null +++ b/.zsh.d/general.zsh @@ -0,0 +1,62 @@ +: Lang && { + export LANG=ja_JP.UTF-8 +} + +: Direcotry && { + setopt auto_pushd + setopt PUSHD_IGNORE_DUPS +} + +: Key Bind && { + bindkey -e +} + +: Color && { + autoload -U colors + colors +} + + +: General completion && { + autoload -U compinit + compinit + + setopt correct + + zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' + # 補完メニューをカーソルで選択可能にする。 + zstyle ':completion:*:default' menu select=1 + # カレントに候補が無い場合のみcdpath 上のディレクトリが候補となる + zstyle ':completion:*:cd:*' tag-order local-directories path-directories + # 補完でキャッシュを有効にする + zstyle ':completion:*' use-cache true + # 補完時のファイル名を黄色で表示 + zstyle ':completion:*' list-colors di=33 fi=0 + + setopt list_packed # 補完候補をつめて表示する + setopt auto_menu # TAB で順に補完候補を切り替える + setopt auto_list # 複数の補完候補があったときに、そのリストを自動的に表示 + setopt complete_in_word # 補完開始時にカーソルは単語の終端になくても良い。 + setopt list_types # 種類を示すマーク表示をつける(ls -fと同じもの) + setopt auto_param_keys # カッコの対応などを自動的に補完 + setopt auto_param_slash # ディレクトリ名の補完で末尾の / を自動的に付加し、次の補完に備える +} + +: Prediction && { + autoload predict-on + predict-on +} + +: History && { + HISTFILE=$HOME/.zhistory + HISTSIZE=100000 + SAVEHIST=100000 + + setopt hist_no_store hist_ignore_dups hist_reduce_blanks hist_ignore_space + setopt incappendhistory sharehistory + setopt extended_history + setopt hist_ignore_all_dups extended_history + setopt hist_save_no_dups + + function history-all { history -E 1 } +} diff --git a/.zsh.d/git.zsh b/.zsh.d/git.zsh new file mode 100644 index 0000000..fe6267b --- /dev/null +++ b/.zsh.d/git.zsh @@ -0,0 +1,13 @@ +: git-completion && { + autoload bashcompinit + bashcompinit + + case ${OSTYPE} in + linux*) + # for Linux + if [ -f ~/.git-completion.bash ]; then + source ~/.git-completion.bash + fi + ;; + esac +} diff --git a/.zsh.d/goenv.zsh b/.zsh.d/goenv.zsh new file mode 100644 index 0000000..a1f7ab3 --- /dev/null +++ b/.zsh.d/goenv.zsh @@ -0,0 +1,22 @@ +# === go === +case ${OSTYPE} in + darwin*) + # For Mac only + export GOPATH="$HOME/work/go" + export PATH="$GOPATH/bin:$PATH" + ;; + linux*) + # for Linux Only + if [ -e ${HOME}/.goenv/bin/goenv ]; then + export GOENV_ROOT="$HOME/.goenv" + export GOPATH="$HOME/works/mnt/go" + export PATH="$GOENV_ROOT/bin:$GOPATH/bin:$PATH" + + export GOENV_DISABLE_GOPATH=1 + + eval "$(goenv init -)" + + export PATH="$GOROOT/bin:$PATH" + fi +esac + diff --git a/.zsh.d/node.zsh b/.zsh.d/node.zsh new file mode 100644 index 0000000..99d71db --- /dev/null +++ b/.zsh.d/node.zsh @@ -0,0 +1,9 @@ +# === nodebrew === +case ${OSTYPE} in + *) + if [ -e /${HOME}/.nodebrew/nodebrew ]; then + PATH=${HOME}/.nodebrew/current/bin:${PATH} + export PATH + fi + ;; +esac diff --git a/.zsh.d/path.zsh b/.zsh.d/path.zsh new file mode 100644 index 0000000..03db188 --- /dev/null +++ b/.zsh.d/path.zsh @@ -0,0 +1,11 @@ +# === Path === +case ${OSTYPE} in + darwin*) + # For Mac only + export PATH=/Users/kazu634/bin:$PATH + ;; + linux*) + # For Linux only + export PATH=/home/kazu634/bin:$PATH + ;; +esac diff --git a/.zsh.d/plugin.zsh b/.zsh.d/plugin.zsh new file mode 100644 index 0000000..a7e9691 --- /dev/null +++ b/.zsh.d/plugin.zsh @@ -0,0 +1,17 @@ +source ~/.zplug/init.zsh + +zplug "zsh-users/zsh-syntax-highlighting", defer:2 +zplug "zsh-users/zsh-completions" +zplug "zsh-users/zsh-autosuggestions" + + +# Install plugins if there are plugins that have not been installed +if ! zplug check --verbose; then + printf "Install? [y/N]: " + if read -q; then + echo; zplug install + fi +fi + +# Then, source plugins and add commands to $PATH +zplug load --verbose diff --git a/.zsh.d/prompt.zsh b/.zsh.d/prompt.zsh new file mode 100644 index 0000000..4ae5ec1 --- /dev/null +++ b/.zsh.d/prompt.zsh @@ -0,0 +1,7 @@ +: Prompt && { + : Starshipを利用したpromptのカスタマイズ && { + if which starship > /dev/null ; then + eval "$(starship init zsh)" + fi + } +} diff --git a/.zsh.d/rbenv.zsh b/.zsh.d/rbenv.zsh new file mode 100644 index 0000000..d333a5b --- /dev/null +++ b/.zsh.d/rbenv.zsh @@ -0,0 +1,10 @@ +# === rbenv === +case ${OSTYPE} in + *) + # for Linux Only + if [ -e ${HOME}/.rbenv/bin/rbenv ]; then + export PATH="${HOME}/.rbenv/bin:${PATH}" + eval "$(rbenv init - zsh)" + fi + ;; +esac diff --git a/.zsh.d/util.zsh b/.zsh.d/util.zsh new file mode 100644 index 0000000..1cb0446 --- /dev/null +++ b/.zsh.d/util.zsh @@ -0,0 +1,116 @@ +: chpwd内のlsでファイル数が多い場合に省略表示する +: http://qiita.com/yuyuchu3333/items/b10542db482c3ac8b059 && { + chpwd() { + ls_abbrev + } + + ls_abbrev() { + # -a : Do not ignore entries starting with .. + # -C : Force multi-column output. + # -F : Append indicator (one of */=>@|) to entries. + local cmd_ls='ls' + local -a opt_ls + opt_ls=('-aCF' '--color=always') + case "${OSTYPE}" in + freebsd*|darwin*) + if type gls > /dev/null 2>&1; then + cmd_ls='gls' + else + # -G : Enable colorized output. + opt_ls=('-aCFG') + fi + ;; + esac + + local ls_result + ls_result=$(CLICOLOR_FORCE=1 COLUMNS=$COLUMNS command $cmd_ls ${opt_ls[@]} | sed $'/^\e\[[0-9;]*m$/d') + + local ls_lines=$(echo "$ls_result" | wc -l | tr -d ' ') + + if [ $ls_lines -gt 10 ]; then + echo "$ls_result" | head -n 5 + echo '...' + echo "$ls_result" | tail -n 5 + echo "$(command ls -1 -A | wc -l | tr -d ' ') files exist" + else + echo "$ls_result" + fi + } +} + +: cdr + fzf setting && { + : 前提条件 && { + autoload -Uz add-zsh-hook + autoload -Uz chpwd_recent_dirs cdr + add-zsh-hook chpwd chpwd_recent_dirs + } + + : cdr の設定 && { + zstyle ':completion:*' recent-dirs-insert both + zstyle ':chpwd:*' recent-dirs-max 500 + zstyle ':chpwd:*' recent-dirs-default true + zstyle ':chpwd:*' recent-dirs-file "$HOME/.cache/chpwd-recent-dirs" + zstyle ':chpwd:*' recent-dirs-pushd true + } + + : 関数の定義 && { + if which fzf > /dev/null; then + function fzf-cdr () { + my-compact-chpwd-recent-dirs + + local selected_dir=$(cdr -l | awk '{ print $2 }' | fzf) + if [ -n "$selected_dir" ]; then + BUFFER="cd ${selected_dir}" + zle accept-line + fi + zle clear-screen + } + + zle -N fzf-cdr + bindkey '^x' fzf-cdr + fi + } + + : メンテナンス && { + # http://blog.n-z.jp/blog/2014-07-25-compact-chpwd-recent-dirs.html + function my-compact-chpwd-recent-dirs () { + emulate -L zsh + setopt extendedglob + local -aU reply + integer history_size + autoload -Uz chpwd_recent_filehandler + chpwd_recent_filehandler + history_size=$#reply + reply=(${^reply}(N)) + (( $history_size == $#reply )) || chpwd_recent_filehandler $reply + } + } +} + +: history + fzf function && { + # use `fzf` to see the history: + if which fzf > /dev/null; then + # statements + function fzf-select-history() { + local tac + + if which tac > /dev/null; then + tac="tac" + else + tac="tail -r" + fi + + BUFFER=$(history -n 1 | \ + eval $tac | \ + awk '!a[$0]++' | \ + fzf --query "$LBUFFER") + + CURSOR=$#BUFFER + zle clear-screen + } + + zle -N fzf-select-history + + bindkey '^r' fzf-select-history + fi +} diff --git a/.zshenv b/.zshenv new file mode 100644 index 0000000..62a7d2d --- /dev/null +++ b/.zshenv @@ -0,0 +1 @@ +export ZDOTDIR=$HOME/.zsh.d diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc74c84 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# ドットファイルの設定 +各種設定ファイルをまとめました。 + +* .gitconfig +* .gitignore +* .screenrc +* .screenrc.swp +* .vimrc +* .zshenv +* .zshrc +* install.sh + +## .gitconfig +Git用の設定ファイル。 + +* https://gist.github.com/4117588 +* http://oli.jp/2012/git-powerup/ + +## .vimrc +vim用の設定ファイル。 \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..e3f888a --- /dev/null +++ b/install.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# finding out the shell script directory +CURDIR=`dirname $0` + +# finding out the OS type +OS=`uname` + +if [ ${CURDIR} = "." ]; then + CURDIR=`pwd` +fi + +# judging the OS type +if [ ${OS} = "Linux" ]; then # if linux + # copying the .files as a soft link + find ${CURDIR} -maxdepth 1 -type f -name ".*" ! -name ".*.swp" -print0 | xargs -0 -I % ln -f -s % ${HOME} 2>/dev/null + + # copying the `.zsh.d` configuration file as a soft link + ln -f -s ${CURDIR}/.zsh.d ${HOME} + +else # otherwise (meaning Darwin) + # copying the .files as a soft link + find ${CURDIR} -type f -name ".*" ! -name ".*.swp" -maxdepth 1 -print0 | xargs -0 -J % ln -f -s % ${HOME} 2>/dev/null + + # copying the `.zsh.d` configuration file as a soft link + ln -f -s ${CURDIR}/.zsh.d ${HOME} +fi