Skip to content

Instantly share code, notes, and snippets.

@mcwindy
Last active May 6, 2024 01:26
Show Gist options
  • Save mcwindy/2d89f2837a586ff146df74109b1cc8cb to your computer and use it in GitHub Desktop.
Save mcwindy/2d89f2837a586ff146df74109b1cc8cb to your computer and use it in GitHub Desktop.
My zshrc config
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
# git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# NOTE when git clone, `git config --global core.autocrlf false` should be set
alias zshconfig="nano ~/.zshrc"
alias ohmyzsh="cd ~/.oh-my-zsh"
eval $(thefuck --alias)
export C_INCLUDE_PATH=/usr/local/include/python3.8/
export CPLUS_INCLUDE_PATH=/usr/local/include/python3.8/
export CUDA_PATH=/usr/local/cuda-11.5/targets/x86_64-linux/include/
alias proxy="source /home/mcwindy/proxy.sh"
. /home/mcwindy/proxy.sh set
########################
# 全局禁用zsh仓库更改检测
git config --global --add oh-my-zsh.hide-dirty 1
# 工作目录禁用zsh仓库更改检测
git config --add oh-my-zsh.hide-dirty 1
# 重新启用
git config --add oh-my-zsh.hide-dirty 0
######################## ~/proxy.sh
#!/bin/sh
hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }')
wslip=$(hostname -I | awk '{print $1}')
port=<PORT>
PROXY_HTTP="http://${hostip}:${port}"
set_proxy(){
export http_proxy="${PROXY_HTTP}"
export HTTP_PROXY="${PROXY_HTTP}"
export https_proxy="${PROXY_HTTP}"
export HTTPS_proxy="${PROXY_HTTP}"
export ALL_PROXY="${PROXY_SOCKS5}"
export all_proxy=${PROXY_SOCKS5}
}
unset_proxy(){
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY
unset ALL_PROXY
unset all_proxy
}
test_setting(){
echo "Host ip:" ${hostip}
echo "WSL ip:" ${wslip}
echo "Current proxy:" $https_proxy
echo "set/unset"
}
if [ "$1" = "set" ]
then
set_proxy
elif [ "$1" = "unset" ]
then
unset_proxy
elif [ "$1" = "test" ] || [ ! "$1" ]
then
test_setting
else
echo "Unsupported arguments."
fi
# uncompress
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*.deb) ar x $1 ;;
*.tar.xz) tar xf $1 ;;
*.tar.zst) unzstd $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
########################
# Enable regex search in reversed-i-search
bindkey '^R' history-incremental-pattern-search-backward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment