From 103e9e951c68ffdcc740e117302f2378d29855e2 Mon Sep 17 00:00:00 2001 From: xinyz Date: Thu, 2 Dec 2021 16:46:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AEzsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 ++ aliases/aliases | 7 ++++ bash/bash_profile | 75 ++++++++++++++++++++----------------- zsh/plugins/autosuggestions | 1 + zsh/zshenv | 24 ++++++++++++ zsh/zshrc | 73 ++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 35 deletions(-) create mode 100644 .gitmodules create mode 100644 aliases/aliases create mode 160000 zsh/plugins/autosuggestions create mode 100644 zsh/zshenv create mode 100755 zsh/zshrc diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2d14739 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "zsh/plugins/autosuggestions"] + path = zsh/plugins/autosuggestions + url = git@github.com:zsh-users/zsh-autosuggestions.git diff --git a/aliases/aliases b/aliases/aliases new file mode 100644 index 0000000..9dfd407 --- /dev/null +++ b/aliases/aliases @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# +----+ +# | ls | +# +----+ +alias ls='ls --color=auto' + diff --git a/bash/bash_profile b/bash/bash_profile index f8f4688..c980904 100755 --- a/bash/bash_profile +++ b/bash/bash_profile @@ -1,35 +1,40 @@ -# generated by Git for Windows -test -f ~/.profile && . ~/.profile -test -f ~/.bashrc && . ~/.bashrc -PS1='\w $ ' -export LANG=zh_CN.UTF-8 - -export _JAVA_OPTIONS="-Dfile.encoding=UTF-8" -export JAVA_OPTS="-Dfile.encoding=UTF-8" -export JAVA_TOOLS_OPTIONS="-Dfile.encoding=UTF-8" -export MAVEN_OPTS="-Dfile.encoding=UTF-8" - -export VAGRANT_PREFER_SYSTEM_BIN=1 - -env=/tmp/agent.env - -agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } - -agent_start () { - (umask 077; ssh-agent >| "$env") - . "$env" >| /dev/null ; } - -agent_load_env - -# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running -agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) - -if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then - agent_start - ssh-add -elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then - ssh-add -fi - -unset env - +# generated by Git for Windows +test -f ~/.profile && . ~/.profile +test -f ~/.bashrc && . ~/.bashrc + +export DOTFILES=$HOME/dotfiles + +test -f $DOTFILES/aliases/aliases && . $DOTFILES/aliases/aliases + +PS1='\w $ ' +export LANG=zh_CN.UTF-8 + +export _JAVA_OPTIONS="-Dfile.encoding=UTF-8" +export JAVA_OPTS="-Dfile.encoding=UTF-8" +export JAVA_TOOLS_OPTIONS="-Dfile.encoding=UTF-8" +export MAVEN_OPTS="-Dfile.encoding=UTF-8" + +export VAGRANT_PREFER_SYSTEM_BIN=1 + +env=/tmp/agent.env + +agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } + +agent_start () { + (umask 077; ssh-agent >| "$env") + . "$env" >| /dev/null ; } + +agent_load_env + +# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running +agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) + +if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then + agent_start + ssh-add +elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then + ssh-add +fi + +unset env + diff --git a/zsh/plugins/autosuggestions b/zsh/plugins/autosuggestions new file mode 160000 index 0000000..a411ef3 --- /dev/null +++ b/zsh/plugins/autosuggestions @@ -0,0 +1 @@ +Subproject commit a411ef3e0992d4839f0732ebeb9823024afaaaa8 diff --git a/zsh/zshenv b/zsh/zshenv new file mode 100644 index 0000000..8829b2d --- /dev/null +++ b/zsh/zshenv @@ -0,0 +1,24 @@ +#!/usr/bin/env zsh + +############################### +# EXPORT ENVIRONMENT VARIABLE # +############################### + +export TERM='rxvt-256color' +export DOTFILES="$HOME/dotfiles" + +# XDG +export XDG_CONFIG_HOME=$HOME/.config +export XDG_DATA_HOME=$XDG_CONFIG_HOME/local/share +export XDG_CACHE_HOME=$XDG_CONFIG_HOME/cache + +# editor +export EDITOR="vim" +export VISUAL="vim" + +# zsh +export ZDOTDIR="$XDG_CONFIG_HOME/zsh" +export HISTFILE="$ZDOTDIR/.zhistory" # History filepath +export HISTSIZE=10000 # Maximum events for internal history +export SAVEHIST=10000 # Maximum events in history file + diff --git a/zsh/zshrc b/zsh/zshrc new file mode 100755 index 0000000..264f235 --- /dev/null +++ b/zsh/zshrc @@ -0,0 +1,73 @@ +setopt EXTENDED_HISTORY +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_IGNORE_DUPS +setopt HIST_IGNORE_ALL_DUPS +setopt HIST_IGNORE_SPACE +setopt HIST_FIND_NO_DUPS +setopt HIST_SAVE_NO_DUPS +setopt HIST_BEEP + +autoload -Uz compinit +compinit + +export LANG=zh_CN.UTF-8 + +export _JAVA_OPTIONS="-Dfile.encoding=UTF-8" +export JAVA_OPTS="-Dfile.encoding=UTF-8" +export JAVA_TOOLS_OPTIONS="-Dfile.encoding=UTF-8" +export MAVEN_OPTS="-Dfile.encoding=UTF-8" + +export VAGRANT_PREFER_SYSTEM_BIN=1 + +# +---------+ +# | ALIASES | +# +---------+ + +source $DOTFILES/aliases/aliases + + +# +-----------+ +# | SSH_AGENT | +# +-----------+ + +env=/tmp/agent.env + +agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } + +agent_start () { + (umask 077; ssh-agent >| "$env") + . "$env" >| /dev/null ; } + +agent_load_env + +# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running +agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) + +if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then + agent_start + ssh-add +elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then + ssh-add +fi + +unset env + +# +-----+ +# | VIM | +# +-----+ + +# Vi mode +bindkey -v +export KEYTIMEOUT=1 + +# +--------+ +# | PROMPT | +# +--------+ + +export PROMPT='%F{blue}(%n)%f %~ %# ' + +# +-----------------+ +# | auto-suggestion | +# +-----------------+ +source $DOTFILES/zsh/plugins/autosuggestions/zsh-autosuggestions.zsh +