2018-04-01 17:06:16 +08:00
# zsh settings
2018-12-10 16:03:35 +08:00
export HISTSIZE = 10000
export SAVEHIST = 100000
2018-10-17 10:28:55 +08:00
export HISTFILE = $HOME /.zsh_history
2018-04-02 22:10:30 +08:00
setopt append_history
setopt extended_history
setopt share_history
setopt histignorespace
setopt longlistjobs
setopt notify
setopt completeinword
setopt noshwordsplit
setopt auto_cd
setopt interactivecomments
setopt extended_glob
2018-04-01 17:06:16 +08:00
2018-10-09 20:36:55 +08:00
autoload -U compinit; compinit
2018-10-28 18:18:18 +08:00
# basic keybindings
2018-10-09 20:36:55 +08:00
bindkey -v
2018-10-28 18:18:18 +08:00
bindkey "^R" history-incremental-search-backward
2018-10-09 20:36:55 +08:00
2018-10-09 19:03:43 +08:00
# zsh imports
2018-10-17 10:28:55 +08:00
fpath = ( $HOME /.zsh/functions $fpath )
# ls colors
2018-11-01 00:22:44 +08:00
if [ [ " $( uname -s) " = = "Darwin" ] ] ; then
2018-10-28 18:18:18 +08:00
#eval $(gdircolors -b $HOME/.dircolors)
export CLICOLOR = 1
2018-10-17 14:52:42 +08:00
else
eval $( dircolors -b $HOME /.dircolors)
2018-11-01 00:37:31 +08:00
alias ls = 'ls --color=auto'
2018-10-17 14:52:42 +08:00
fi
2018-10-30 16:34:51 +08:00
zstyle ':completion:*:default' list-colors ${ (s. : .)LS_COLORS }
# completion menu
zstyle ':completion:*' menu select
2018-10-09 19:03:43 +08:00
2019-10-21 17:49:55 +08:00
# documents
if [ [ " $( uname -s) " = = "Darwin" ] ] ; then
export DOC = " $HOME /Documents "
else
export DOC = " $HOME "
fi
2018-09-22 20:43:47 +08:00
# editor
export EDITOR = nvim
2018-04-02 12:40:37 +08:00
# pure
2019-10-21 17:49:55 +08:00
export PURE_PROMPT_SYMBOL = "%1{❯ %}"
export PURE_PROMPT_VICMD_SYMBOL = "%1{❮ %}"
2019-10-22 00:20:23 +08:00
zstyle :prompt:pure:git:dirty color 242
2019-10-21 17:49:55 +08:00
# Fixes it's treatment as a double width character, see https://github.com/geometry-zsh/geometry/commit/dbd28b23293b0862055deda8e59db57ebd6d6606#diff-37d2e8a43274d6fbaf5b762a55f5138cR211
2018-04-02 12:40:37 +08:00
autoload -U promptinit; promptinit
prompt pure
2018-09-22 20:43:47 +08:00
# autosuggestions
2018-10-17 10:28:55 +08:00
source $HOME /.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
2019-10-22 00:20:23 +08:00
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = 'fg=10'
2018-10-09 19:03:43 +08:00
export ZSH_AUTOSUGGEST_USE_ASYNC = true
2018-11-10 08:51:48 +08:00
bindkey '^e' autosuggest-execute
2018-09-22 20:43:47 +08:00
2018-11-10 08:43:39 +08:00
# syntax highlighting
source $HOME /.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
2018-04-02 23:05:10 +08:00
# thefuck
2018-10-09 19:03:43 +08:00
export PATH = " $HOME /.local/bin: $PATH "
2018-04-02 23:05:10 +08:00
eval $( thefuck --alias nope)
2018-04-01 17:06:16 +08:00
# golang
2019-10-21 17:49:55 +08:00
export GOPATH = " $DOC /go "
2018-04-01 17:06:16 +08:00
export PATH = " $( go env GOPATH) /bin: $PATH "
2019-08-12 11:51:41 +08:00
# rust
2019-10-21 17:49:55 +08:00
if [ [ -f " $HOME /.cargo/env " ] ] ; then
source " $HOME /.cargo/env "
2019-08-25 16:22:25 +08:00
fi
2019-08-12 11:51:41 +08:00
2019-10-04 11:34:06 +08:00
# deno
export DENO_INSTALL = " $HOME /.deno "
export PATH = " $DENO_INSTALL /bin: $PATH "
2018-12-01 00:33:57 +08:00
# yarn bin
export PATH = " $HOME /.yarn/bin: $PATH "
2019-10-21 17:49:55 +08:00
# minio client
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/local/bin/mc mc
# kubectl
if [ [ -f " $( which kubectl) " ] ] ; then
source <( kubectl completion zsh)
fi
2019-10-22 10:15:13 +08:00
# python path
if [ [ " $( uname -s) " = = "Darwin" ] ] ; then
export PATH = " $PATH : $HOME /Library/Python/3.7/bin "
export PATH = " $PATH : $HOME /Library/Python/2.7/bin "
fi
# flutter SDK
export PATH = " $PATH : $DOC /flutter/bin "
2018-04-01 17:06:16 +08:00
# aliases
alias vim = nvim
2019-10-21 17:49:55 +08:00
# gpg help
2019-09-20 00:57:17 +08:00
function gpg_start {
# gpg
export GPG_TTY = " $( tty) "
# gpg ssh agent
test -e " $( which gpgconf) " && export SSH_AUTH_SOCK = " $( gpgconf --list-dirs agent-ssh-socket) "
# gpg ssh fix pinentry
echo "UPDATESTARTUPTTY" | gpg-connect-agent > /dev/null 2>& 1
}
2018-10-17 10:28:55 +08:00
# iTerm2 integration
2019-10-21 17:49:55 +08:00
if [ [ -f " $HOME /.iterm2_shell_integration.zsh " ] ] ; then
source " $HOME /.iterm2_shell_integration.zsh "
fi
2018-10-17 14:52:42 +08:00
2018-10-17 10:28:55 +08:00
# hack to optionally get some oh-my-zsh back
2018-11-01 00:22:44 +08:00
if [ [ " $( uname -s) " = = "Darwin" ] ] ; then
2018-10-17 14:52:42 +08:00
export ZSH = " $HOME /.oh-my-zsh "
test -e " $HOME /.oh-my-zsh/plugins/osx/osx.plugin.zsh " && source " $HOME /.oh-my-zsh/plugins/osx/osx.plugin.zsh "
# legacy scripts
test -e " $HOME /.bin " && export PATH = " $HOME /.bin: $PATH " # TODO: move to .local/bin
# tips
function tips {
echo "Some useful commands:"
echo " - spotify || itunes Chill out to 🎧"
echo " - cdf Jumps to the folder open in finder"
echo " - quick-look Opens file in quick look 👀"
echo " - asciinema Records a terminal session"
echo " - http Make HTTP requests"
echo " - ghi GitHub Issues"
echo " - todo [task] What it says on the tin 🗒"
echo " - nope When you give up on life 😖"
echo " - imgcat photo Preview photo inline"
echo " - it2dl file Downloads file"
echo " - ^R Searches history"
echo " - ^Z Suspend process"
2018-11-10 08:51:48 +08:00
echo " - ^E Executes suggestion or Emmet"
2018-10-17 14:52:42 +08:00
echo " - ⌘ B In Finder, open a iTerm window"
echo
echo "In vim:"
2019-02-19 00:40:54 +08:00
echo " - ctrl-v, shift-i, [chars]"
2018-10-17 14:52:42 +08:00
echo " - o (insert in new line) a (append) A (append at end) c (change selection)"
echo " - w (start of word) e (end of word) 0 (start of line) $ (end of line) "
echo " - k (up) j (down) h (left) l (right)"
echo " - ~ (swap case) U (uppercase) u (lowercase) gUU guu gu $ gu0 gUaw "
echo " - % (jump to matching brackets)"
2019-10-08 00:31:59 +08:00
echo " - cc (intent line) = (indent selection)"
echo " - (insert mode) ctrl-y (indent) ctrl-d (unindent)"
2018-10-17 14:52:42 +08:00
echo " - (jump to line in screen) H (top) M (middle) L (bottom)"
echo " - (jump by screen to line) ctrl-u (half up) ctrl-d (half down)"
2019-02-19 00:40:54 +08:00
echo " - (scroll screen, put current line at) zz (center) zt (top) zb (bottom)"
2018-10-17 14:52:42 +08:00
echo " - (scroll screen by one line) ctrl-y (up) ctrl-e (down)"
echo " - mx (mark as x) \`x (return to x)"
2019-02-19 00:40:54 +08:00
echo " - f[char] (find char)"
2018-10-17 14:52:42 +08:00
}
fi
2019-05-26 12:23:13 +08:00