This commit is contained in:
Jay 2021-11-26 21:01:28 +08:00
commit 23a5c6ea5a
11 changed files with 386 additions and 0 deletions

3
.dotter/cache.toml Normal file
View File

@ -0,0 +1,3 @@
[symlinks]
[templates]

27
.dotter/global.toml Normal file
View File

@ -0,0 +1,27 @@
[helpers]
[default]
depends = []
[default.files]
[default.variables]
[zsh.files]
zshrc = "~/.zshrc"
zprofile = "~/.zprofile"
zsh_20_keybind = "~/.zsh/20_keybind.zsh"
zsh_30_alias = "~/.zsh/30_alias.zsh"
zsh_50_setopt = "~/.zsh/50_setopt.zsh"
zsh_70_misc = "~/.zsh/70_misc.zsh"
[shell.files]
# Optional variables email+git_username
gitconfig = "~/.gitconfig"
tmux = "~/.tmux.conf"
[vim.files]
vimrc = "~/.vimrc"
[nvim.files]
init_vim = "~/.config/nvim/init.vim"

6
.dotter/local.toml Normal file
View File

@ -0,0 +1,6 @@
includes = []
packages = ["default", "zsh"]
[files]
[variables]

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/global.toml

26
gitconfig Normal file
View File

@ -0,0 +1,26 @@
{{#if (and email git_username)~}}
[user]
name = {{git_username}}
email = {{email}}
{{/if~}}
[merge]
tool = vimdiff
[diff]
tool = vimdiff
trustExitCode = true
[difftool]
prompt = false
[alias]
d = difftool
co = checkout
ci = commit -v
l = log --oneline --graph --all
ls = log --graph --pretty=format:\"%h <%an> %ar %s\" --all
st = status
br = branch
[mergetool]
keepBackup = false
[core]
editor = vim
# vim: ft=gitconfig

24
zprofile Normal file
View File

@ -0,0 +1,24 @@
# `$HOME/bin/start-agent`
SSH_ENV="$HOME/.ssh/agent-environment"
function start_agent {
echo "Initialising new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
#ps ${SSH_AGENT_PID} doesn't work under cywgin
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi

49
zsh_20_keybind Normal file
View File

@ -0,0 +1,49 @@
# Vim-like keybind as default
bindkey -v
autoload -U edit-command-line
zle -N edit-command-line
bindkey -M viins '^X^E' edit-command-line
# Add emacs-like keybind to viins mode
bindkey -M viins '^F' forward-char
bindkey -M viins '^B' backward-char
# bindkey -M viins '^P' up-line-or-history
# bindkey -M viins '^N' down-line-or-history
bindkey -M viins '^A' beginning-of-line
bindkey -M viins '^E' end-of-line
bindkey -M viins '^K' kill-line
bindkey -M viins '^R' history-incremental-pattern-search-backward
# bindkey -M viins '\er' history-incremental-pattern-search-forward
bindkey -M viins '^Y' yank
bindkey -M viins '^W' backward-kill-word
bindkey -M viins '^U' backward-kill-line
bindkey -M viins '^H' backward-delete-char
bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^G' send-break
bindkey -M viins '^D' delete-char-or-list
bindkey -M vicmd '^A' beginning-of-line
bindkey -M vicmd '^E' end-of-line
bindkey -M vicmd '^K' kill-line
# bindkey -M vicmd '^P' up-line-or-history
# bindkey -M vicmd '^N' down-line-or-history
bindkey -M vicmd '^Y' yank
bindkey -M vicmd '^W' backward-kill-word
bindkey -M vicmd '^U' backward-kill-line
bindkey -M vicmd '/' vi-history-search-forward
bindkey -M vicmd '?' vi-history-search-backward
bindkey -M vicmd 'gg' beginning-of-line
bindkey -M vicmd 'G' end-of-line
if is-at-least 5.0.8; then
autoload -Uz surround
zle -N delete-surround surround
zle -N change-surround surround
zle -N add-surround surround
bindkey -a cs change-surround
bindkey -a ds delete-surround
bindkey -a ys add-surround
bindkey -a S add-surround
fi

1
zsh_30_alias Normal file
View File

@ -0,0 +1 @@
alias k="kubectl"

160
zsh_50_setopt Normal file
View File

@ -0,0 +1,160 @@
# Do not print the directory stack after pushd or popd.
#setopt pushd_silent
# Replace 'cd -' with 'cd +'
setopt pushd_minus
# Ignore duplicates to add to pushd
setopt pushd_ignore_dups
# pushd no arg == pushd $HOME
setopt pushd_to_home
# Check spell command
# setopt correct
# Check spell all
# setopt correct_all
# Prohibit overwrite by redirection(> & >>) (Use >! and >>! to bypass.)
# setopt no_clobber
# Deploy {a-c} -> a b c
setopt brace_ccl
# Enable 8bit
setopt print_eight_bit
# sh_word_split
setopt sh_word_split
# Change
#~$ echo 'hoge' \' 'fuga'
# to
#~$ echo 'hoge '' fuga'
setopt rc_quotes
# Case of multi redirection and pipe,
# use 'tee' and 'cat', if needed
# ~$ < file1 # cat
# ~$ < file1 < file2 # cat 2 files
# ~$ < file1 > file3 # copy file1 to file3
# ~$ < file1 > file3 | cat # copy and put to stdout
# ~$ cat file1 > file3 > /dev/stdin # tee
setopt multios
# Automatically delete slash complemented by supplemented by inserting a space.
setopt auto_remove_slash
# No Beep
setopt no_beep
setopt no_list_beep
setopt no_hist_beep
# Expand '=command' as path of command
# e.g.) '=ls' -> '/bin/ls'
setopt equals
# Do not use Ctrl-s/Ctrl-q as flow control
setopt no_flow_control
# Look for a sub-directory in $PATH when the slash is included in the command
setopt path_dirs
# Show exit status if it's except zero.
setopt print_exit_value
# Show expaning and executing in what way
#setopt xtrace
# Confirm when executing 'rm *'
# setopt rm_star_wait
# Let me know immediately when terminating job
setopt notify
# Show process ID
setopt long_list_jobs
# Resume when executing the same name command as suspended process name
setopt auto_resume
# Disable Ctrl-d (Use 'exit', 'logout')
#setopt ignore_eof
# Ignore case when glob
setopt no_case_glob
# Use '*, ~, ^' as regular expression
# Match without pattern
# ex. > rm *~398
# remove * without a file "398". For test, use "echo *~398"
setopt extended_glob
# If the path is directory, add '/' to path tail when generating path by glob
setopt mark_dirs
# Automaticall escape URL when copy and paste
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
# Prevent overwrite prompt from output withour cr
setopt no_prompt_cr
# Let me know mail arrival
setopt mail_warning
# Do not record an event that was just recorded again.
setopt hist_ignore_dups
# Delete an old recorded event if a new event is a duplicate.
setopt hist_ignore_all_dups
setopt hist_save_nodups
# Expire a duplicate event first when trimming history.
setopt hist_expire_dups_first
# Do not display a previously found event.
setopt hist_find_no_dups
# Shere history
setopt share_history
# Pack extra blank
setopt hist_reduce_blanks
# Write to the history file immediately, not when the shell exits.
setopt inc_append_history
# Remove comannd of 'hostory' or 'fc -l' from history list
setopt hist_no_store
# Remove functions from history list
setopt hist_no_functions
# Record start and end time to history file
setopt extended_history
# Ignore the beginning space command to history file
setopt hist_ignore_space
# Append to history file
setopt append_history
# Edit history file during call history before executing
setopt hist_verify
# Enable history system like a Bash
setopt bang_hist
setopt always_last_prompt
setopt auto_cd
setopt auto_menu
setopt auto_param_keys
setopt auto_param_slash
setopt auto_pushd
setopt complete_in_word
setopt globdots
setopt interactive_comments
setopt list_types
setopt magic_equal_subst
setopt monitor

43
zsh_70_misc Normal file
View File

@ -0,0 +1,43 @@
# Important
zstyle ':completion:*:default' menu select=2
# Completing Groping
zstyle ':completion:*:options' description 'yes'
zstyle ':completion:*:descriptions' format '%F{yellow}Completing %B%d%b%f'
zstyle ':completion:*' group-name ''
# Completing misc
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
zstyle ':completion:*' verbose yes
zstyle ':completion:*' completer _expand _complete _match _prefix _approximate _list _history
zstyle ':completion:*:*files' ignored-patterns '*?.o' '*?~' '*\#'
zstyle ':completion:*' use-cache true
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
# Directory
zstyle ':completion:*:cd:*' ignore-parents parent pwd
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# default: --
zstyle ':completion:*' list-separator '-->'
zstyle ':completion:*:manuals' separate-sections true
# Menu select
zmodload -i zsh/complist
bindkey -M menuselect '^h' vi-backward-char
bindkey -M menuselect '^j' vi-down-line-or-history
bindkey -M menuselect '^k' vi-up-line-or-history
bindkey -M menuselect '^l' vi-forward-char
#bindkey -M menuselect '^k' accept-and-infer-next-history
autoload -Uz cdr
autoload -Uz history-search-end
autoload -Uz modify-current-argument
autoload -Uz smart-insert-last-word
autoload -Uz terminfo
autoload -Uz vcs_info
autoload -Uz zcalc
autoload -Uz zmv
autoload -Uz run-help-git
autoload -Uz run-help-svk
autoload -Uz run-help-svn

46
zshrc Normal file
View File

@ -0,0 +1,46 @@
source ~/.zplug/init.zsh
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOSTART_ONCE=true
export ZSH_TMUX_AUTOCONNECT=true
zplug "zplug/zplug", hook-build:'zplug --self-manage'
zplug "QiaoHao9/ys", as:theme
zplug "zsh-users/zsh-syntax-highlighting"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "zsh-users/zsh-history-substring-search"
zplug "mattbangert/kubectl-zsh-plugin"
zplug "greymd/docker-zsh-completion"
zplug "pkulev/zsh-rustup-completion"
zplug "g-plane/zsh-yarn-autocompletions", hook-build:"./zplug.zsh", defer:2
zplug "plugins/tmux", from:oh-my-zsh
zplug "plugins/git", from:oh-my-zsh
zplug "plugins/docker", from:oh-my-zsh
zplug "plugins/composer", from:oh-my-zsh
zplug "plugins/extract", from:oh-my-zsh
zplug "lib/completion", from:oh-my-zsh
zplug "plugins/sudo", from:oh-my-zsh
zplug "b4b4r07/enhancd", use:init.sh
zplug "$HOME/.zsh", from:local, use:"*.zsh"
# Install plugins if there are plugins that have not been installed
if ! zplug check --verbose; then
printf "Install? [y/N]: "
if read -q; then
echo; zplug install
fi
fi
# Then, source plugins and add commands to $PATH
zplug load
if [ -f "$HOME/.zprofile" ]; then
source "$HOME/.zprofile"
fi