Re: Check if running inside script
- In reply to: Andrea Venturoli : "Check if running inside script"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 May 2023 13:12:32 UTC
On 08/05/2023 13:35, Andrea Venturoli wrote: > Is there a way a shell script of mine can check if running inside > sysutils/screen? Check the shell environment. I use tmux(1) in preference to screen(1), and that sets various environment variables which should provide some clues: ``` lucid-nonsense:~:% env | grep -i tmux TMUX_PANE=%0 TMUX=/tmp/tmux-1001/default,36946,0 TERM_PROGRAM=tmux TERM=tmux-256color ``` Hmmm.... actually, screen(1) is installed on my Mac: ``` [misophist]:~:% env| grep -i screen TERM=screen TERMCAP=SC|screen|VT 100/ANSI X3.64 virtual terminal:\ ``` Looks like what you want is the $TERM environment variable. Cheers, Matthew