Last active
July 18, 2023 01:38
-
-
Save gtongy/5c2726db4af251392f404856c09a7507 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ============================================================================== | |
# | |
# zplug | |
# | |
# ============================================================================== | |
if [[ ! -d ~/.zplug ]];then | |
git clone https://github.com/zplug/zplug ~/.zplug | |
fi | |
source ~/.zplug/init.zsh | |
zplug "~/.zsh", from:local | |
zplug "zsh-users/zsh-history-substring-search" | |
zplug "zsh-users/zsh-completions" | |
zplug "zsh-users/zsh-syntax-highlighting" | |
zplug mafredri/zsh-async, from:github | |
zplug sindresorhus/pure, use:pure.zsh, from:github, as:theme | |
zplug "sorin-ionescu/prezto" | |
zplug "zsh-users/zsh-autosuggestions" | |
zplug "tarrasch/zsh-bd" | |
zplug "b4b4r07/enhancd", use:init.sh | |
zplug "arks22/tmuximum", as:command | |
zplug "sharkdp/bat", from:gh-r, as:command, rename-to:"bat" | |
if ! zplug check --verbose; then | |
printf "Install? [y/N]: " | |
if read -q; then | |
echo; zplug install | |
fi | |
fi | |
zplug load --verbose | |
# ============================================================================== | |
# | |
# pure setting | |
# | |
# ============================================================================== | |
autoload -U promptinit; promptinit | |
zstyle ':prezto:module:prompt' theme 'pure' | |
zstyle ':prezto:load' pmodule \ | |
'environment' \ | |
'terminal' \ | |
'editor' \ | |
'history' \ | |
'directory' \ | |
'spectrum' \ | |
'utility' \ | |
'completion' \ | |
'syntax-highlighting' \ | |
'autosuggestions' \ | |
'prompt' | |
zmodload zsh/nearcolor | |
zstyle :prompt:pure:path color 031 | |
zstyle :prompt:pure:prompt:success color 028 | |
zstyle :prompt:pure:prompt:failure color 131 | |
zstyle :prompt:pure:git:branch color 028 | |
zstyle :prompt:pure:git:arrow color 031 | |
zstyle :prompt:pure:git:stash color 031 | |
zstyle :prompt:pure:git:dirty color 031 | |
zstyle :prompt:pure:git:stash color 031 | |
# コマンド補完 | |
autoload -U compinit | |
compinit | |
# ============================================================================== | |
# | |
# ls color | |
# | |
# ============================================================================== | |
export LSCOLORS=Exfxcxdxbxegedabagacad | |
export LS_COLORS='di=01;34:ln=01;35:so=01;32:ex=01;31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' | |
export ZLS_COLORS=$LS_COLORS | |
export CLICOLOR=true | |
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | |
zstyle ':completion:*' menu select | |
# ============================================================================== | |
# | |
# システム設定 | |
# | |
# ============================================================================== | |
# 重複を記録しない | |
setopt hist_ignore_dups | |
# 開始と終了を記録 | |
setopt EXTENDED_HISTORY | |
eval "$(anyenv init -)" | |
# PROMPT変数内で変数参照する | |
setopt prompt_subst | |
# 重複を記録しない | |
setopt hist_ignore_dups | |
# 開始と終了を記録 | |
setopt EXTENDED_HISTORY | |
# 音を鳴らさない | |
setopt no_beep | |
# cdとlsの省略 | |
setopt auto_cd | |
function chpwd() { ls } | |
# ============================================================================== | |
# | |
# 履歴設定 | |
# | |
# ============================================================================== | |
# 履歴ファイルの保存先 | |
export HISTFILE=${HOME}/.zsh_history | |
# メモリに保存される履歴の件数 | |
export HISTSIZE=1000 | |
# 履歴ファイルに保存される履歴の件数 | |
export SAVEHIST=100000 | |
# ============================================================================== | |
# | |
# zshlocal | |
# | |
# ============================================================================== | |
if [ -e ~/.zshlocal ]; then | |
source ~/.zshlocal | |
fi | |
# ============================================================================== | |
# | |
# fzf | |
# | |
# ============================================================================== | |
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --multi --border --bind='ctrl-t:toggle-preview'" | |
export RUNEWIDTH_EASTASIAN=0 | |
# ============================================================================== | |
# | |
# anyenv | |
# | |
# ============================================================================== | |
export PATH="$HOME/.anyenv/bin:$PATH" | |
# ============================================================================== | |
# | |
# custom functions | |
# | |
# ============================================================================== | |
function command-history-search-fzf(){ | |
BUFFER="$(history -nr 1 | awk '!a[$0]++' | fzf | sed 's/\\n/\n/')" | |
CURSOR=$#BUFFER # カーソルを文末に移動 | |
zle -R -c # refresh | |
} | |
function gitmoji-search-fzf(){ | |
BUFFER="${BUFFER}$(gitmoji -l | fzf | awk '{print $3}')" | |
CURSOR=$#BUFFER | |
zle redisplay | |
} | |
function _gapp(){ | |
files=$( git status -s | grep -v \? | grep -E "^.M" | perl -pe "s/(?<=^.{0}).{3}//g" | fzf ) | |
wc=`echo $files | wc -l` | |
if [ $wc -ne 1 ]; then | |
files=$(echo $files | sed -e :loop -e 'N; $!b loop' -e 's/\n/ /g') | |
fi | |
if [ -n "$files" ]; then | |
git add -p ${=files} | |
fi | |
} | |
function pull-current-branch(){ | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
if [ $current_branch ]; then | |
git pull origin $current_branch | |
fi | |
} | |
function get-develop-changes-to-work(){ | |
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
git checkout develop | |
git fetch --all | |
git pull --rebase origin develop | |
git checkout $CURRENT_BRANCH | |
git merge --no-ff develop | |
} | |
function push-current-branch(){ | |
CURRENT_BRANCH=`git rev-parse --abbrev-ref HEAD` | |
if [ $CURRENT_BRANCH = 'master' ]; then | |
echo "current branch is master. stop push current branch." | |
return | |
fi | |
git push origin $CURRENT_BRANCH | |
} | |
function change-match-pattern(){ | |
if [ ! $1 ]; then | |
echo "please input before pattern" | |
return | |
fi | |
if [ ! $2 ]; then | |
echo "please input after pattern" | |
return | |
fi | |
git grep -l $1 $3 | xargs sed -i "" -e "s/$1/$2/g" | |
} | |
function jump_fzf(){ | |
JUMP_PATH=`git grep -E "$*" | fzf | awk -F: '{printf $1 " +" $2}'| sed -e 's/\+$//'` | |
if [ $JUMP_PATH ]; then | |
view ${=JUMP_PATH} | |
fi | |
} | |
function docker-exec-fzf(){ | |
NAME=`docker ps -a --format "{{.Names}}" | fzf` | |
docker exec -it $NAME bash | |
} | |
# ============================================================================== | |
# | |
# alias | |
# | |
# ============================================================================== | |
alias rm='trash -F' | |
alias glg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" | |
alias ll='ls -la' | |
alias gd='git diff --name-only HEAD^ | fzf' | |
alias pm=get-develop-changes-to-work | |
alias gapp='_gapp' | |
alias pcb='pull-current-branch' | |
alias pushcb=push-current-branch | |
alias gp="cd $GOPATH/src/github.com/gtongy/" | |
alias gbc="git branch | fzf | xargs git checkout" | |
alias zr="source ~/.zshrc" | |
alias cmp=change-match-pattern | |
alias jump=jump_fzf | |
alias def=docker-exec-fzf | |
alias t=tmuximum | |
alias cat=bat | |
alias vi=nvim | |
# ============================================================================== | |
# | |
# key bind | |
# | |
# ============================================================================== | |
zle -N command-history-search-fzf | |
zle -N gitmoji-search-fzf | |
bindkey '^R' command-history-search-fzf | |
bindkey '^F' forward-word | |
bindkey '^B' backward-word | |
bindkey '^J' self-insert | |
bindkey '^Y' kill-line | |
bindkey '^W' gitmoji-search-fzf | |
bindkey '^P' backward-delete-word |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment