Console/SSH/X: How to tell?

Tyler Aviss tjaviss-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue Jun 23 20:27:39 UTC 2009


On Sat, Jun 20, 2009 at 11:00 PM, Robert
Brockway<robert-5LEc/6Zm6xCUd8a0hrldnti2O/JbrIOy at public.gmane.org> wrote:
> On Fri, 19 Jun 2009, Marc Lanctot wrote:
>
>> So what I'd like to do is detect if the session is an xterm/console, or
>> through interactive ssh.. and output the calendar in these cases but
>> not in cases where I scp or execute a command remotely.
>>
>> Can I do this? If so, how?
>
> I change my prompt based on whether I am logged in under X or not:
>
>        case $TERM in
>        xterm)
>                # Cyan prompt, host, tty & date in xterm title (36 denotes
> cyan)
>                export PS1='\[\033]2;\H:\l (\d
> \t)\007\[\033[36m\]\h:\w\$\[\033[m\]'
>                ;;
>        *)
>                # Cyan prompt, time printed in top right hand corner (36
> denotes cyan)
>                export PS1='\[`tput sc;tput cup 0 71`\t`tput
> rc`\]\[\033[36m\]\h:\w\$\[\033[m\] '
>                ;;
>        esac
>
> I only use xterm, not any of the other terminal apps.
>
> Rob
>
> --
> I tried to change the world but they had a no-return policy
> --
> The Toronto Linux Users Group.      Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>

Out of curiosity, would $TERM have a value if you're SCP'ing?
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list