Skip to content

Instantly share code, notes, and snippets.

@chunibyo-wly
Created September 7, 2024 09:25
Show Gist options
  • Save chunibyo-wly/b36525d17717895fc178998878d8dc6a to your computer and use it in GitHub Desktop.
Save chunibyo-wly/b36525d17717895fc178998878d8dc6a to your computer and use it in GitHub Desktop.
Prevent WSLg suspend when terminal closed
#!/bin/bash
FLAG_FILE="/tmp/startup_script_executed"
if [ ! -f "$FLAG_FILE" ]; then
# Your commands here
echo "Running startup commands..."
# Example: Start a new tmux session with specific windows
tmux new-session -d -s my_session
tmux new-window -t my_session:1 -n "tmux-startup-window" "while true; do echo 1 > /tmp/tmux_output.txt; sleep 1; done"
# Create the flag file
touch "$FLAG_FILE"
fi
& 'C:\Program Files\WSL\wsl.exe' -e /home/chunibyo/.tmux_startup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment