bashrc/.bashrc

27 lines
892 B
Bash
Raw Normal View History

2023-03-18 12:49:08 +01:00
#!/usr/bin/env bash
# ~/.bashrc: executed 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/*
2023-03-19 09:08:59 +01:00
# check if we are already in a Tmux session or open/attach the default one
if [[ "${TERM-}" != tmux* ]] && [[ -z "${TMUX}" ]] && [[ -z "${SSH_CONNECTION}" ]] && command -v tmux 1> /dev/null; then
# open/attach the local default Tmux session
2023-03-19 16:09:37 +01:00
systemd-run -q --scope --user tmux new-session -A -s local && exit
2023-03-19 09:08:59 +01:00
elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && command -v tmux 1> /dev/null; then
# open/attach the SSH default Tmux session
2023-03-19 16:09:37 +01:00
systemd-run -q --scope --user tmux new-session -A -s ssh && exit
2023-03-19 09:08:59 +01:00
fi
# if Tmux is not installed or if we are inside a Tmux session continue the sourcing
2023-03-18 12:49:08 +01:00
for file in ~/.bashrc.d/*.bashrc;
do
source "${file}"
done