claude-code-termux/config/bashrc.snippet

52 lines
2.5 KiB
Plaintext
Raw Normal View History

# === Claude Code for Termux - .bashrc additions ===
# Append these lines to your ~/.bashrc
# Node-gyp / native compilation config
export CFLAGS="-I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib"
export CC=clang
export CXX=clang++
export npm_config_nodedir=$PREFIX
# Add local bin to PATH (for clauded, claude-check-env, etc.)
export PATH="$HOME/.local/bin:$PATH"
# Prevent Claude Code auto-updater (enforced at shell level too)
export DISABLE_AUTOUPDATER=1
# === Optional: helper aliases for samba + mDNS services ===
# Only useful if you set up smbd and mdns-publish (see docs/04-samba.md, docs/03-ssh-mdns-tailscale.md).
alias smb-start='smbd -D -s ~/.config/samba/smb.conf 2>>~/.config/samba/samba-startup.log && echo "Samba started on port 4450"'
alias smb-stop='pkill smbd && echo "Samba stopped"'
alias smb-restart='pkill smbd 2>/dev/null; sleep 1; smbd -D -s ~/.config/samba/smb.conf 2>>~/.config/samba/samba-startup.log && echo "Samba restarted"'
alias smb-status='pgrep -a smbd && echo "Port: 4450" || echo "Samba is not running"'
alias smb-log='tail -50 ~/.config/samba/samba.log'
alias mdns-status='pgrep -af mdns-publish || echo "mDNS publisher is not running"'
alias mdns-restart='pkill -f mdns-publish; sleep 1; nohup python ~/.local/bin/mdns-publish.py >>~/.cache/mdns.log 2>&1 & disown && echo "mDNS restarted"'
alias mdns-stop='pkill -f mdns-publish && echo "mDNS stopped"'
# === Generic host resolver (resolve: mDNS -> Tailscale -> cache) ===
# Works in any command: ping $(resolve lenovo) / curl "http://$(resolve hp62a)"
alias r='resolve'
pingr() { ping -c 3 "$(resolve "$1")"; }
curlr() { local h="$1"; shift; curl "$@" "http://$(resolve "$h")"; }
# HostKeyAlias reuses the known_hosts entry for the Tailscale FQDN
# so SSH-by-IP does not fail host-key verification.
sshr() {
local h="$1"; shift
local canonical="$h"
case "$h" in dell) canonical="dell-latitude3400";; lenovo) canonical="lenovo-ideapad";; esac
ssh -o "HostKeyAlias=${canonical}.${TAILSCALE_DOMAIN:-tailb0bb74.ts.net}" \
"YOUR_USER@$(resolve "$h")" "$@"
}
# === Optional: auto-start samba + mDNS on shell login ===
# Uncomment the block below if you want services up automatically.
# Failures are logged (NOT silenced) — silent failures after a tar restore are the worst class of bug.
#
# mkdir -p ~/.cache
# pgrep -x smbd >/dev/null 2>&1 || smbd -D -s ~/.config/samba/smb.conf 2>>~/.config/samba/samba-startup.log
# pgrep -f "mdns-publish" >/dev/null 2>&1 || nohup python ~/.local/bin/mdns-publish.py >>~/.cache/mdns.log 2>&1 & disown