[关闭]
@czyczk 2020-09-17T07:02:31.000000Z 字数 2285 阅读 413

.bashrc / .zshrc

Linux Shell


  1. # User-defined aliases
  2. # Show your IP on the Internet
  3. alias show_ip="curl http://ipinfo.io/json"
  4. # Apply proxies (Setting `ALL_PROXY` only is not enough since some applications like `go get` follows `HTTP_PROXY` and `HTTPS_PROXY` only.)
  5. export GLOBAL_PROXY_URL="socks5://127.0.0.1:12080"
  6. alias auto_set_proxy='export ALL_PROXY="$GLOBAL_PROXY_URL" && export HTTP_PROXY="$GLOBAL_PROXY_URL" && export HTTPS_PROXY="$GLOBAL_PROXY_URL"'
  7. alias auto_unset_proxy="unset ALL_PROXY && unset HTTP_PROXY && unset HTTPS_PROXY"
  8. alias auto_set_git_proxy='git config --global http.https://github.com.proxy "$GLOBAL_PROXY_URL" && git config --global https.https://github.com.proxy "$GLOBAL_PROXY_URL"'
  9. alias auto_unset_git_proxy="git config --global --unset http.https://github.com.proxy && git config --global --unset https.https://github.com.proxy"
  10. # ShadowsocksR related (only work after SSR is configured)
  11. alias start_ssr="sudo python /opt/shadowsocksr/shadowsocks/local.py -c /etc/shadowsocksr/user-config.json -d start"
  12. alias check_ssr="sudo tail /var/log/shadowsocksr.log"
  13. # User-defined environment variables
  14. # Golang
  15. export GOPATH=$HOME/go
  16. export PATH=$PATH:$GOPATH/bin
  17. export GOPROXY=https://goproxy.cn
  18. # NVM (defer init + Zsh ver.)
  19. # (for Bash version, use `type -t` instead of `whence -w`)
  20. # Defer initialization of nvm until nvm, node or a node-dependent command is
  21. # run. Ensure this block is only run once if .bashrc gets sourced multiple times
  22. # by checking whether __init_nvm is a function.
  23. if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(whence -w __init_nvm)" = function ]; then
  24. export NVM_DIR="$HOME/.nvm"
  25. [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
  26. declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
  27. function __init_nvm() {
  28. for i in "${__node_commands[@]}"; do unalias $i; done
  29. . "$NVM_DIR"/nvm.sh
  30. unset __node_commands
  31. unset -f __init_nvm
  32. }
  33. for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done
  34. fi
  35. # Pyenv
  36. export PATH="/home/zenas/.pyenv/bin:$PATH"
  37. eval "$(pyenv init -)"
  38. eval "$(pyenv virtualenv-init -)"
  39. # Pip installed bins
  40. export PATH=~/.local/bin:$PATH
  41. # RUSTUP
  42. export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
  43. # Enable proxy when starting shell
  44. # auto_set_proxy
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注