# # ~/.bashrc # # If not running interactively, don't do anything [[ $- != *i* ]] && return alias ls='ls --color=auto' PS1='[\u@\h \W]\$ ' # Execute tmux in Alacritty if [[ "$TERM" == "alacritty" || "$TERM_PROGRAM" == "WezTerm" ]]; then exec tmux fi # SSH without checking or adding host keys to known_hosts # Useful for cloud server rescue environment & installation alias sshtmp="ssh -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no'" alias moshtmp="mosh --ssh=\"ssh -o 'UserKnownHostsFile /dev/null' -o 'StrictHostKeyChecking no'\"" # SSH with automatic "screen" function sshscr() { [ -z "$1" ] && return ssh -t $@ screen -RR -d } function moshscr() { [ -z "$1" ] && return mosh $@ -- screen -RR -d } # Alternative SSH session for unlocking remote encrypted servers # This requires a standalone known hosts file function sshunlock() { set -o pipefail pass show "Misc/$2" | wl-copy if [ $? -ne 0 ]; then echo "key not found" return fi ssh -o UserKnownHostsFile=~/.ssh/known_hosts_unlock root@$1 -t "zfsunlock" echo "" | wl-copy set +o pipefail } # Show a menu of all known Tailscale nodes for the user to select from function tsselect() { local items=() local hostnames=() while read -r line; do [ -z "$line" ] && continue [[ "$line" =~ ^\# ]] && continue local name=$(echo "$line" | awk '{ print $2 }') local ip=$(echo "$line" | awk '{ print $1 }') items+=("$name ($ip)") hostnames+=("$name") done <<< $(tailscale status --self=false | sort -k 2) _COLUMNS=$COLUMNS # Force options to display in one column COLUMNS=80 select item in "${items[@]}" Cancel; do if [ $REPLY -eq ${#items[@]} ]; then echo "" fi echo ${hostnames[$((REPLY - 1))]} break; done COLUMNS=$_COLUMNS } # SSH shorthands, same as before but for tailscale nodes function moshscrts() { moshscr $(tsselect) } function sshscrts() { sshscr $(tsselect) } function _ssh() { [ -z "$1" ] && return ssh $@ } function sshts() { _ssh $(tsselect) } # Add local to path export PATH="$PATH:~/.local/bin" # Password Store export PASSWORD_STORE_ENABLE_EXTENSIONS=true