notes/config/zsh/env.bash

174 lines
5.6 KiB
Bash

export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
export EDITOR='vim'
alias vimdiff='vi -d'
# delete remote branch
alias gpod='git push origin --delete'
# pip alias
alias piu='pip install -U'
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
export LOCAL=$HOME/.local
export CONF=$HOME/.config
export LOG=$LOCAL/var/log
# npm config
# export NODE_HOME=$HOME/.local/node
# export NODE_PATH=$NODE_PATH:$HOME/.local/npm/lib/node_modules
# export PATH=$HOME/.local/npm/bin:$NODE_HOME/bin:$PATH
function update_dlv () {
go install github.com/go-delve/delve/cmd/dlv@latest
}
# golang config
goinfo=$(echo $(which go))
if [[ $goinfo =~ "not found" ]]; then
echo "go not found"
else
export GOPATH=$HOME/Projects/Go
export PATH=$HOME/.local/bin:$GOROOT/bin:$GOPATH/bin:$PATH
# export GOROOT=$(go env | grep -Eo '(GOROOT=.*)' | grep -Eo '(=.*)' | sed 's/=//g' | sed 's/"//g')
# export GOROOT=/usr/lib/go
export $(go env | grep 'GOROOT' | sed 's/"//g' | sed "s/'//g")
# export GOROOT=$HOME/.local/go
# :${JAVA_HOME}/bin:${PATH}
export GO111MODULE=on
fi
# 阿里云镜像
# export GOPROXY=https://mirrors.aliyun.com/goproxy/
# 中国golang镜像
# GOPROXY=https://goproxy.io
# go env -w GOPROXY=https://goproxy.cn,direct
export GOPROXY=https://goproxy.cn
# rust config
export CARGO_HOME=$HOME/.cargo
export PATH=$CARGO_HOME/bin:$PATH
# [[ -f ~/.fzf.zsh ]] && source ~/.fzf.zsh
# MacOS settings
if [[ $(uname -s) = "Darwin" ]]; then
# icoding
export ICODING_HOME=$HOME/.local/icoding
export PATH=$ICODING_HOME:$PATH
# MySQL 5.7 at MacOS
# For compilers to find mysql@5.7
if [[ $(uname -m) = "arm64" ]]; then
export MYSQL_HOME="/opt/homebrew/Cellar/mysql@5.7/5.7.38"
export LDFLAGS="-L/opt/homebrew/opt/mysql@5.7/lib"
export CPPFLAGS="-I/opt/homebrew/opt/mysql@5.7/include"
export PATH="/opt/homebrew/opt/go@1.17/bin:$PATH"
export PG_HOME="/opt/homebrew/opt/postgresql@15"
export LDFLAGS="-L/opt/homebrew/opt/postgresql@15/lib:$LDFLAGS"
export CPPFLAGS="-I/opt/homebrew/opt/postgresql@15/include:$CPPFLAGS"
export PATH="$PG_HOME/bin:$PATH"
else
export MYSQL_HOME="/usr/local/opt/mysql@5.7"
export LDFLAGS="-L/usr/local/opt/mysql@5.7/lib -L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/mysql@5.7/include -I/usr/local/opt/openssl@1.1/include"
fi
export PATH=$MYSQL_HOME/bin:$PATH
export PKG_CONFIG_PATH=$MYSQL_HOME/lib/pkgconfig
# export VIRTUALENVWRAPPER_PYTHON="/usr/local/bin/python3"
export PATH="/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands":$PATH
# export GITSTATUS_LOG_LEVEL=DEBUG
# tig_completion=/usr/local/etc/bash_completion.d/tig-completion.bash
# if [[ -f $tig_completion ]]; then
# source $tig_completion
# fi
# android platform-tools
export PATH="$HOME/.local/platform-tools":$PATH
# php config
# export PATH="/opt/homebrew/opt/php@7.4/bin:$PATH"
# export PATH="/opt/homebrew/opt/php@7.4/sbin:$PATH"
# export LDFLAGS="-L/opt/homebrew/opt/php@7.4/lib"
# export CPPFLAGS="-I/opt/homebrew/opt/php@7.4/include"
alias sed="gsed"
# export GOPROXY=https://goproxy.baidu-int.com
# Update homebrew config
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
# node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
# set go build
export GO_1_17_BIN=$GOROOT/bin
export GO_1_18_BIN=$GOROOT/bin
# Linux settings
elif [[ $(uname -s) = "Linux" ]]; then
if [[ $XDG_SESSION_TYPE = "x11" ]]; then
alias pbcopy="xclip -sel clipboard"
alias pbpaste="xclip -sel clipboard -o"
elif [[ $XDG_SESSION_TYPE = "wayland" ]]; then
alias pbcopy="wl-copy"
alias pbpaste="wl-paste"
fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/cuda/lib64/
# Java config
# export JAVA_HOME=$HOME/.local/jvm/openjdk17
# graalvm-jdk-17.0.7+8.1
export JAVA_HOME="$HOME/.local/jvm/graalvm-jdk-17.0.7+8.1"
export GRAALVM_HOME=$JAVA_HOME
export JRE_HOME=${JAVA_HOME}/jre
export CLASS_PATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=$JAVA_HOME/bin:$PATH
# using maven from idea
IDEA_HOME="/opt/idea"
MVN_HOME=${IDEA_HOME}/plugins/maven/lib/maven3/
export PATH=${MVN_HOME}/bin:$PATH
elif [[ $(uname -s) = "freebsd" ]]; then
# TODO: finish when I have a freebsd system
alias la="ls -ahl"
fi
VIRTUALENV_PATHS=(
"/usr/bin/virtualenvwrapper.sh"
"/usr/local/bin/virtualenvwrapper.sh"
"/opt/homebrew/bin/virtualenvwrapper.sh")
for VIRTUALENV in ${VIRTUALENV_PATHS[@]}
do
if [[ -f $VIRTUALENV ]]; then
source $VIRTUALENV
break
fi
done
unset VIRTUALENV_PATHS
# if type kitty >/dev/null 2>&1; then
# alias icat="kitty +kitten icat"
# alias kssh="kitty +kitten ssh"
# fi