how to avoid running tmux in vscode-terminal.
If you're like me and have a default attach-session setup in your ~/.zshrc and but don't want VSCode to attach to it, then this is for you.
Just check if the name of parent process != 'code'
# check if parent is foot, then start
tmux_run() {
parent_process=$(ps -p $PPID -o comm=)
if [[ "$parent_process" != "code" ]]; then
if [ -z "$TMUX" ]; then
tmux attach-session -t envy || tmux new -s envy
fi
}
tmux_run
edit: switched to fish
function tmux_run
set parent_process (ps -o comm= -p (ps -o ppid= -p $fish_pid | string trim))
# Check if the parent process is not `code` or `zed-editor`
if not test "$parent_process" = "code" -o "$parent_process" = "zed-editor"
# Check if not already inside a tmux session
if not set -q TMUX
# Attach to tmux session "envy" or create it if it doesn't exist
tmux attach-session -t envy || tmux new -s envy
end
end
end
save the function and add tmux_run to config.fish