Skip to content

Instantly share code, notes, and snippets.

@tyru
Created August 28, 2010 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyru/554810 to your computer and use it in GitHub Desktop.
Save tyru/554810 to your computer and use it in GitHub Desktop.
is_screen_running() {
# tscreen also uses this varariable.
[ ! -z "$WINDOW" ]
}
is_tmux_runnning() {
[ ! -z "$TMUX" ]
}
is_screen_or_tmux_running() {
is_screen_running || is_tmux_runnning
}
shell_has_started_interactively() {
[ ! -z "$PS1" ]
}
resolve_alias() {
cmd="$1"
while \
whence "$cmd" >/dev/null 2>/dev/null \
&& [ "$(whence "$cmd")" != "$cmd" ]
do
cmd=$(whence "$cmd")
done
echo "$cmd"
}
if ! is_screen_or_tmux_running && shell_has_started_interactively; then
for cmd in tmux tscreen screen; do
if whence $cmd >/dev/null 2>/dev/null; then
$(resolve_alias "$cmd")
break
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment