#!/usr/bin/env bash
# ~/.bashrc: sourced by bash(1) for non-login shells.
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return ;;
esac
chmod 700 ~/.bashrc.d
chmod 600 ~/.bashrc ~/.bashrc.d/*
# check if we are already in a Tmux session and not in ssh then open/attach the default one
if [[ ! "${TERM}" == "tmux"* ]] && [[ -z "${TMUX}" ]] && [[ -z "${SSH_CONNECTION}" ]] && command -v tmux 1> /dev/null; then
# attach or start the local default Tmux session
if systemctl --quiet $([[ $(id -u) != 0 ]]; echo "--user") is-active tmux-local-$(id -un).scope; then
tmux -L local-$(id -un) attach-session -t local-$(id -un) ; exit
fi
systemd-run -q --unit tmux-local-$(id -un) --scope $([[ $(id -u) != 0 ]] && echo "--user") tmux -L local-$(id -un) new-session -s local-$(id -un) ; exit
elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && command -v tmux 1> /dev/null; then
# attach or start the ssh default Tmux session
if systemctl --quiet $([[ $(id -u) != 0 ]]; echo "--user") is-active tmux-ssh-$(id -un).scope; then
tmux -L ssh-$(id -un) attach-session -t ssh-$(id -un) ; exit
fi
systemd-run -q --unit tmux-ssh-$(id -un) --scope $([[ $(id -u) != 0 ]] && echo "--user") tmux -L ssh-$(id -un) new-session -s ssh-$(id -un) && exit || echo 'Tmux Systemd unit failed/exited'
fi
# if Tmux is not installed or if we are inside a Tmux session continue the sourcing
for file in ~/.bashrc.d/*.bashrc;
do
source "${file}"
done
But behind that free service, the model was to provide an expensive service to companies needing high frequency testing or scraping (sometime illegal) with multiple ips and locations. I got a trial for 1 week after a visio with them, it was complicated to setup, but it felt like exploiting unknowing free users.