moved tmux before sourcing

This commit is contained in:
Tomasz Kapias 2023-03-19 15:08:59 +07:00
parent 802196aaa8
commit ac5ce1fbe6
Signed by: tkapias
SSH key fingerprint: SHA256:bsmasrX7y0xxAHa/x1x8zAgHInO4nPpKMk5JIQ0Vsbw
4 changed files with 31 additions and 36 deletions

10
.bashrc
View file

@ -10,6 +10,16 @@ esac
chmod 700 ~/.bashrc.d chmod 700 ~/.bashrc.d
chmod 600 ~/.bashrc ~/.bashrc.d/* chmod 600 ~/.bashrc ~/.bashrc.d/*
# 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
systemd-run -q --scope --user --unit tmux-session-local tmux new-session -A -s local && exit
elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && command -v tmux 1> /dev/null; then
# open/attach the SSH default Tmux session
systemd-run -q --scope --user --unit tmux-session-ssh tmux new-session -A -s ssh && exit
fi
# if Tmux is not installed or if we are inside a Tmux session continue the sourcing
for file in ~/.bashrc.d/*.bashrc; for file in ~/.bashrc.d/*.bashrc;
do do
source "${file}" source "${file}"

View file

@ -23,7 +23,7 @@ else
alias grep='grep -a' alias grep='grep -a'
fi fi
# most common usage of df/du # most common usage of df/du
if command -v hl 1> /dev/null; then if command -v hl 1> /dev/null; then
alias df='df -Tha --total | hlauto --df' alias df='df -Tha --total | hlauto --df'
else else
@ -31,7 +31,7 @@ else
fi fi
alias du='du -ach' alias du='du -ach'
# better ncdu # better ncdu
if command -v ncdu 1> /dev/null; then if command -v ncdu 1> /dev/null; then
alias ncdu='ncdu -e --exclude-kernfs --color dark' alias ncdu='ncdu -e --exclude-kernfs --color dark'
fi fi
@ -100,7 +100,7 @@ if command -v xclip 1> /dev/null; then
# shortcuts to copy/paste text contents # shortcuts to copy/paste text contents
alias xclip-in-txt='xclip -in -rmlastnl -selection clipboard' alias xclip-in-txt='xclip -in -rmlastnl -selection clipboard'
alias xclip-txt-out='xclip -out -rmlastnl -selection clipboard' alias xclip-txt-out='xclip -out -rmlastnl -selection clipboard'
# shortcuts to copy/paste other contents # shortcuts to copy/paste other contents
alias xclip-in-png='xclip -in -selection clipboard -t image/png' alias xclip-in-png='xclip -in -selection clipboard -t image/png'
alias xclip-in-jpeg='xclip -in -selection clipboard -t image/jpeg' alias xclip-in-jpeg='xclip -in -selection clipboard -t image/jpeg'
alias xclip-in-gif='xclip -in -selection clipboard -t image/gif' alias xclip-in-gif='xclip -in -selection clipboard -t image/gif'
@ -137,15 +137,16 @@ if command -v et 1> /dev/null; then
alias etmotd='et --ssh-option SetEnv=SSH_MOTD=1' alias etmotd='et --ssh-option SetEnv=SSH_MOTD=1'
fi fi
# open a new tmux session named ssh_tmux or attach to it # open/attach to a default tmux session named local or ssh
if command -v tmux 1> /dev/null; then if command -v tmux 1> /dev/null; then
alias tmuxs='tmux new-session -A -s ssh_tmux && exit' alias tmux-local='systemd-run -q --scope --user --unit tmux-session-local tmux new-session -A -s local && exit'
alias tmux-ssh='systemd-run -q --scope --user --unit tmux-session-ssh tmux new-session -A -s ssh && exit'
fi fi
# vifm: tui file explorer # vifm: tui file explorer
if command -v vifmrun 1> /dev/null && command -v vifm 1> /dev/null; then if command -v vifmrun 1> /dev/null && command -v vifm 1> /dev/null; then
alias vifm='vifmrun' alias vifm='vifmrun'
alias vf='vifmrun' alias vf='vifmrun'
fi fi
# dragon for drag&drop function # dragon for drag&drop function
@ -156,11 +157,11 @@ fi
# glow: tui/cli markdown pager explorer # glow: tui/cli markdown pager explorer
if command -v glow 1> /dev/null; then if command -v glow 1> /dev/null; then
alias glw='glow -l -p -w 80 -s dark' alias glw='glow -l -p -w 80 -s dark'
fi fi
if command -v tidy-viewer 1> /dev/null; then if command -v tidy-viewer 1> /dev/null; then
alias tv='tidy-viewer' alias tv='tidy-viewer'
fi fi
# HLEDGER # HLEDGER
@ -173,24 +174,24 @@ alias meteo='echo -e "┌─────────┐\n│ wttr.in │ ${MYCIT
# mimic3: tts interactive command, just paste text inside # mimic3: tts interactive command, just paste text inside
if command -v mimic3 1> /dev/null; then if command -v mimic3 1> /dev/null; then
alias mimic3-fr='mimic3 --voice fr_FR/tom_low --play-program paplay --interactive' alias mimic3-fr='mimic3 --voice fr_FR/tom_low --play-program paplay --interactive'
alias mimic3-en='mimic3 --voice en_US/ljspeech_low --play-program paplay --interactive' alias mimic3-en='mimic3 --voice en_US/ljspeech_low --play-program paplay --interactive'
alias mimic3-pl='mimic3 --voice pl_PL/m-ailabs_low --play-program paplay --interactive' alias mimic3-pl='mimic3 --voice pl_PL/m-ailabs_low --play-program paplay --interactive'
fi fi
# Neomutt, notmuch, mbsync # Neomutt, notmuch, mbsync
if command -v neomutt 1> /dev/null; then if command -v neomutt 1> /dev/null; then
alias ntt='neomutt -f "📫Boite à lettres"' alias ntt='neomutt -f "📫Boite à lettres"'
if command -v notmuch 1> /dev/null && command -v mbsync 1> /dev/null; then if command -v notmuch 1> /dev/null && command -v mbsync 1> /dev/null; then
# Sync all Mailboxes, Notmuch and Afew, then launch Neomutt # Sync all Mailboxes, Notmuch and Afew, then launch Neomutt
alias ntt-sync='notmuch new && mbsync mutt && notmuch new && neomutt -f "📫Boite à lettres"' alias ntt-sync='notmuch new && mbsync mutt && notmuch new && neomutt -f "📫Boite à lettres"'
# Sync some Mailboxes, Notmuch and Afew, then launch Neomutt # Sync some Mailboxes, Notmuch and Afew, then launch Neomutt
alias ntt-sync-base='notmuch new && mbsync mutt-fast && notmuch new && neomutt -f "📫Boite à lettres"' alias ntt-sync-base='notmuch new && mbsync mutt-fast && notmuch new && neomutt -f "📫Boite à lettres"'
# Reindex Notmuch and Afew for main, then launch Neomutt # Reindex Notmuch and Afew for main, then launch Neomutt
alias ntt-index='notmuch new && neomutt -f "📫Boite à lettres"' alias ntt-index='notmuch new && neomutt -f "📫Boite à lettres"'
fi fi
if command -v msmtp-queue 1> /dev/null; then if command -v msmtp-queue 1> /dev/null; then
# Flush send mail queue with msmtpq, then launch Neomutt # Flush send mail queue with msmtpq, then launch Neomutt
alias ntt-flush='msmtp-queue -r && neomutt -f "📫Boite à lettres"' alias ntt-flush='msmtp-queue -r && neomutt -f "📫Boite à lettres"'
fi fi
fi fi

View file

@ -86,16 +86,6 @@ c() {
fi fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# shortcut for tmux to open a new default session with a name or attach if it exist
# an alias tmuxs exist too for ssh sessions
if command -v tmux 1> /dev/null; then
tmuxa() {
systemd-run -q --scope --user tmux new-session -A -s default "$@"
exit
}
fi
# ============================== # ==============================
# Utils # Utils
# ============================== # ==============================

View file

@ -5,16 +5,10 @@
# AUTOSTART # AUTOSTART
# ============================== # ==============================
# run tmux if TMUX variable is null # run MOTD at login only in an ssh session containing the env $SSH_MOTD=1
if [[ "${TERM-}" != tmux* ]] && [[ -z "${TMUX}" ]] && [[ -z "${SSH_CONNECTION}" ]]; then
tmuxa
elif [[ -z "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]]; then
tmuxs
fi
# run MOTD at login only in an ssh session
if [[ -n "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && [[ "${SSH_MOTD-}" == 1 ]] && [[ -f "/etc/update-motd.d/00-motdfetch" ]]; then if [[ -n "${TMUX}" ]] && [[ -n "${SSH_CONNECTION}" ]] && [[ "${SSH_MOTD-}" == 1 ]] && [[ -f "/etc/update-motd.d/00-motdfetch" ]]; then
motd motd
else else
# use function pgdown to get the prompt to terminal window bottom # use function pgdown to get the prompt to terminal window bottom
pgdown pgdown
fi fi