Files
dotfiles/home/.chezmoitemplates/scripts/commonrc.sh.tmpl
Ryan Walters 9fb2c304f3 feat: add Windows Terminal helper function across all shells
Add `wt` function to launch Windows Terminal with WSL in current directory across Bash, Fish, Nushell, and PowerShell. The function supports passing additional arguments while maintaining the current working directory context.
2025-11-01 11:08:32 -05:00

127 lines
3.6 KiB
Bash

# This template's argument is the shell as a string (bash, ...).
# general configuration
export EDITOR="micro"
export GPG_TTY=$(tty)
export MICRO_TRUECOLOR=1
export TERM=xterm-256color # fixes terminal colors when ssh'ing into laptop
# authentication
export OPENAI_API_KEY="{{ dopplerProjectJson.OPENAI_CHATGPT_CLI }}"
# hishtory
export HISHTORY_SERVER="https://hsh.{{ dopplerProjectJson.PRIVATE_DOMAIN }}"
export PATH="$PATH:$HOME/.hishtory"
{{ if eq .shell "bash" -}}
source $HOME/.hishtory/config.sh
{{- else -}}
{{ fail "Unexpected shell." }}
{{- end }}
export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH=$PATH:~/.local/bin
export PATH=$PATH:/usr/local/go/bin # Go
export PATH="$HOME/go/bin/:$PATH" # Go-installed tools
export PATH="$HOME/.local/share/bob/nvim-bin:$PATH" # Bob, the Neovim package manager
if [ -d "$HOME/.deno" ]; then
. "$HOME/.deno/env" # Deno
fi
. "$HOME/.cargo/env" # Rustup + Cargo + Cargo-installed tools
# Homebrew (cached for performance - reduces startup time by ~14ms)
if [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
BREW_CACHE="$HOME/.cache/brew_env.sh"
BREW_BIN="/home/linuxbrew/.linuxbrew/bin/brew"
# Regenerate cache if: doesn't exist, >7 days old, or brew binary is newer
if [ ! -f "$BREW_CACHE" ] || \
[ $(( $(date +%s) - $(stat -c %Y "$BREW_CACHE" 2>/dev/null || echo 0) )) -gt 604800 ] || \
[ "$BREW_BIN" -nt "$BREW_CACHE" ]; then
mkdir -p "$(dirname "$BREW_CACHE")"
"$BREW_BIN" shellenv > "$BREW_CACHE" 2>/dev/null
fi
[ -f "$BREW_CACHE" ] && . "$BREW_CACHE"
fi
command -v rbenv &> /dev/null && eval "$(rbenv init -)" # rbenv for Ruby
command -v chatgpt &> /dev/null && . <(chatgpt --set-completions {{ .shell -}}) # chatgpt completions
{{ if eq .shell "bash" -}}
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
{{- end }}
# pyenv, python version manager
export PYENV_ROOT="$HOME/.pyenv"
if [[ -d $PYENV_ROOT/bin ]]; then
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv &> /dev/null; then
eval "$(pyenv init -)"
# pyenv virtual-env
eval "$(pyenv virtualenv-init -)"
fi
fi
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# java version manager
if [ -d $HOME/.jenv/bin ]; then
export PATH="$HOME/.jenv/bin:$PATH"
if command -v jenv &> /dev/null
then
eval "$(jenv init -)"
fi
fi
# pnpm
export PNPM_HOME="$HOME/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
# spicetify
if [ -d "$HOME/.spicetify" ]; then
export PATH=$PATH:$HOME/.spicetify
fi
# pulumi
if [ -d "$HOME/.pulumi/bin" ]; then
export PATH=$PATH:$HOME/.pulumi/bin
fi
. $HOME/.bash_aliases
{{- /* WSL-specific settings */ -}}
{{- if .data.wsl }}
## Ensures CLI apps open URLs in the default Windows browser (Chrome/Firefox/etc) instead of a CLI browser
export BROWSER='powershell.exe /c start'
# Cursor IDE CLI (Windows installation accessible from WSL)
[ -x /mnt/c/Users/Xevion/AppData/Local/Programs/cursor/resources/app/bin/cursor ] && \
export PATH="$PATH:/mnt/c/Users/Xevion/AppData/Local/Programs/cursor/resources/app/bin"
# Zed Editor CLI (Windows installation accessible from WSL)
[ -x /mnt/c/Users/Xevion/AppData/Local/Programs/Zed/bin/zed ] && \
export PATH="$PATH:/mnt/c/Users/Xevion/AppData/Local/Programs/Zed/bin"
# Launch Windows Terminal in current directory
wt() {
if [ $# -eq 0 ]; then
wt.exe -w 0 sp wsl --cd "$(pwd)"
else
wt.exe -w 0 "$@" wsl --cd "$(pwd)"
fi
}
{{- end }}
# dotnet
if [ -d "$HOME/.dotnet" ]; then
export DOTNET_ROOT="$HOME/.dotnet"
export PATH="$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools"
fi