prezto/runcoms/zshrc
Tatsuro Furusawa 7054b8cc94 modify indent
2022-07-06 17:21:19 +09:00

107 lines
2.2 KiB
Bash

#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
fi
# Customize to your needs...
if command -v direnv > /dev/null 2>&1; then
eval "$(direnv hook zsh)"
fi
if command -v nodenv > /dev/null 2>&1; then
eval "$(nodenv init -)"
fi
if command -v rbenv > /dev/null 2>&1; then
eval "$(rbenv init -)"
fi
if command -v pyenv > /dev/null 2>&1; then
eval "$(pyenv init --path)"
fi
if command -v aws > /dev/null 2>&1; then
complete -C '/usr/local/bin/aws_completer' aws
fi
export PATH=$PATH:~/bin
if command -v go > /dev/null 2>&1; then
GOPATH=$(go env GOPATH)
export PATH=$GOPATH/bin:$PATH
export GOPATH=$GOPATH
export GO111MODULE="on"
fi
# ヒストリに追加されるコマンド行が古いものと同じなら古いものを削除
setopt hist_ignore_all_dups
# スペースで始まるコマンド行はヒストリリストから削除
setopt hist_ignore_space
# 余分な空白は詰めて記録
setopt hist_reduce_blanks
# historyコマンドは履歴に登録しない
setopt hist_no_store
# history
function peco-select-history() {
BUFFER=$(history -n 1 | tail -r | awk '!a[$0]++' | peco)
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N peco-select-history
bindkey '^r' peco-select-history
function peco-src() {
local base=$(ghq root)
local src=$(ghq list | peco --query "$LBUFFER")
if [ -n "$src" ]; then
BUFFER="cd $base/$src"
zle accept-line
fi
zle -R -c
}
zle -N peco-src
bindkey '^]' peco-src
function paws {
local profile=$(perl -nle 'print $1 if /^[[](?:profile\s+)?([^]]+)/' ~/.aws/config | peco)
if [ -n "$profile" ]; then
AWS_PROFILE=$profile
export AWS_PROFILE
echo "AWS_PROFILE is now $AWS_PROFILE"
fi
}
function penv {
local env=$(echo "development\nstaging\nproduction" | peco)
if [ -n "$env" ]; then
APP_ENV=$env
export APP_ENV
echo "APP_ENV is now $APP_ENV"
fi
}
# Activate SSH Agent
if ! ssh-add -l > /dev/null 2>&1; then
ssh-add --apple-use-keychain
fi
autoload bashcompinit && bashcompinit
# load local settings
LOCAL_FILE="${HOME}/.zshrc.local"
if [ -e $LOCAL_FILE ]; then
source $LOCAL_FILE
fi