Skip to content

Instantly share code, notes, and snippets.

@tamago324
Last active October 17, 2020 15:00
Show Gist options
  • Save tamago324/9631880cfd33a08068f6497660bd11ce to your computer and use it in GitHub Desktop.
Save tamago324/9631880cfd33a08068f6497660bd11ce to your computer and use it in GitHub Desktop.
git clone https://git.io/JTcQJ ~/tmp/dotfiles
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zinit-zsh/z-a-rust \
zinit-zsh/z-a-as-monitor \
zinit-zsh/z-a-patch-dl \
zinit-zsh/z-a-bin-gem-node
### End of Zinit's installer chunk
# 追加していく
zinit ice blockf
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
# ASDF
. $HOME/.asdf/asdf.sh
fpath=(${ASDF_DIR}/completions $fpath)
# 色を使えるようにする
autoload -Uz colors
colors
umask 022
#####################################################################
# environment
######################################################################
# https://gihyo.jp/dev/serial/01/zsh-book/0001
# / で単語移動できるようにする (/を抜いた)
# default: *?_-.[]~=/&;!#$%^(){}<>
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
if [ -d "/mnt/c" ]; then
export IS_WSL=1
fi
# 履歴
HISTFILE=$HOME/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
# プロンプト (2行表示)
PROMPT="%{${fg[red]}%}[%n]%{${reset_color}%} %~ %# "
export PATH="$PATH:$HOME/.local/bin"
export PATH="$PATH:$HOME/bin"
# クリップボードの共有のため
export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"
# go get で入れたものを使えるようにする
export PATH="$PATH:$(go env GOPATH)/bin"
# ghq の設定
export GHQ_ROOT="$HOME/.ghq"
# 文字コード
export LANG=ja_JP.UTF-8
# 色の設定
export LSCOLORS=Exfxcxdxbxegedabagacad
# # poetry
# export PATH="$PATH:$HOME/.poetry/bin"
# fpath=($HOME/.zfunc $fpath)
# cargo
source $ASDF_DIR/installs/rust/stable/env
#####################################################################
# zshmodules
######################################################################
zmodload zsh/mathfunc
# for deoplete-zsh
zmodload -a zsh/zpty zpty
zmodload -a zsh/zprof zprof
zmodload -ap zsh/mapfile mapfile
zmodload -aF zsh/stat b:zstat
#####################################################################
# completions
#####################################################################
# 補完を有効にする
if [ -d ~/.zsh/comp ]; then
fpath=(~/.zsh/comp $fpath)
autoload -U ~/.zsh/comp*(:t)
fi
# :completion:function:completer:command:argument:tag
# completion リテラル文字列
# function
# TODO: 理解する
zstyle ':completion:*' group-name ''
zstyle ':completion:*:messages' format '%d'
zstyle ':completion:*:descriptions' format '%d'
zstyle ':completion:*:options' verbose yes
zstyle ':completion:*:values' verbose yes
zstyle ':completion:*:options' prefix-needed yes
# Use cache completion
# apt-get, dpkg (Debian), rpm (Redhat), urpmi (Mandrake), perl -M,
# bogofilter (zsh 4.2.1 >=), fink, mac_apps...
zstyle ':completion:*' use-cache true
zstyle ':completion:*:default' menu select=1
zstyle ':completion:*' matcher-list \
'' \
'm:{a-z}={A-Z}' \
'l:|=* r:|[.,_-]=* r:|=* m:{a-z}={A-Z}'
# sudo completions
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
/usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
zstyle ':completion:*' menu select
zstyle ':completion:*' keep-prefix
zstyle ':completion:*' completer _oldlist _complete _match _ignored \
_approximate _list _history
autoload -Uz compinit
compinit
# cd で検索する対象にいれる
cdpath=($HOME)
# TODO:理解する
zstyle ':completion:*:processes' command "ps -u $USER -o pid,stat,%cpu,%mem,cputime,command"
#####################################################################
# keybinds
######################################################################
# emacs のようなキーバインディング
bindkey -e
#####################################################################
# options
######################################################################
# :Man zshoptions(1)
# -----------
# history
# -----------
# 重複した履歴は保存しない
setopt hist_ignore_dups
# コマンドに付いている余計な空白は削除する
setopt hist_reduce_blanks
# 先頭が空白の実行は履歴に保存しない
setopt hist_ignore_space
# 履歴の実行時刻を保存する (何の意味があるんだろう...)
setopt extended_history
# ! で始まる場合、
setopt hist_expand
# 関数定義は履歴に追加しない
setopt hist_no_functions
# history は保存しない
setopt hist_no_store
# 複数の端末で履歴を共有する
setopt share_history
# 履歴をすぐに追加
setopt inc_append_history
# -----------
# ジョブの頭文字だけでジョブの再実行を行なう
setopt auto_resume
# job は長い形式で表示する
setopt long_list_jobs
# <C-d> でログアウトできないようにする
setopt ignoreeof
# -----------
# Changing Directories
# -----------
# コマンド名ではない文字でディレクトリと同じだった場合、cd する
setopt auto_cd
# ディレクトリスタックに自動でプッシュする
setopt auto_pushd
# TODO: 理解する
# setopt pushd_minus
# 同じディレクトリは push しない
setopt pushd_ignore_dups
# TODO: 理解する
# pushd popd した後にディレクトリスタックを表示しない
setopt pushd_silent
# -----------
# スペルチェックをする
setopt correct
# TODO: 理解する
# setopt magic_equal_subst
# -----------
# completions
# -----------
# ディレクトリを補完したら末尾に / を付ける
setopt mark_dirs
# vimshell のためこれを設定するらしい? (deoplete-zsh にも必要?)
setopt no_menu_complete
# TODO: 理解する
setopt list_rows_first
# TODO: 理解する
# * を展開したときの状態で補完候補を表示する?
setopt glob_complete
# TODO: 理解する
setopt always_last_prompt
# あいまい補完のとき、リストを表示する
setopt auto_list
# TODO: 理解する
setopt auto_param_slash
# TODO: 理解する
setopt auto_param_keys
# TODO: 理解する
setopt list_types
# コンパクトに補完候補を表示する
setopt list_packed
# TODO: 理解する
# エイリアスが展開されるのを防ぐ?
setopt complete_aliases
# -----------
# コマンドに / が含まれていた場合、 /usr/local/bin を探しにいく
setopt path_dirs
# マルチバイト文字用
setopt print_eightbit
# 終了ステータスが 0 以外の場合、そのステータスを表示する
setopt print_exit_value
# TODO: 理解する
setopt transient_rprompt
# TODO: 理解する
# unsetopt promptcr
# 最初に実行された場所を記憶して、コマンドの検索を行ないようにする (高速化?)
setopt hash_cmds
# TODO: 理解する
setopt numeric_glob_sort
# インタラクティブシェルでもコメントを書けるようにする
setopt interactive_comments
# rm * が実行されたら、10 秒間待機する (反射的に Enter を押すのを防ぐ)
setopt rm_star_wait
# TODO: 理解する
setopt extended_glob
# TODO: 理解する
# プロンプトで置換する?
setopt prompt_subst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment