diff options
Diffstat (limited to 'bash/.bash_aliases')
| -rw-r--r-- | bash/.bash_aliases | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/bash/.bash_aliases b/bash/.bash_aliases index 7ec2ad1..0eafcad 100644 --- a/bash/.bash_aliases +++ b/bash/.bash_aliases @@ -17,16 +17,29 @@ alias ras='sudo nixos-rebuild switch --flake .#' # Tmux tm() { + # Handle specific session attachment (standard behavior). if [ -n "$1" ]; then - # If an argument is provided, try to attach to it or create it. tmux attach-session -t "$1" 2>/dev/null || tmux new-session -s "$1" - elif tmux has-session 2>/dev/null; then - # No argument? Open the alphabetical list. - tmux attach-session \; choose-tree -sZ -O name - else - # Nothing running? Fresh start. - tmux + return fi + + # If no tmux server is running at all. + if ! tmux has-session 2>/dev/null; then + # Start a dummy session in the background to kickstart the server. + tmux new-session -d -s "init" + + # Trigger the restore script. + RESURRECT_SCRIPT="$HOME/.config/tmux/plugins/tmux-resurrect/scripts/restore.sh" + + if [ -f "$RESURRECT_SCRIPT" ]; then + tmux run-shell "$RESURRECT_SCRIPT" + # Kill the dummy session once restored. + tmux kill-session -t "init" 2>/dev/null + fi + fi + + # Attach and show the tree. + tmux attach-session -t "main" 2>/dev/null || tmux attach-session \; choose-tree -sZ -O name } # Edit NixOS Sops secret files. |
