diff --git a/.gitconfig b/.gitconfig index 43acf1d..033077b 100644 --- a/.gitconfig +++ b/.gitconfig @@ -1,3 +1,5 @@ +[core] + excludesfile = $HOME/.gitignore_global [alias] br = branch brr = branch -r @@ -6,24 +8,20 @@ st = status cm = commit -m aa = add --all . - show-origin-url = remote get-url origin + show-origin-url = remote get-url origin cam = !git add --all . && git commit --amend --no-edit rbs = !git checkout main && git pull && git checkout - && git rebase main cop = "!f() { git checkout ${1-main}; git pull; }; f" lazy = commit -C HEAD@{1} cp = cherry-pick - anne = commit --amend --no-edit + cane = commit --amend --no-edit [init] defaultBranch = main [pull] ff = only -[user] - name = Tom Hicks - email = headhunter3@gmail.com -[http] - lowSpeedLimit = 1000 - lowSpeedTime = 60 - postBuffer = 524288000 +[color "status"] + added = brightgreen + untracked = brightred [filter "lfs"] clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f diff --git a/.gitignore b/.gitignore index 6daba93..6e3376f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +/* +!/.* /history /.vscode/extensions diff --git a/.gitignore_global b/.gitignore_global index 93bfd12..1ff8358 100644 --- a/.gitignore_global +++ b/.gitignore_global @@ -1,2 +1,3 @@ *~ .DS_Store +._* diff --git a/.profile b/.profile index ab2b9e7..d42f5ca 100644 --- a/.profile +++ b/.profile @@ -1,28 +1,4 @@ -# ~/.profile: executed by the command interpreter for login shells. -# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login -# exists. -# see /usr/share/doc/bash/examples/startup-files for examples. -# the files are located in the bash-doc package. +. "$HOME/.cargo/env" -# the default umask is set in /etc/profile; for setting the umask -# for ssh logins, install and configure the libpam-umask package. -#umask 022 - -# TODO: Do this for zsh and exec $HOME/.zshrc? -# if running bash -if [ -n "$BASH_VERSION" ]; then - # include .bashrc if it exists - if [ -f "$HOME/.bashrc" ]; then - . "$HOME/.bashrc" - fi -fi - -# set PATH so it includes user's private bin if it exists -if [ -d "$HOME/bin" ] ; then - PATH="$HOME/bin:$PATH" -fi - -# set PATH so it includes user's private bin if it exists -if [ -d "$HOME/.local/bin" ] ; then - PATH="$HOME/.local/bin:$PATH" -fi +# Hermes Agent — ensure ~/.local/bin is on PATH +export PATH="$HOME/.local/bin:$PATH" diff --git a/.rc.d/ls-colors.sh b/.rc.d/ls-colors.sh index dff98f8..3a2cf02 100755 --- a/.rc.d/ls-colors.sh +++ b/.rc.d/ls-colors.sh @@ -1,5 +1,6 @@ -# zsh -export LSCOLORS=FxGxedGdCxxExFHBDBbcbd - -# bash -export LS_COLORS="rs=0:di=95:ln=36:mh=00:pi=96;43:so=34;43:do=34;43:bd=104:cd=105:or=5;96;40:mi=5;30;46:su=97;101:sg=93;101:ca=00:tw=91;42:ow=91;43:st=42:ex=92:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:" +# See ls-color.md for an explanation of the formats. +if [ -n "$BASH_VERSION" ]; then + export LS_COLORS="rs=0:di=95:ln=36:mh=00:pi=96;43:so=34;43:do=34;43:bd=104:cd=105:or=5;96;40:mi=5;30;46:su=97;101:sg=93;101:ca=00:tw=91;42:ow=91;43:st=42:ex=92:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:" +elif [ -n "$ZSH_VERSION" ]; then + export LSCOLORS=FxGxedGdCxxExFHBDBbcbd +fi diff --git a/.rc.d/node.sh b/.rc.d/node.sh new file mode 100644 index 0000000..bf5691b --- /dev/null +++ b/.rc.d/node.sh @@ -0,0 +1,92 @@ +# Setup Node.js environment: NVM (preferred), system/fallback Node, NPM global bin, and Yarn +_setup_node() { + _add_to_path() { + [ -d "$1" ] || return 0 + case ":$PATH:" in + *":$1:"*) ;; + *) PATH="$1:$PATH"; export PATH ;; + esac + } + + _nvm_active=0 + + # 1. Check for NVM and prefer NVM node version + if [ -z "$NVM_DIR" ]; then + if [ -d "$HOME/.nvm" ]; then + export NVM_DIR="$HOME/.nvm" + elif [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/nvm" ]; then + export NVM_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nvm" + elif [ -d "/opt/homebrew/opt/nvm" ]; then + export NVM_DIR="/opt/homebrew/opt/nvm" + fi + fi + + if [ -n "$NVM_DIR" ] && [ -d "$NVM_DIR" ]; then + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + + if command -v nvm >/dev/null 2>&1 || type nvm >/dev/null 2>&1; then + nvm use --silent 2>/dev/null || nvm use --silent default 2>/dev/null || nvm use --silent node 2>/dev/null + fi + + if [ -n "$NVM_BIN" ] && [ -d "$NVM_BIN" ]; then + _nvm_active=1 + fi + fi + + # 2. If NVM is not available or has no active node, fallback to system/global node installs + if [ "$_nvm_active" -eq 0 ]; then + if ! command -v node >/dev/null 2>&1; then + for _node_dir in \ + /opt/homebrew/opt/node/bin \ + /opt/homebrew/bin \ + /usr/local/bin \ + /usr/bin \ + /usr/local/nodejs/bin \ + /usr/local/node/bin \ + "$HOME/.local/bin" + do + if [ -x "$_node_dir/node" ]; then + _add_to_path "$_node_dir" + break + fi + done + fi + fi + + # 3. Setup NPM global binaries (for system node or custom npm prefix) + if [ "$_nvm_active" -eq 0 ] && command -v npm >/dev/null 2>&1; then + _npm_prefix="$(npm config get prefix 2>/dev/null || npm prefix -g 2>/dev/null)" + if [ -n "$_npm_prefix" ] && [ -d "$_npm_prefix/bin" ]; then + _add_to_path "$_npm_prefix/bin" + fi + unset _npm_prefix + elif [ -d "$HOME/.npm-global/bin" ]; then + _add_to_path "$HOME/.npm-global/bin" + fi + + # 4. Setup Yarn global bin if yarn is available + if command -v yarn >/dev/null 2>&1; then + _yarn_bin="$(yarn global bin 2>/dev/null)" + if [ -n "$_yarn_bin" ] && [ -d "$_yarn_bin" ]; then + _add_to_path "$_yarn_bin" + fi + unset _yarn_bin + fi + + # 5. Guarantee NVM active node takes precedence over any global node in PATH + if [ "$_nvm_active" -eq 1 ] && [ -n "$NVM_BIN" ] && [ -d "$NVM_BIN" ]; then + _clean_path=":$PATH:" + _clean_path="${_clean_path//:$NVM_BIN:/:}" + _clean_path="${_clean_path#:}" + _clean_path="${_clean_path%:}" + PATH="$NVM_BIN:$_clean_path" + export PATH + unset _clean_path + fi + + unset _nvm_active +} +_setup_node +unset -f _setup_node _add_to_path + diff --git a/.rc.d/nvm.sh b/.rc.d/nvm.sh deleted file mode 100755 index 01bfea3..0000000 --- a/.rc.d/nvm.sh +++ /dev/null @@ -1,11 +0,0 @@ -function anon() { - local nvm_dir="$HOME/.nvm" - - if [ -d $nvm_dir ]; then - [ -s $nvm_dir/nvm.sh ] && \. $nvm_dir/nvm.sh # This loads nvm - [ -s $nvm_dir/bash_completion ] && \. $nvm_dir/bash_completion # This loads nvm bash_completion - export NVM_DIR=$nvm_dir - fi - unset -f anon -} -anon diff --git a/.rc.d/pkgconfig.sh b/.rc.d/pkgconfig.sh new file mode 100644 index 0000000..d0326e8 --- /dev/null +++ b/.rc.d/pkgconfig.sh @@ -0,0 +1,48 @@ +# Setup PKG_CONFIG_PATH for Apple Silicon Homebrew on macOS and LSB/standard paths on Linux +_setup_pkgconfig() { + [ -n "$ZSH_VERSION" ] && setopt localoptions nonomatch nullglob + + _add_pkg_config_path() { + [ -d "$1" ] || return 0 + case ":${PKG_CONFIG_PATH}:" in + *":$1:"*) ;; + *) + if [ -n "$PKG_CONFIG_PATH" ]; then + PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:$1" + else + PKG_CONFIG_PATH="$1" + fi + ;; + esac + } + + # macOS: Apple Silicon Homebrew + if [ -d "/opt/homebrew" ]; then + _add_pkg_config_path "/opt/homebrew/lib/pkgconfig" + _add_pkg_config_path "/opt/homebrew/share/pkgconfig" + for _dir in /opt/homebrew/opt/*/lib/pkgconfig \ + /opt/homebrew/opt/*/share/pkgconfig; do + _add_pkg_config_path "$_dir" + done + fi + + # Linux (apt / rpm / LSB / manual build & install paths) and user paths + for _dir in \ + "$HOME/.local/lib/pkgconfig" \ + "$HOME/.local/share/pkgconfig" \ + /usr/local/lib/pkgconfig \ + /usr/local/lib64/pkgconfig \ + /usr/local/share/pkgconfig \ + /usr/lib/pkgconfig \ + /usr/lib64/pkgconfig \ + /usr/share/pkgconfig \ + /usr/lib/*-linux-gnu*/pkgconfig \ + /usr/local/lib/*-linux-gnu*/pkgconfig + do + _add_pkg_config_path "$_dir" + done + + export PKG_CONFIG_PATH +} +_setup_pkgconfig +unset -f _setup_pkgconfig _add_pkg_config_path diff --git a/.rc.d/pkgconfig.sh.disabled b/.rc.d/pkgconfig.sh.disabled deleted file mode 100644 index 1b04c97..0000000 --- a/.rc.d/pkgconfig.sh.disabled +++ /dev/null @@ -1,7 +0,0 @@ -# TODO: Find a way to make this automatic so pkgconfig works for anything installed via homebrew. -# See java.sh for details, but we can enumerate folders under /opt/homebrew/Cellar/*/*/lib/pkgconfig and add them all. -PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/homebrew/Cellar/libpng/1.6.40/lib/pkgconfig -PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/homebrew/Cellar/zlib/1.3/lib/pkgconfig -# PKG_CONFIG_PATH=$PKG_CONFIG_PATH: - -export PKG_CONFIG_PATH \ No newline at end of file diff --git a/.rc.d/yt-dlp.sh b/.rc.d/yt-dlp.sh new file mode 100644 index 0000000..a0326bf --- /dev/null +++ b/.rc.d/yt-dlp.sh @@ -0,0 +1,55 @@ +# Define yt-dlp functions with dynamic JavaScript runtime (Node.js) detection +yt-dlp() { + local _cmd="yt-dlp" + if ! command -v yt-dlp >/dev/null 2>&1; then + if [ -x "/opt/homebrew/bin/yt-dlp" ]; then + _cmd="/opt/homebrew/bin/yt-dlp" + elif [ -x "/usr/local/bin/yt-dlp" ]; then + _cmd="/usr/local/bin/yt-dlp" + elif [ -x "$HOME/.local/bin/yt-dlp" ]; then + _cmd="$HOME/.local/bin/yt-dlp" + else + echo "yt-dlp: command not found" >&2 + return 127 + fi + fi + + if command -v node >/dev/null 2>&1; then + command $_cmd --js-runtimes "node:$(command -v node)" "$@" + else + command $_cmd "$@" + fi +} + +yt-dlp-best() { + yt-dlp -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]" "$@" +} + +yt-dlp-audio-meta() { + yt-dlp \ + -f "ba[ext=m4a]/ba" \ + -x --audio-format m4a \ + --embed-metadata --embed-thumbnail \ + "$@" +} + +yt-dlp-formats() { + yt-dlp -F "$@" +} + +yt-dlp-playlist-audio() { + yt-dlp \ + --yes-playlist \ + --embed-metadata --embed-thumbnail \ + -f "ba[ext=m4a]/ba" \ + -o "%(playlist_title,playlist_id)s/%(playlist_index)03d - %(title)s.%(ext)s" \ + "$@" +} + +yt-dlp-playlist() { + yt-dlp \ + --yes-playlist \ + --embed-metadata --embed-thumbnail \ + -o "%(playlist_title,playlist_id)s/%(playlist_index)03d - %(title)s.%(ext)s" \ + "$@" +} diff --git a/.yarnrc b/.yarnrc index 62d7557..37b9ffe 100644 --- a/.yarnrc +++ b/.yarnrc @@ -2,4 +2,4 @@ # yarn lockfile v1 -lastUpdateCheck 1768790207834 +lastUpdateCheck 1726638947230 diff --git a/.zprofile b/.zprofile index a153e75..d080cbb 100644 --- a/.zprofile +++ b/.zprofile @@ -14,21 +14,5 @@ # ~/.zlogin ##fi -# set PATH so it includes user's private bin if it exists -if [ -d "$HOME/bin" ] ; then - PATH="$HOME/bin:$PATH" -fi - -# set PATH so it includes user's private bin if it exists -if [ -d "$HOME/.local/bin" ] ; then - PATH="$HOME/.local/bin:$PATH" -fi - -## ZSH version of this -# # if running bash -# if [ -n "$BASH_VERSION" ]; then -# # include .bashrc if it exists -# if [ -f "$HOME/.bashrc" ]; then -# . "$HOME/.bashrc" -# fi -# fi +# Hermes Agent — ensure ~/.local/bin is on PATH +export PATH="$HOME/.local/bin:$PATH" diff --git a/.zshrc b/.zshrc index 00d3356..b0e93f3 100644 --- a/.zshrc +++ b/.zshrc @@ -1,4 +1,30 @@ # Consider moving these to a script in .rc.d if they don't need to be before the other scripts in there. +# If Apple Silicon Homebrew is installed activate it. +if [ -x "/usr/local/homebrew/bin/brew" ]; then + eval "$(/usr/local/homebrew/bin/brew shellenv)" + # If x86_64 Homebrew is installed alias it to brew86. + if [ -x "/opt/homebrew/bin/brew" ]; then + alias brew86='arch -x86_64 /usr/local/homebrew/bin/brew' + fi +fi +# If x86_64 Homebrew is installed activate it. +if [ -x "/opt/homebrew/bin/brew" ]; then + eval "$(/opt/homebrew/bin/brew shellenv)" + # If Apple Silicon Homebrew is installed alias it to brewarm. + if [ -x "/usr/local/homebrew/bin/brew" ]; then + alias brewarm='arch -arm64 /opt/homebrew/bin/brew' + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi # Activate ZSH autocompletion. autoload -Uz compinit @@ -17,30 +43,16 @@ fpath=( ~/.zsh_functions "${fpath[@]}" ) setopt HIST_IGNORE_SPACE setopt HIST_IGNORE_DUPS setopt INC_APPEND_HISTORY -setopt histignorealldups sharehistory HISTSIZE=1000 SAVEHIST=10000 # TODO: Look for an equivalent for `shopt -s checkwinsize` # I don't even remember what it does, but I think it's bash specific. -# zstyle ':completion:*' auto-description 'specify: %d' -# zstyle ':completion:*' completer _expand _complete _correct _approximate -# zstyle ':completion:*' format 'Completing %d' -# zstyle ':completion:*' group-name '' -# zstyle ':completion:*' menu select=2 -# eval "$(dircolors -b)" -# zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} -# zstyle ':completion:*' list-colors '' -# zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s -# zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' -# zstyle ':completion:*' menu select=long -# zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s -# zstyle ':completion:*' use-compctl false -# zstyle ':completion:*' verbose true +# Added by cua-driver-rs installer — see https://github.com/trycua/cua +export PATH="/Users/tom/.local/bin:$PATH" -# zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' -# zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' +# Added by cua-driver-rs installer — see https://github.com/trycua/cua +export PATH="/Users/tom/.local/bin:$PATH" -# Initialize profile environment [ -f "$HOME/.init_profile" ] && . "$HOME/.init_profile"