source: trunk/debathena/debathena/dotfiles/bashrc @ 25099

Revision 25099, 4.4 KB checked in by jdreed, 13 years ago (diff)
Quote $command in cshrc Add a space to the scp case statement in bashrc, to catch all the users executing scp-sux-my-binary-is-cooler
Line 
1# Global bashrc file
2#
3# $Id: bashrc,v 1.39 2006-07-17 23:14:07 rbasch Exp $
4
5# This file is sourced by default user file ~/.bashrc
6
7initdir=/usr/lib/init
8
9# Determine if we're in an sftp or scp session and if so, be quiet
10SILENT=no
11case "$BASH_EXECUTION_STRING" in
12    /usr/lib/openssh/sftp-server)
13        SILENT=yes
14        ;;
15    scp\ *)
16        SILENT=yes
17        ;;
18esac
19
20# *******************   ENVIRONMENT SETUP   *******************
21
22# Set up standard system/user environment configuration (including setup of
23# environment variables, attachment of lockers, and setting of search path)
24
25# If we see ENV_SET set to empty, we could be a tcsh user who has
26# decided to run bash, or we could be a bash user suffering from the
27# misfeature that the standard xsession script runs the tcsh dotfiles
28# for all users.  Running the environment setup for the former
29# category of user would be unfriendly (it resets the homedir and
30# changes the path), so for now, only run environment setup for bash
31# users.  If the xsession problem is ever fixed, change this
32# conditional to check for '"${ENV_SET+set}" != set' and eliminate the
33# shell check.
34if [ "${ENV_SET:+set}" != set -a "${SHELL##*/}" = bash ]; then
35
36        export ENV_SET=t                        # Avoid unnecessary repeat
37        export HOSTTYPE="`/bin/machtype`"
38
39        # Ensure user's homedir is attached, for legacy things
40        # that care about attachtab
41        # Only attach if running as an Athena user, not e.g. using sudo.
42        if [ "$DEBATHENA_HOME_TYPE" = afs ]; then
43                /bin/attach -h -q "${ATHENA_USER:-$USER}"
44        fi
45
46        if [ -r "$HOME/.generation" ]; then
47                export ATHENA_DOTFILE_GENERATION=`cat "$HOME/.generation"`
48        else
49                export ATHENA_DOTFILE_GENERATION=0
50        fi
51
52        ulimit -S -c 0                          # Don't allow coredumps
53        export EDITOR=emacs                     # Set default editor
54        export MM_CHARSET=iso-8859-1
55
56        export EMAIL="$USER@mit.edu"            # Set default email address
57
58        export MORE=-s
59
60        export ATHENA_SYS=`/bin/machtype -S`
61        export ATHENA_SYS_COMPAT=`/bin/machtype -C`
62
63        if [ -z "$ATHENA_SYS" ]; then
64                export ATHENA_SYS=@sys
65        fi
66
67        if [ "${PRINTER+set}" != set \
68          -a -e /var/run/athena-clusterinfo.csh ]; then
69                PRINTER=`awk '/LPR/ { print $3 }' \
70                  /var/run/athena-clusterinfo.csh`
71                if [ -n "$PRINTER" ]; then export PRINTER; fi
72        fi
73
74        # Reset the HOME variable to correspond to the actual location
75        # of the user's home directory.  This will avoid having long
76        # pathnames being printed when /mit/<user> is a symlink to a
77        # path within AFS.
78
79        x=`(cd && /bin/pwd) 2>/dev/null`
80        if [ -n "$x" ]; then
81                export HOME=$x
82                if [ "$x" = "`/bin/pwd`" ]; then
83                        cd "$HOME"
84                fi
85        fi
86        unset x
87
88        # Run user environment customizations identified in your
89        # ~/.bash_environment file.  This is the place to include your
90        # own environment variables, attach commands, and other system
91        # wide setup commands.  You can also cancel default behaviors
92        # listed above.
93        # ~/.bash_environment is not sourced if NOCALLS is set (i.e.,
94        # if you selected the xlogin "Ignore your customizations"
95        # option when you logged in).
96
97        if [ "${NOCALLS+set}" != set -a -r ~/.bash_environment ]; then
98            if [ "$SILENT" = "yes" ]; then
99                . ~/.bash_environment &> /dev/null
100            else
101                . ~/.bash_environment
102            fi
103        fi
104
105        # If the user has a bindir in $HOME, put it in front of the path.
106        athena_home_bin=$( /usr/bin/athdir "$HOME" )
107        PATH=${athena_home_bin:+$athena_home_bin:}$PATH
108        unset athena_home_bin
109
110fi
111
112
113# *******************  BASH SETUP   *******************
114
115# Set up standard bash shell initializations
116
117if [ "${XSESSION+set}" = set ]; then
118        logout () { gnome-session-save --kill --silent; exit; } # logout for X
119fi
120
121#   aliases dealing with adding locker programs
122
123setup_tty () {(export SUBJECT="$@"; $SHELL)}
124setup_X () {(export SUBJECT="$@"; xterm -title "$@" &)}
125
126if [ -n "$XSESSION" ]; then
127   alias setup=setup_X
128else
129   alias setup=setup_tty
130fi
131
132remove () { export SUBJECT="$@";
133            source $initdir/env_remove.bash;
134            unset SUBJECT; }
135
136if [ -n "$SUBJECT" -a -r $initdir/env_setup.bash ]; then
137        source $initdir/env_setup.bash
138fi
139
140
141# All of the bash initializing commands above can be overridden by using
142# "unset" or "unalias" commands (or by changing things using "set" or
143# "alias" again) in your ~/.bashrc.mine file, which is sourced here.
144# ~/.bashsrc.mine is not sourced if the xlogin "Ignore your customizations"
145# option was selected to begin the session.
146
147if [ "${NOCALLS+set}" != set -a -r ~/.bashrc.mine ]; then
148    if [ "$SILENT" = "yes" ]; then
149        . ~/.bashrc.mine &> /dev/null
150    else
151        . ~/.bashrc.mine
152    fi
153fi
Note: See TracBrowser for help on using the repository browser.