3 changed files with 111 additions and 42 deletions
@ -1,58 +1,76 @@
|
||||
#!/bin/zsh |
||||
|
||||
if hash vim 2>/dev/null; then |
||||
export EDITOR=vim |
||||
# ------------------------- |
||||
# Editor |
||||
# ------------------------- |
||||
if command -v vim >/dev/null 2>&1; then |
||||
export EDITOR=vim |
||||
else |
||||
export EDITOR=vi |
||||
export EDITOR=vi |
||||
fi |
||||
|
||||
if hash clang 2>/dev/null; then |
||||
export CC=$(which clang) |
||||
else |
||||
export CC=$(which gcc) |
||||
# ------------------------- |
||||
# C / C++ compiler defaults |
||||
# ------------------------- |
||||
if command -v clang >/dev/null 2>&1; then |
||||
export CC="$(command -v clang)" |
||||
elif command -v gcc >/dev/null 2>&1; then |
||||
export CC="$(command -v gcc)" |
||||
fi |
||||
|
||||
if hash clang++ 2>/dev/null; then |
||||
export CXX=$(which clang++) |
||||
else |
||||
export CXX=$(which g++) |
||||
if command -v clang++ >/dev/null 2>&1; then |
||||
export CXX="$(command -v clang++)" |
||||
elif command -v g++ >/dev/null 2>&1; then |
||||
export CXX="$(command -v g++)" |
||||
fi |
||||
|
||||
export OPENSSL_ROOT_DIR=$(which openssl) |
||||
|
||||
# Add openJDK to path |
||||
export PATH="/usr/local/opt/openjdk/bin:$PATH" |
||||
|
||||
# Ignore duplicates in history to make history less of a hassle to use. |
||||
# ------------------------- |
||||
# History |
||||
# ------------------------- |
||||
# Note: HISTCONTROL is bash-specific, but harmless. |
||||
# ZSH history dedupe should usually be configured with setopt elsewhere. |
||||
export HISTCONTROL=ignoredups |
||||
|
||||
# If go is installed, set the $GOPATH to the projects directory created above. |
||||
if which go > /dev/null; then |
||||
export GOPATH=$HOME/.go |
||||
export PATH=${PATH}:`go env GOPATH`/bin |
||||
fi |
||||
# ------------------------- |
||||
# User paths |
||||
# ------------------------- |
||||
path=("$HOME/bin" $path) |
||||
path=("$HOME/.local/bin" $path) |
||||
|
||||
if [ -d "$HOME/.rvm" ]; then |
||||
export PATH="$PATH:$HOME/.rvm/bin" |
||||
# ------------------------- |
||||
# Go |
||||
# ------------------------- |
||||
if command -v go >/dev/null 2>&1; then |
||||
export GOPATH="$HOME/.go" |
||||
path=("$(go env GOPATH)/bin" $path) |
||||
fi |
||||
|
||||
if [ -f "$HOME/.cargo/env" ]; then |
||||
. "$HOME/.cargo/env" |
||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then |
||||
# If the Go install guide was followed for Linux, |
||||
# /usr/local/go will contain the go binary. |
||||
[[ -d "/usr/local/go/bin" ]] && path=("/usr/local/go/bin" $path) |
||||
fi |
||||
|
||||
if [[ "$OSTYPE" == "linux-gnu" ]]; then |
||||
# If the Go install guide was followed for Linux |
||||
# /usr/local/go will contain the go binary. |
||||
export PATH=$PATH:/usr/local/go/bin |
||||
# ------------------------- |
||||
# Ruby / RVM |
||||
# ------------------------- |
||||
if [[ -d "$HOME/.rvm/bin" ]]; then |
||||
path=("$HOME/.rvm/bin" $path) |
||||
fi |
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then |
||||
# Enable homebrew openssl support |
||||
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/ |
||||
export PATH="/usr/local/opt/llvm/bin:$PATH" |
||||
export PATH="/usr/local/opt/qt/bin:$PATH" |
||||
export PATH="/usr/local/opt/tcl-tk/bin:$PATH" |
||||
# ----------------------------- |
||||
# Rust / Cargo - Let rustup win |
||||
# ----------------------------- |
||||
if [[ -f "$HOME/.cargo/env" ]]; then |
||||
. "$HOME/.cargo/env" |
||||
fi |
||||
|
||||
export PATH=$HOME/bin:/usr/local/bin:$PATH |
||||
|
||||
if [[ -d "$HOME/.cargo/bin" ]]; then |
||||
path=("$HOME/.cargo/bin" $path) |
||||
fi |
||||
# ------------------------- |
||||
# OpenSSL fallback |
||||
# ------------------------- |
||||
if command -v openssl >/dev/null 2>&1; then |
||||
export OPENSSL_BIN="$(command -v openssl)" |
||||
fi |
||||
|
||||
@ -0,0 +1,51 @@
|
||||
#!/bin/zsh |
||||
|
||||
# ------------------------- |
||||
# macOS-specific setup |
||||
# ------------------------- |
||||
|
||||
# Prefer Apple Silicon Homebrew, fall back to Intel Homebrew. |
||||
if [[ -d "/opt/homebrew" ]]; then |
||||
export HOMEBREW_PREFIX="/opt/homebrew" |
||||
elif [[ -d "/usr/local/Homebrew" || -d "/usr/local/Cellar" ]]; then |
||||
export HOMEBREW_PREFIX="/usr/local" |
||||
fi |
||||
|
||||
if [[ -n "$HOMEBREW_PREFIX" ]]; then |
||||
[[ -d "$HOMEBREW_PREFIX/bin" ]] && path=("$HOMEBREW_PREFIX/bin" $path) |
||||
[[ -d "$HOMEBREW_PREFIX/sbin" ]] && path=("$HOMEBREW_PREFIX/sbin" $path) |
||||
|
||||
# LLVM / clangd / clang-format |
||||
if [[ -d "$HOMEBREW_PREFIX/opt/llvm/bin" ]]; then |
||||
path=("$HOMEBREW_PREFIX/opt/llvm/bin" $path) |
||||
export LDFLAGS="-L$HOMEBREW_PREFIX/opt/llvm/lib ${LDFLAGS:-}" |
||||
export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/llvm/include ${CPPFLAGS:-}" |
||||
fi |
||||
|
||||
# OpenSSL |
||||
if [[ -d "$HOMEBREW_PREFIX/opt/openssl@3" ]]; then |
||||
export OPENSSL_ROOT_DIR="$HOMEBREW_PREFIX/opt/openssl@3" |
||||
export LDFLAGS="-L$OPENSSL_ROOT_DIR/lib ${LDFLAGS:-}" |
||||
export CPPFLAGS="-I$OPENSSL_ROOT_DIR/include ${CPPFLAGS:-}" |
||||
export PKG_CONFIG_PATH="$OPENSSL_ROOT_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}" |
||||
elif [[ -d "$HOMEBREW_PREFIX/opt/openssl" ]]; then |
||||
export OPENSSL_ROOT_DIR="$HOMEBREW_PREFIX/opt/openssl" |
||||
export LDFLAGS="-L$OPENSSL_ROOT_DIR/lib ${LDFLAGS:-}" |
||||
export CPPFLAGS="-I$OPENSSL_ROOT_DIR/include ${CPPFLAGS:-}" |
||||
export PKG_CONFIG_PATH="$OPENSSL_ROOT_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}" |
||||
fi |
||||
|
||||
# OpenJDK |
||||
[[ -d "$HOMEBREW_PREFIX/opt/openjdk/bin" ]] && path=("$HOMEBREW_PREFIX/opt/openjdk/bin" $path) |
||||
|
||||
# Qt |
||||
[[ -d "$HOMEBREW_PREFIX/opt/qt/bin" ]] && path=("$HOMEBREW_PREFIX/opt/qt/bin" $path) |
||||
|
||||
# Tcl/Tk |
||||
[[ -d "$HOMEBREW_PREFIX/opt/tcl-tk/bin" ]] && path=("$HOMEBREW_PREFIX/opt/tcl-tk/bin" $path) |
||||
fi |
||||
|
||||
# Ghostty CLI |
||||
if [[ -d "/Applications/Ghostty.app/Contents/MacOS" ]]; then |
||||
path=("/Applications/Ghostty.app/Contents/MacOS" $path) |
||||
fi |
||||
Loading…
Reference in new issue