LoginSignup
49
53

More than 5 years have passed since last update.

dotfilesをキレイキレイするついでに晒す

Posted at

はじめに

この記事は チームスピリット Advent Calendar 2017 の17日目の記事です。
クリスマスも近いので少し早い気もしますが私の dotfiles を晒します。

使っているもの

macOS/Ubuntu

そろそろ自宅のPCも macOS にしたいんですが、時期 Mac mini はいつ発表されるんでしょうねえ。

Homebrew/Linuxbrew

macOS で Homebrew を使っているユーザーは多いと思うのですが、Linux派生OSでも Linuxbrew で管理すると捗ります。
パッケージがユーザーインストールになるので管理が容易ですし、頻繁にインストールスクリプトが更新されています。(あるいは自動的に最新版を取得するように設定されている。)

FantasqueSansMono Nerd Font

私は飽き性なのでターミナルのフォントはコロコロ変えているのですが、これは一番飽きなかったフォントです。

OneDark

OneDark

カラースキームはOneDarkが非常に気に入りました。Atom 専用テーマにインスパイヤされて幅広く使われているカラースキームです。
下記のVimのプラグインはVimのカラースキームだけでなく、端末の設定済みプロファイルも配布しているので愛用しています。

joshdick/onedark.vim: A dark Vim/Neovim color scheme inspired by Atom's One Dark syntax theme.

dotfiles

zsh

シェルは zsh を使っています。理由としてはプラグインが豊富であることです。

zplugin

プラグインマネージャーは zplug から zplugin に乗り換えました。

理由としては、 zplugin はダウンロードしたプラグインやスニペットを zcompile するので、プラグインのロードが圧倒的に早いです。(zplugin 自体も zcompile されます。)
また autoload するファイルを一箇所に纏めたり、補完のロードを一箇所に纏めていたりと、ロードの高速化に余念がありません。そして現在も速いペースで進化しています。

zdharma/zplugin: Uber-flexible Zsh plugin manager with clean fpath, reports, completion management, multiple sites support

ディレクトリ構成

├── .jira.d
├── .SpaceVim.d
│   ├── init.vim
│   ├── snippets
│   └── template
├── .tig
│   └── rc
│       ├── large-repo.tigrc
│       └── vim.tigrc
├── .zsh
│   ├── completions
│   ├── functions
│   └── rc
│       ├── 10_utilities.zsh
│       ├── 20_key-bindings.zsh
│       ├── 30_aliases.zsh
│       ├── 50_options.zsh
│       ├── 70_misc.zsh
│       ├── 80_custom.zsh
│       ├── exports.rc.zsh
│       └── tmux.rc.zsh
├── bin
├── .editorconfig
├── .gemrc
├── .gitconfig
├── .gitignore-global
├── .globalrc
├── .ideavimrc
├── .importjs.js
├── .tigrc
├── .tmux.conf
├── .zshenv
├── .zshrc
├── Brewfile
├── Gemfile
├── README.md
├── config.toml
├── requirements.txt
└── requirements3.txt

.zshrc

基本的に外部ソースファイルの管理には zplugin を使い、自分の設定がプラグインのロードによって上書かれない順序で読み込みます。

.zshrc
# (省略)

if [[ -z "$TMUX" ]] && [[ -z "$STY" ]]
then
  # tmux が起動していなければ起動します。
  # tmux を起動した場合は tmux.rc.zsh の中で exit を呼ぶので、このコードブロックの外側は実行されません。
  . "${HOME}/.zsh/rc/exports.rc.zsh"
  . "${HOME}/.zsh/rc/tmux.rc.zsh"
fi

zmodload zsh/zpty

# anyenv がコマンドとして実行可能であれば anyenv を初期化します。
if [[ "${+commands[anyenv]}" == 1 ]]
then
  eval "$(anyenv init - zsh)"
fi

autoload -Uz compinit

# zplugin をロードします。
. "${HOME}/.zplugin/bin/zplugin.zsh"

# zplugin のコマンド補完をロードします。
autoload -Uz _zplugin

# プラグインが使うコマンドをこのタイミングで autoload しておきます。
autoload -Uz add-zsh-hook
autoload -Uz cdr
autoload -Uz chpwd_recent_dirs

if [[ "${+_comps}" == 1 ]]
then
  _comps[zplugin]=_zplugin
fi

# zplugin: Utilities {{{
# OS間のクリップボードの差異を吸収するコマンドを定義する oh-my-zsh のスニペットをロードします。
zplugin snippet 'OMZ::lib/clipboard.zsh'
zplugin snippet "${HOME}/.zsh/rc/10_utilities.zsh"

# (省略)
# fzf を利用した補完のキーバインドを設定するスニペットをロードします。
# Homebrew で fzf がインストールされている、かつ HOMEBREW_PREFIX に Homebrew のプリフィックスが格納されていることが前提です。
zplugin snippet "${HOMEBREW_PREFIX}/opt/fzf/shell/key-bindings.zsh"
# 自分のキーバインド設定をここで読み込みます。
zplugin snippet "${HOME}/.zsh/rc/20_key-bindings.zsh"

# 自分のエイリアス設定をここで読み込みます。
zplugin snippet "${HOME}/.zsh/rc/30_aliases.zsh"

# zsh の補完を使いやすく設定する oh-my-zsh のスニペットをロードします。
zplugin snippet 'OMZ::lib/completion.zsh'
zplugin snippet 'OMZ::lib/compfix.zsh'
# (省略)
# 自分の zsh オプション設定をここで読み込みます。
zplugin snippet "${HOME}/.zsh/rc/50_options.zsh"

# プラグインの設定などをここで読み込みます。
zplugin snippet "${HOME}/.zsh/rc/70_misc.zsh"

# 自分のコマンド定義などをここで読み込みます。
zplugin snippet "${HOME}/.zsh/rc/80_custom.zsh"
# }}}

# zplugin: Plugins {{{

# djui/alias-tips {{{
export ZSH_PLUGINS_ALIAS_TIPS_TEXT='alias-tips: '
# }}}

# fzf で絵文字を検索&入力ためのプラグインです。
zplugin light 'b4b4r07/emoji-cli'
# 利用可能なエイリアスを使わずにコマンドを実行した際に通知するプラグインです。
zplugin light 'djui/alias-tips'
# fzf を使ったウィジェットが複数バンドルされたプラグインです。
zplugin light 'mollifier/anyframe'
# 作業中のGitのルートディレクトリまでジャンプするコマンドを定義するプラグインです。
# cd-gitroot コマンドをエイリアスで U に割り当てています。
zplugin light 'mollifier/cd-gitroot'
# tmux のウィンドウを作業中のGitレポジトリ名に応じて自動的にリネームしてくれるプラグインです。(自分で作った)
zplugin light 'sei40kr/zsh-tmux-rename'
# ls よりも使いやすく見やすいディレクトリの一覧表示のコマンドを定義するプラグインです。
zplugin ice pick'k.sh'
zplugin light 'supercrabtree/k'

# 作業ディレクトリに .env ファイルがあった場合に自動的にロードしてくれます。
zplugin snippet 'OMZ::plugins/dotenv/dotenv.plugin.zsh'
# コマンド入力待ち状態から control-Z で suspend したプロセスに復帰するキーバインドを設定するプラグインです。
zplugin snippet 'OMZ::plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh'
# Gitの補完と大量のエイリアスを定義するプラグインです。
# エイリアスは重宝するものが多く、Gitを使うユーザーには必ずオススメしたいプラグインです。
zplugin snippet 'OMZ::plugins/git/git.plugin.zsh'
# GitHub のレポジトリを管理するためのコマンドを定義するプラグインです。
zplugin snippet 'OMZ::plugins/github/github.plugin.zsh'
# 非GNU系OSにインストールしたGNU系ツールをプリフィックスなしで使えるようにするプラグインです。
zplugin snippet 'OMZ::plugins/gnu-utils/gnu-utils.plugin.zsh'
# .zshrc を zcompile してロードしてくれる src コマンドを定義するプラグインです。
zplugin snippet 'OMZ::plugins/zsh_reload/zsh_reload.plugin.zsh'
# }}}

# zplugin: Commands {{{
# Go で書かれたツール群を並列ダウンロード&ビルド&インストールしてくれます。
zplugin ice from'gh-r' as'command' mv'gotcha_* -> gotcha'
zplugin light 'b4b4r07/gotcha'

# (省略)

# mosh や ssh でリモートのシェルに自分の rc ファイルをロードします。
zplugin snippet --command \
    'https://raw.githubusercontent.com/Russell91/sshrc/master/moshrc'
zplugin snippet --command \
    'https://raw.githubusercontent.com/Russell91/sshrc/master/sshrc'
# git diif や tig の可読性をより良くします。(要設定)
# Homebrew で git をインストールしていること、 `HOMEBREW_PREFIX` に Homebrew のプリフィックスが格納されている前提です。
zplugin snippet --command \
    "${HOMEBREW_PREFIX}/share/git-core/contrib/diff-highlight/diff-highlight"
# }}}

# zplugin: Completions {{{
# プラグインの中に含まれているコマンド補完のみを zplugin で管理します。
# 想定された zplugin の使い方ではないかもしれません。
zplugin ice pick''
zplugin light 'jsforce/jsforce-zsh-completions'
zplugin ice pick''
zplugin light 'zsh-users/zsh-completions'
# }}}

compinit
zplugin cdreplay -q

# zplugin: Plugins loaded after compinit {{{
# コマンドをハイライトするプラグインを遅延ロードします。
zplugin ice wait'1' atload'_zsh_highlight'
zplugin light 'zdharma/fast-syntax-highlighting'
# コマンドをサジェストするプラグインを遅延ロードします。
zplugin ice wait'1' atload'_zsh_autosuggest_start'
zplugin light 'zsh-users/zsh-autosuggestions'

# プロンプトのテーマを遅延ロードします。このプラグインのみロード完了後にプロンプトを再描画しています。
zplugin ice pick'spaceship.zsh' wait'!0'
zplugin light 'denysdovhan/spaceship-zsh-theme'
# }}}

.zsh/rc/20_key-bindings.zsh

20_key-bindings.zsh
# (省略)

# alt + 矢印でキャレットを単語間で移動するキーバインドを定義しておきます。
# alt + F/B で慣れてしまったので不要かもしれない。
bindkey '^[[1;3C' forward-word
bindkey '^[[1;3D' backward-word

# (anyframe の設定)

.zsh/rc/30_aliases.zsh

基本的に oh-my-zsh のプラグインにあるエイリアス設定を参考にしています。
プラグインには不必要な挙動があったり、コマンド名との重複( rgalias rg='rake generate' )があったりするので、その場合はここで定義しています。

30_aliases.zsh
# (省略)

# brew {{{
alias brews='brew list -1'
alias bubo='brew update && brew outdated'
alias bubc='brew upgrade && brew cleanup'
alias bubu='bubo && bubc'
# }}}

# bundler {{{
alias be='bundle exec'
alias bl='bundle list'
alias bp='bundle package'
alias bo='bundle open'
alias bout='bundle outdated'
alias bu='bundle update'
alias bi='bundle_install'
alias bcn='bundle clean'
# }}}

# common-aliases {{{
alias zshrc='$EDITOR ~/.zshrc'

alias t='tail -f'

alias dud='du -d 1 -h'
alias duf='du -sh *'
alias fd='bfs . -type d -name'
alias ff='bfs . -type f -name'

alias h='history'
alias help='man'
alias p='ps -f'
alias sortnr='sort -n -r'
alias unexport='unset'
# }}}

# directories {{{
alias u='builtin cd ..'

alias md='mkdir -p'
alias rd='rmdir'
# }}}

# docker-compose {{{
alias dco='docker-compose'

alias dcb='docker-compose build'
alias dce='docker-compose exec'
alias dcps='docker-compose ps'
alias dcrestart='docker-compose restart'
alias dcrm='docker-compose rm'
alias dcr='docker-compose run'
alias dcstop='docker-compose stop'
alias dcup='docker-compose up'
alias dcdn='docker-compose down'
alias dcl='docker-compose logs'
alias dclf='docker-compose logs -f'
# }}}

# gem {{{
alias gemb='gem build *.gemspec'
alias gemp='gem push *.gem'
# }}}

# golang {{{
alias gob='go build'
alias goc='go clean'
alias god='go doc'
alias gof='go fmt'
alias gofa='go fmt . ./...'
alias gog='go get'
alias goi='go install'
alias gol='go list'
alias gor='go run'
alias got='go test'
alias gov='go vet'
# }}}

# jonas/tig {{{
alias tis='tig status'
alias til='tig log'
alias tib='tig blame -C'
# }}}

# mvn {{{
alias mvncie='mvn clean install eclipse:eclipse'
alias mvnci='mvn clean install'
alias mvncist='mvn clean install -DskipTests'
alias mvncisto='mvn clean install -DskipTests --offline'
alias mvne='mvn eclipse:eclipse'
alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
alias mvncv='mvn clean verify'
alias mvnd='mvn deploy'
alias mvnp='mvn package'
alias mvnc='mvn clean'
alias mvncom='mvn compile'
alias mvnct='mvn clean test'
alias mvnt='mvn test'
alias mvnag='mvn archetype:generate'
alias mvn-updates='mvn versions:display-dependency-updates'
alias mvntc7='mvn tomcat7:run'
alias mvntc='mvn tomcat:run'
alias mvnjetty='mvn jetty:run'
alias mvndt='mvn dependency:tree'
alias mvns='mvn site'
alias mvnsrc='mvn dependency:sources'
alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
# }}}

# npm {{{
alias npmg="npm i -g "
alias npmS="npm i -S "
alias npmD="npm i -D "
alias npmE='PATH="$(npm bin)":"$PATH"'
alias npmO="npm outdated"
alias npmV="npm -v"
alias npmL="npm list"
alias npmL0="npm ls --depth=0"
alias npmst="npm start"
alias npmt="npm test"
alias npmR="npm run"
alias npmP="npm publish"
# }}}

# nvim {{{
alias vim='nvim'
# }}}

# perl {{{
alias pbi='perlbrew install'
alias pbl='perlbrew list'
alias pbo='perlbrew off'
alias pbs='perlbrew switch'
alias pbu='perlbrew use'

alias pd='perldoc'

alias ple='perl -wlne'
# }}}

# python {{{
alias pyfind='bfs . -name "*.py"'
# }}}

# postgres {{{
alias startpost='pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start'
alias stoppost='pg_ctl -D /usr/local/var/postgres stop -s -m fast'
alias restartpost='stoppost && sleep 1 && startpost'
alias reloadpost='pg_ctl reload -D /usr/local/var/postgres -s'
alias statuspost='pg_ctl status -D /usr/local/var/postgres -s'
# }}}

# rails {{{
alias devlog='tail -f log/development.log'
alias prodlog='tail -f log/production.log'
alias testlog='tail -f log/test.log'

alias -g RED='RAILS_ENV=development'
alias -g REP='RAILS_ENV=production'
alias -g RET='RAILS_ENV=test'

alias rc='rails console'
alias rcs='rails console --sandbox'
alias rd='rails destroy'
alias rdb='rails dbconsole'
alias rgm='rails generate migration'
alias rp='rails plugin'
alias ru='rails runner'
alias rs='rails server'
alias rsd='rails server --debugger'
alias rsp='rails server --port'

alias rdm='rake db:migrate'
alias rdms='rake db:migrate:status'
alias rdr='rake db:rollback'
alias rdc='rake db:create'
alias rds='rake db:seed'
alias rdd='rake db:drop'
alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone'
alias rdsl='rake db:schema:load'
alias rlc='rake log:clear'
alias rn='rake notes'
alias rr='rake routes'
alias rt='rake test'
alias rmd='rake middleware'
alias rsts='rake stats'
# }}}

# rake {{{
alias rake='noglob rake'
alias brake='noglob bundle exec rake'
alias srake='noglob sudo rake'
alias sbrake='noglob sudo bundle exec rake'
# }}}

# react-native {{{
alias rn='react-native'
alias rns='react-native start'
alias rnlink='react-native link'

alias rnand='react-native run-android'
alias rnios='react-native run-ios'
alias rnios4s='react-native run-ios --simulator "iPhone 4s"'
alias rnios5='react-native run-ios --simulator "iPhone 5"'
alias rnios5s='react-native run-ios --simulator "iPhone 5s"'
alias rnios6='react-native run-ios --simulator "iPhone 6"'
alias rnios6s='react-native run-ios --simulator "iPhone 6s"'

alias rnland='react-native log-android'
alias rnlios='react-native log-ios'
# }}}

# rsync {{{
alias rsync-copy="rsync -avz --progress -h"
alias rsync-move="rsync -avz --progress -h --remove-source-files"
alias rsync-update="rsync -avzu --progress -h"
alias rsync-synchronize="rsync -avzu --delete --progress -h"
# }}}

# yarn {{{
alias y="yarn "
alias ya="yarn add"
alias ycc="yarn cache clean"
alias yh="yarn help"
alias yo="yarn outdated"
alias yui="yarn upgrade-interactive"
# }}}

# zmv {{{
alias zmv='noglob zmv'
# }}}

# mollifier/anyframe {{{
alias U='cd-gitroot'
# }}}

.zsh/rc/50_options.zsh

50_options.zsh
setopt append_history
setopt auto_cd
setopt auto_list
setopt auto_menu
setopt auto_pushd
setopt auto_param_keys
setopt auto_param_slash
setopt auto_resume
setopt equals
setopt extended_history
setopt glob_dots
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt hist_reduce_blanks
setopt interactive_comments
setopt no_beep
setopt numeric_glob_sort
setopt print_eight_bit
setopt prompt_subst
setopt pushd_ignore_dups
setopt share_history
unsetopt list_beep

.zsh/rc/70_misc.zsh

70_misc.zsh
# (省略)

# fzf のデフォルトコマンドに rg を採用し、 .git/ 以下を除外しています。
# junegunn/fzf {{{
FZF_DEFAULT_COMMAND='rg --files --hidden --follow --iglob "!.git/**"'
FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"

if [[ -n "$TMUX" ]]
then
  FZF_TMUX=1
  FZF_TMUX_HEIGHT='25%'
fi
# }}}

# mollifier/anyframe {{{
zstyle ':anyframe:selector:fzf-tmux:' command "fzf-tmux -d ${FZF_TMUX_HEIGHT}"
# }}}

custom

80_custom.zsh
# (修正)

# robbyrussell/oh-my-zsh/colored-man-pages {{{
# 色付きで manual を表示するコマンド (oh-my-zsh の colored-man-pages が元になっています)
# 自分の環境だとうまく動かなかったので微修正を加えています。(どんな修正だったか忘れた)
man() {
  command env \
    LESS_TERMCAP_mb=$(printf "\e[1;31m") \
    LESS_TERMCAP_md=$(printf "\e[1;31m") \
    LESS_TERMCAP_me=$(printf "\e[0m") \
    LESS_TERMCAP_se=$(printf "\e[0m") \
    LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
    LESS_TERMCAP_ue=$(printf "\e[0m") \
    LESS_TERMCAP_us=$(printf "\e[1;32m") \
    _NROFF_U=1 \
    man "$@"
}
# }}}

# mollifier/anyframe {{{
# enhancd で定義した cd コマンドが -- に対応していません。
# zsh ビルトインの cd コマンドを利用するように設定します。
anyframe-widget-cd-ghq-repository() {
  anyframe-source-ghq-repository | \
    anyframe-selector-auto | \
    anyframe-action-execute builtin cd --
}
# }}}

tmux

ターミナル画面を分割するのに、ターミナル純正機能ではなく tmux を愛用しています。
カスタマイズが容易で、環境に依存しない形で実現できることが理由です。

しかし、複数のセッションを使いこなすには脳みそのキャパが足りなかったので、 tmux.rc.zsh で1つのセッションを使いまわすように工夫しています。

tmux.rc.zsh
# (省略)

# Launch tmux
# -----------

if [[ "${+commands[tmux]}" == 1 ]]
then
  tmux has-session -t global 2>/dev/null || tmux new-session -ds global \
      && tmux attach-session -t global
  exit
elif [[ "${commands[screen]}" == 1 ]]
then
  # (省略)
fi

# vi: et sw=2 cc=80

また、判定に時間のかかる(ファイルアクセスを伴うなど)変数は tmux 起動時に定義し、 export するようにしています。

exports.rc.zsh
# (省略)

# Homebrew/Linuxbrew
# ------------------

# Homebrew/Linuxbrew でプリフィックスのパスが違う。
# $(brew --prefix) は時間がかかる処理であるため、ここで判定して HOMEBREW_PREFIX に格納する。
if [[ -d "${HOME}/.linuxbrew" ]]
then
  HOMEBREW_PREFIX="${HOME}/.linuxbrew"
elif [[ -x '/usr/local/bin/brew' ]]
then
  HOMEBREW_PREFIX='/usr/local'
fi

if [[ -n "$HOMEBREW_PREFIX" ]]
then
  # Homebrew の PATH の解決をここで行う。
  export HOMEBREW_PREFIX
  path=( "${HOMEBREW_PREFIX}/bin" "${path[@]}" )

  export XDG_DATA_DIRS="${HOMEBREW_PREFIX}/share:${XDG_DATA_DIRS}"
fi


# anyenv
# ------

if [[ -d "${HOME}/.anyenv" ]]
then
  export ANYENV_ROOT="${HOME}/.anyenv"
  path=( "${ANYENV_ROOT}/bin" "${path[@]}" )
fi


# Golang
# ------

if [[ -d "${HOME}/.go" ]]
then
  export GOPATH="${HOME}/.go"
  path=( "${GOPATH}/bin" "${path[@]}" )
fi

path=(
  "${HOME}/.local/bin"(N-/)
  "${HOME}/.cabal/bin"(N-/)
  "${HOME}/.cargo/bin"(N-/)
  "${path[@]}"
)
export PATH


# Misc
# ----

if [[ -d "${HOME}/.zsh" ]]
then
  fpath=(
    "${HOME}/.zsh/completions"
    "${HOME}/.zsh/functions"
    "${fpath[@]}"
  )
  export FPATH
fi

export XDG_CONFIG_HOME="${HOME}/.config"

# vi: et sw=2 cc=80

tmux のプラグイン管理は tpm を利用しています。

tmux-plugins/tpm: Tmux Plugin Manager

tmux.conf
# Esc の入力遅延を軽減する。
set-option -s escape-time 10
# tmux のペインのフォーカスが移った場合に子プロセスに入力を送る。
set-option -s focus-events on

set-option -g base-index 1
set-option -g bell-action none
# tmux 2.6 以降では reattach-to-user-namespace が不要になった。
# tmux-yank で設定されることを防ぐため、 default-command を上書きする。
set-option -g default-command 'exec "$SHELL" -l'
set-option -g default-terminal 'screen-256color-italic'
set-option -g pane-base-index 1
set-option -g renumber-windows on
set-option -g set-titles on

set-option -ag terminal-overrides ",xterm-256color-italic:Tc"

# tmux-plugins/tmux-pain-control {{{
# 古いキーバインドを削除しておく。
unbind-key '"'
unbind-key %
# }}}

# Configure tpm plugins
set-option -g @plugin 'tmux-plugins/tpm'
set-option -g @plugin 'tmux-plugins/tmux-sensible'
set-option -g @plugin 'tmux-plugins/tmux-copycat'
set-option -g @plugin 'tmux-plugins/tmux-open'
set-option -g @plugin 'tmux-plugins/tmux-pain-control'
set-option -g @plugin 'tmux-plugins/tmux-yank'
set-option -g @plugin 'sei40kr/tmux-fancy-ctrl-space'

run-shell '~/.tmux/plugins/tpm/tpm'

# テーマは気に入ったものが見つからなかったので自前で定義。
set-option -g message-style 'bg=default,fg=default'
set-option -g mode-style 'bg=#3e4452,fg=default'
set-option -g pane-border-style 'fg=#5c6370'
set-option -g pane-active-border-style 'fg=#abb2bf'
set-option -g status-justify centre
set-option -g status-keys vi
set-option -g status-style 'bg=#2c323c,fg=#abb2bf'
set-option -g status-left '[#S]'
set-option -g status-right '%m/%d %a %R'

set-window-option -g mode-keys vi
set-window-option -g window-status-style 'fg=#5c6370'
set-window-option -g window-status-current-style 'fg=#abb2bf'
set-window-option -g xterm-keys on

# Keymap
# ------

# コピーモードでのキーバインドを Vim に近付ける。
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy V select-line
bind-key -t vi-copy C-v rectangle-toggle
bind-key -t vi-copy y copy-selection
bind-key -t vi-copy Y copy-line

anyenv

バージョンマネージャーを管理するマネージャーです。
バージョンマネージャー全般に言えることですが、公式がサポートしている場合を除いて Homebrew でインストールするべきではないです。

riywo/anyenv: all in one for **env

ndenv

Node のバージョン管理に利用しています。
yarn を使う場合は brew install yarn --without-node でインストールするか yarn config delete prefix で設定されたプリフィクスを削除します。(実行時に判別する。)

jenv

Java のバージョン管理に利用しようと思ったのですが、他の env 系とは違い、Javaのインストールができません。
既にインストールされたものを管理するツールになります。インストールからツールで行いたい場合は SDKMAN! を利用したほうが良いです。

SDKMAN! the Software Development Kit Manager

fzf

junegunn/fzf: A command-line fuzzy finder

愛用しているインタラクティブフィルターです。見栄えがよく、キーバインドも直感的なのが決め手です。

ghq

Gitのレポジトリを管理するツールです。 anyframe と合わせて使うことでターミナルでのプロジェクト管理が格段に楽になります。

.gitconfig
[ghq]
  root = ~/dev/ws

SpaceVim

【ほぼ自分語り】僕がVimを使い始めた理由とSpaceVim - Qiita

.SpaceVim.d/init.vim

init.vim
" (省略)
" 

if has('$RBENV_ROOT')
  let g:ruby_host_prog = $RBENV_ROOT . '/shims/ruby'
endif

if has('$PYENV_ROOT')
  let g:python_host_prog = $PYENV_ROOT . '/shims/python2'
  let g:python3_host_prog = $PYENV_ROOT . '/shims/python3'
endif

" リーダーキーを設定する。
let g:mapleader = ';'

" (超省略)

" blueyed/vim-diminactive {{{
" tmux のペインのフォーカスイベントを監視する。
let g:diminactive_enable_focus = 1
" }}}

" elzr/vim-json {{{
" JSON のダブルクォートを非表示にする機能を向こうに。
let g:vim_json_syntax_conceal = 0
" }}}

" joshdick/onedark.vim {{{
" コメント部分をイタリックフォントで表示する。
let g:onedark_terminal_italics = 1
" }}}

" mhinz/vim-signify {{{
" GUI エディタライクな行差分の Gutter 表示を設定する。
let g:gitgutter_sign_added = '▍'
let g:gitgutter_sign_modified = '▍'
let g:gitgutter_sign_modified_removed = '▍'

let g:gitgutter_map_keys = 0

" 行差分の間をジャンプするキーバインドを設定する。
nmap [c <Plug>GitGutterPrevHunk
nmap ]c <Plug>GitGutterNextHunk
" }}}

" othree/javascript-libraries-syntax.vim {{{
" ライブラリに特化したシンタックスハイライトはオススメしない。
let g:used_javascript_libs = ''
" }}}

" Shougo/neosnippet.vim {{{
" これらの言語ではスニペットを無効にし、Emmetに絞る。
let g:neosnippet#disable_runtime_snippets = {
      \ 'html': 1,
      \ 'css': 1,
      \ 'scss': 1,
      \ 'sass': 1,
      \ 'less': 1,
      \ }
" }}}

" thinca/vim-template {{{
" ファイルテンプレートの変数を自動的に展開する。
let g:template_basedir = expand('~/.SpaceVim.d/template')
let g:template_files = 'template.*'

let s:template_user = 'Seong Yong-ju'
let s:template_user_id = '@sei40kr'
let s:template_organization = 'TeamSpirit Inc.'

let s:template_datetime_format = '%Y-%m-%d %H:%M:%S'
let s:template_date_format = '%Y-%m-%d'
let s:template_time_format = '%H:%M:%S'
let s:template_year_format = '%Y'

function! s:template_keywords() abort
  " vint: -ProhibitCommandRelyOnUser -ProhibitCommandWithUnintendedSideEffect
  silent! %s/<+FILE_NAME+>/\=expand('%:t')/g
  silent! %s/<+FILE_BASE_NAME+>/\=expand('%:t:r')/g

  silent! %s/<+USER+>/\=s:template_user/g
  silent! %s/<+USER_ID+>/\=s:template_user_id/g
  silent! %s/<+ORGANIZATION+>/\=s:template_organization/g

  silent! %s/<+DATETIME+>/\=strftime(s:template_datetime_format)/g
  silent! %s/<+DATE+>/\=strftime(s:template_date_format)/g
  silent! %s/<+TIME+>/\=strftime(s:template_time_format)/g
  silent! %s/<+YEAR+>/\=strftime(s:template_year_format)/g
  " vint: +ProhibitCommandRelyOnUser +ProhibitCommandWithUnintendedSideEffect

  if search('<+CURSOR+>')
    execute 'normal! "_da>'
  endif
endfunction
" }}}

" w0rp/ale {{{
" エラー間をジャンプするキーバインドを設定する。
nnoremap <silent> [q :ALEPrevious<CR>
nnoremap <silent> ]q :ALENext<CR>
" }}}

# Vim の背景色を透明に。(ターミナルの背景色をそのまま使う)
augroup SpaceVim_d_colorscheme
  autocmd!
  autocmd ColorScheme onedark call onedark#set_highlight('Normal', {
        \ 'fg': onedark#GetColors().white })
augroup END

augroup SpaceVim_d_tools
  autocmd!
  autocmd User plugin-template-loaded call s:template_keywords()
augroup END

set autochdir
set autoindent expandtab smartindent smarttab
set autoread
set backspace=indent,eol,start
set colorcolumn=80 wrap
set complete& complete-=i
set concealcursor=niv conceallevel=2
set display& display+=lastline
set formatoptions& formatoptions-=ro formatoptions+=j
set history=1000
set hlsearch ignorecase incsearch smartcase wrapscan
set laststatus=2 tabpagemax=50
set list listchars=trail:,extends:,precedes:set nobackup noswapfile nowritebackup
set noerrorbells
set noshowmode
set nrformats-=octal
set ruler
set scrolloff=1 sidescrolloff=5
set wildmenu

nnoremap x "_x

" vim: set et sw=2 cc=80

最後に

ペーストしただけで「この部分無駄なんじゃ」という部分が多々あったので、晒さなくても全体を見直す機会は定期的に欲しいですね。

49
53
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49
53