Skip to content

Instantly share code, notes, and snippets.

@HymanZHAN
Last active August 17, 2022 01:34
Show Gist options
  • Save HymanZHAN/7045848d8bca9649f06a8b5127c176f4 to your computer and use it in GitHub Desktop.
Save HymanZHAN/7045848d8bca9649f06a8b5127c176f4 to your computer and use it in GitHub Desktop.
WSL 2 .zshrc
# change default working directory
if [ "$PWD" = '/mnt/c/Users/zhanx' ]
then
cd
fi
# enabling some built-in features
zstyle ':completion:*' menu select
fpath+=~/.zfunc
autoload -U compinit && compinit
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=1000
setopt SHARE_HISTORY
# some keybinding config
bindkey "^[[1;5C" forward-word
bindkey "^[[1;5D" backward-word
# personal aliases
alias mooc="cd /home/xzhan/Development/MOOC"
alias proj="cd /home/xzhan/Development/Projects"
alias pk="cd /home/xzhan/Development/Packages"
alias wk="cd /home/xzhan/Development/Work"
alias da="deactivate"
alias dcu="docker-compose up"
alias dcud="docker-compose up -d"
alias dex="docker-compose exec"
alias dcd="docker-compose down"
alias dcs="docker-compose stop"
alias dcl="docker-compose logs"
alias vim="nvim"
alias ls="lsd"
alias ll="lsd -l"
alias la="lsd -la"
alias startdb="sudo service mysql start && sudo service redis-server start && sudo service postgresql start"
# added for vscode
alias code="/mnt/c/Users/zhanx/AppData/Local/Programs/'Microsoft VS Code'/bin/code"
# added for docker
DockerResourcesBin="/mnt/c/Program Files/Docker/Docker/resources/bin"
export PATH=$PATH:$DockerResourcesBin
# added for miniconda3
# export PATH="/home/xzhan/miniconda3/bin:$PATH" # commented out by conda initialize
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/xzhan/miniconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/xzhan/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/xzhan/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/xzhan/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# added for rust
export PATH="/home/xzhan/.cargo/bin:$PATH"
# added for golang
export PATH="/usr/local/go/bin:$PATH"
export PATH="/home/xzhan/go/bin:$PATH"
# added for deno
export DENO_INSTALL="/home/xzhan/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
# added for zsh-history-substring-search
source /home/xzhan/.zsh-history-substring-search.zsh
# bindkey '^[[A' history-substring-search-up
# bindkey '^[[B' history-substring-search-down
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="fg=green,bold"
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND="fg=red,bold"
# remove adjacent duplicated search result
setopt HIST_FIND_NO_DUPS
eval "$(starship init zsh)"
eval "$(_TYPER_COMPLETE=source_zsh typer 2>/dev/null)"
eval "$(fnm env --use-on-cd)"
# Load Angular CLI autocompletion.
source <(ng completion script)
# added for proxy
function proxy_on() {
export hostip=$(cat /etc/resolv.conf | grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890"
export http_proxy="http://${hostip}:7890"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment