2023-11-23 12:31:59 +09:00
|
|
|
# Preztoにぶん投げ
|
|
|
|
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
|
|
|
|
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# fzf.zshの読み込み
|
|
|
|
[ -f /usr/share/doc/fzf/examples/key-bindings.zsh ] && source /usr/share/doc/fzf/examples/key-bindings.zsh
|
|
|
|
[ -f /usr/share/doc/fzf/examples/completion.zsh ] && source /usr/share/doc/fzf/examples/completion.zsh
|
|
|
|
|
|
|
|
# ロケール
|
|
|
|
export LC_ALL=ja_JP.UTF-8
|
|
|
|
export LANG=ja_JP.UTF-8
|
|
|
|
|
|
|
|
# 上位階層に移動するコマンド
|
|
|
|
alias a='cd ../'
|
|
|
|
alias aa='cd ../../'
|
|
|
|
alias aaa='cd ../../../'
|
|
|
|
|
|
|
|
# デフォルトエディタをVimにする
|
|
|
|
export EDITOR=nvim
|
|
|
|
alias sudo='sudo -E '
|
|
|
|
alias v=nvim
|
|
|
|
alias vim=nvim
|
|
|
|
|
|
|
|
# paruを短縮する
|
|
|
|
alias poo=paru
|
|
|
|
|
|
|
|
# exaをls代わりにする
|
|
|
|
alias ls='exa --icons -a'
|
|
|
|
alias lsa='exa --icons -T -a'
|
|
|
|
|
|
|
|
# batをcatの代わりにする
|
2023-11-23 12:45:14 +09:00
|
|
|
alias cat="batcat --color=always --style=plain"
|
2023-11-23 12:31:59 +09:00
|
|
|
|
|
|
|
# clearを短縮する
|
|
|
|
alias cls=clear
|
|
|
|
|
|
|
|
# BAT関連
|
|
|
|
export BAT_THEME="TwoDark"
|
|
|
|
|
|
|
|
# Zoxide関連
|
|
|
|
eval "$(zoxide init zsh)"
|
|
|
|
zle -N zi
|
|
|
|
bindkey '^z' zi
|
|
|
|
|
|
|
|
# fzf関連
|
|
|
|
export FZF_CTRL_R_OPTS="--reverse --preview 'echo {}' --preview-window=border-sharp,down:3:hidden:wrap --bind '?:toggle-preview'"
|
|
|
|
export FZF_DEFAULT_COMMAND='rg --files --hidden 2> /dev/null --follow --glob "!.git/*"'
|
2023-11-23 12:45:14 +09:00
|
|
|
export FZF_DEFAULT_OPTS="--ansi --reverse --border=none \
|
2023-11-23 12:31:59 +09:00
|
|
|
--color=bg+:#1c1e26,bg:#1c1e26,spinner:#ee64ac,hl:#e95678 \
|
|
|
|
--color=fg:#d5d8da,header:#e95678,info:#e95678,pointer:#ee64ac \
|
|
|
|
--color=marker:#ee64ac,fg+:#d5d8da,prompt:#e95678,hl+:#e95678"
|
|
|
|
export FZF_CTRL_T_COMMAND='rg --files --hidden 2> /dev/null --follow --glob "!.git/*"'
|
2023-11-23 12:45:14 +09:00
|
|
|
export FZF_CTRL_T_OPTS="--preview 'batcat --color=always --style=plain --line-range :100 {}' --preview-window=border-sharp,right:60%"
|
2023-11-23 12:31:59 +09:00
|
|
|
export FZF_ALT_C_COMMAND='fd -t d --hidden'
|
|
|
|
export FZF_ALT_C_OPTS="--preview 'exa {} -h -T -F --no-user --no-time --no-filesize --no-permissions --long | head -200' --preview-window=border-sharp,hidden:right:60% --bind '?:toggle-preview'"
|
|
|
|
export RUNEWIDTH_EASTASIAN=0
|
|
|
|
bindkey '^[t' fzf-file-widget
|
|
|
|
bindkey '^[r' fzf-history-widget
|
|
|
|
bindkey -r '^T'
|
|
|
|
bindkey -r '^R'
|
|
|
|
|
|
|
|
fadd() {
|
|
|
|
local out q n addfiles
|
|
|
|
while out=$(
|
|
|
|
git status --short |
|
|
|
|
awk '{if (substr($0,2,1) !~ / /) print $2}' |
|
|
|
|
fzf --multi --exit-0 --expect=ctrl-d); do
|
|
|
|
q=$(head -1 <<< "$out")
|
|
|
|
n=$[$(wc -l <<< "$out") - 1]
|
|
|
|
addfiles=(`echo $(tail "-$n" <<< "$out")`)
|
|
|
|
[[ -z "$addfiles" ]] && continue
|
|
|
|
if [ "$q" = ctrl-d ]; then
|
|
|
|
git diff --color=always $addfiles | less -R
|
|
|
|
else
|
|
|
|
git add $addfiles
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
fman() {
|
2023-11-23 12:45:14 +09:00
|
|
|
man -k . | fzf -q "$1" --prompt='man> ' --preview $'echo {} | tr -d \'()\' | awk \'{printf "%s ", $2} {print $1}\' | xargs -r man | col -bx | batcat -l man -p --color always' --preview-window=border-sharp,right:60% --bind '?:toggle-preview' | tr -d '()' | awk '{printf "%s ", $2} {print $1}' | xargs -r man
|
2023-11-23 12:31:59 +09:00
|
|
|
}
|
2023-11-23 12:45:14 +09:00
|
|
|
export MANPAGER="sh -c 'col -bx | batcat -l man -p --paging always'"
|
2023-11-23 12:31:59 +09:00
|
|
|
|
|
|
|
# 履歴関連
|
|
|
|
HISTFILE=~/.zsh_history # ヒストリを保存するファイル
|
|
|
|
HISTSIZE=10000 # メモリに保存されるヒストリの件数
|
|
|
|
SAVEHIST=10000 # 保存されるヒストリの件数
|
|
|
|
setopt bang_hist # !を使ったヒストリ展開を行う(d)
|
|
|
|
setopt extended_history # ヒストリに実行時間も保存する
|
|
|
|
setopt hist_reduce_blanks # 余分なスペースを削除してヒストリに保存する
|