l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2002 Jul 25 14:27

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
[vox-tech] checking for interactive shell in bash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vox-tech] checking for interactive shell in bash



hola,

here's a snippet from my /etc/profile:

   # $TERM is set to "dumb" for scp sessions.
   #
   if [ "$TERM" != "dumb" ]; then
   
      # Stuff for ALL interactive shells
      #
      # Check dir spelling, hash cmds
      shopt -s cdspell checkhash
      # Quiet the console bell
      setterm -bfreq 0
      # No limit to coresizes.
      ulimit -c unlimited
      # Set default file perms as rw-r--r--
      umask 022
      # For ls colors.  nice blinking dangling symlinks!
      eval `dircolors /etc/DIR_COLORS`
   
      # Stuff for non-login shells, like xterms, local and nonlocal
      #
      if [ "$TERM" == "xterm" ]; then
         # Add some extra paths for X
         PATH="$PATH:/usr/X11R6/bin:$HOME/Office52/"
         PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
      fi
   
      # Stuff for local non-login shells (ie local xterms)
      #
      if [ "$DISPLAY" == ":0.0" ]; then
         # Kill the capslock key
         xmodmap -e "remove Lock = Caps_Lock"
         # Turn the X bell off
         xset b off
         # Reset $LINES and $COLUMNS after each command
         shopt -s checkwinsize
      fi
   
   fi

my strategy is this:

   if (any kind of interactive shell at all) {
      do interactive shell stuff (consoles and xterms);

      if (any kind of non-login shell)
         do X-ish stuff (local and non-local);

      if (local non-login shell)
         do X-ish stuff (local only);
   }

the way i check for an interactive shell is by testing $TERM against
"dumb".   i do this because i noticed that scp spawns a shell on the
remote machine and sets TERM to "dumb".

but there are plenty of programs which spawn non-interactive shells, so
i'm thinking that testing against "dumb" isn't the best solution.  it's
specific to scp (i think).

is there a more general way to check for any kind of interactive shell
(both login and non-login)?

hope i got my terminology right...

pete

ps- if anybody has their own hacked bash startup files that they're
proud of, i wouldn't mind seeing what other people are doing.  i could
post mine in its entirety (it's not MUCH longer than what i have above).

-- 
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
EDGE Tech Corp.
For donating some give-aways for our meetings.