Skip to content

Instantly share code, notes, and snippets.

@tobynet
Created August 7, 2011 09:52
Show Gist options
  • Select an option

  • Save tobynet/1130254 to your computer and use it in GitHub Desktop.

Select an option

Save tobynet/1130254 to your computer and use it in GitHub Desktop.
screen detection test
#!/bin/zsh
echo 'screen から起動されているかチェック'
echo 'screenから起動したshellから起動してください'
echo '結論としては、$STYをチェックするのが良さそうです'
echo
function check_screen() {
echo '## TERMをチェック'
# .screenrcで
# term xterm-256color
# されていると無理っぽい
zsh -c 'echo TERM=$TERM'
zsh -c 'if [[ $TERM = screen* ]]; then echo on-screen; else echo not-screen; fi'
echo
echo '## $STYをチェック'
zsh -c 'echo STY=$STY'
zsh -c 'if [[ -n $STY ]]; then echo on-screen; else echo not-screen; fi'
}
echo '# TERM変更なし'
check_screen
echo
echo '# TERMをxterm-256colorに変更'
TERM=xterm-256color check_screen
screen から起動されているかチェック
screenから起動してください
結論としては、$STYをチェックするのが良さそうです
# TERM変更なし
## TERMをチェック
TERM=screen
on-screen
## $STYをチェック
STY=12345.tty3.unko
on-screen
# TERMをxterm-256colorに変更
## TERMをチェック
TERM=xterm-256color
not-screen
## $STYをチェック
STY=12345.tty3.unko
on-screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment