dotfiles/fish/config.fish
Irrlicht b3bcd18f5a [fish][tmux] Tmux auto start: improve feedback
- Remove output from commands used to test Tmux session
- Add information for when a Tmux session is running
2025-09-24 18:19:02 +02:00

33 lines
1 KiB
Fish

# Function to auto-launch tmux session on start
# If option a/attach is given, will attach to an existing session.
# Does nothing if a session is already running, regardless of whether
# current Fish instance is within a Tmux session or not
function auto_launch_tmux
argparse "a/attach" -- $argv
# Check if already in a tmux session
set value $(string match -r tmux $TERM)
if ! test $status -eq 0
set tmux_session $(tmux ls 2> /dev/null| wc -l)
# Test if there's at least one Tmux session running
if test $tmux_session -eq 0
tmux new
else
if set -ql _flag_attach
tmux attach-session -t 0
else
set -U fish_greeting "A Tmux session is running somewhere, use txl to list them"
end
end
end # else already in Tmux, nothing to do
end
if status is-interactive
set -U fish_greeting
abbr --add txl tmux ls
abbr --add txa tmux a
abbr --add txn tmux new
auto_launch_tmux
end