Skip to content

Instantly share code, notes, and snippets.

@viewv
Created July 15, 2020 15:54
Show Gist options
  • Save viewv/5e7172365d74d08b735ea21748be467a to your computer and use it in GitHub Desktop.
Save viewv/5e7172365d74d08b735ea21748be467a to your computer and use it in GitHub Desktop.
# viewv zsh config
### Sys level fix
# Local Fix
export LC_ALL=en_US.UTF-8
# Add Proxy
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
### End sys fix
### Zinit's
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
# zinit light-mode for \
# zinit-zsh/z-a-rust \
# zinit-zsh/z-a-as-monitor \
# zinit-zsh/z-a-patch-dl \
# zinit-zsh/z-a-bin-gem-node
# End zinit annexes
## zsh-defer
zinit light romkatv/zsh-defer
## Add pure theme
zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
zinit light sindresorhus/pure
## End pure theme
## zsh-autosuggestions
zinit light zsh-users/zsh-autosuggestions
### End of Zinit's
# Add normal module
zinit wait lucid light-mode for \
zdharma/fast-syntax-highlighting \
mafredri/zsh-async \
OMZ::plugins/extract \
### Add async
async_init_fun () {
async_start_worker worker_0 -n
async_start_worker worker_1 -n
COMPLETED=0
completed_callback() {
COMPLETED=$(( COMPLETED + 1 ))
message="display notification \"Job: ${1}, Ret: ${2}, Buf: ${6}\\nOut: ${3}\\nErr: ${5}\\nExt: ${4}\""
osascript -e $message
}
async_register_callback worker_0 completed_callback
async_register_callback worker_1 completed_callback
}
zsh-defer async_init_fun
### End async init
### zsh widget config start
bindkey_init_fun () {
bindkey "[F" forward-word
bindkey "[B" backward-word
}
zsh-defer bindkey_init_fun
### zsh widget config end
### Alias and eval Area
# color LS
alias ls='ls --color=auto'
# The fuck
zsh-defer -c 'eval $(thefuck --alias)'
# vscode
zsh-defer -c "alias code='code-insiders'"
# async job you can creat two async_job for now
zsh-defer -c "alias as0='async_job worker_0'"
zsh-defer -c "alias as1='async_job worker_1'"
worker () {
async_start_worker $1
async_register_callback $1 completed_callback
echo "creat ${1}"
zsh-defer -c "alias ${1}='async_job ${1}'"
}
### End alias and eval
### Normal export Area
export_init_fun () {
# Openssl
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
# add sbin to path
export PATH="/usr/local/sbin:$PATH"
# Add Rust
export PATH="/Users/viewv/.cargo/bin:$PATH"
export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
# Add Flutter
export PATH="/Users/viewv/sdk/flutter/bin:$PATH"
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PUB_HOSTED_URL=https://pub.flutter-io.cn
# Add Jetbrains DevTools
export PATH="/Users/viewv/toolbox:$PATH"
# Add GUN
export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
# Add Fido-Test
export PATH="/Users/viewv/.local/bin:$PATH"
# Add Software
export PATH="/Users/viewv/Software:$PATH"
# Add by nvm
export NVM_DIR="$HOME/.nvm"
}
zsh-defer export_init_fun
### Add conda
conda_init_fun () {
# Add by conda
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/viewv/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/viewv/miniconda3/etc/profile.d/conda.sh" ]; then
. "/Users/viewv/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/viewv/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
}
zsh-defer conda_init_fun
# conda_init_fun
### End conda
## nvm load is really slow need some fix --viewv
zsh-defer -c '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"'
# [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# Add rvm
zsh-defer -c '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"'
# Add sdkman
sdkman_init_fun () {
# Add by sdkman
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/viewv/.sdkman"
[[ -s "/Users/viewv/.sdkman/bin/sdkman-init.sh" ]] && source "/Users/viewv/.sdkman/bin/sdkman-init.sh"
}
zsh-defer sdkman_init_fun
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment