[13196] | 1 | # Global bashrc file |
---|
| 2 | # |
---|
[22516] | 3 | # $Id: bashrc,v 1.39 2006-07-17 23:14:07 rbasch Exp $ |
---|
[13196] | 4 | |
---|
| 5 | # This file is sourced by default user file ~/.bashrc |
---|
| 6 | |
---|
[22913] | 7 | initdir=/usr/lib/init |
---|
[13196] | 8 | |
---|
[22913] | 9 | # add alias moved here to avoid having two copies of it. |
---|
[13196] | 10 | |
---|
[22913] | 11 | add () { eval "$( /bin/attach -Padd -b "$@" )" ; } |
---|
[13196] | 12 | |
---|
[22913] | 13 | |
---|
[13196] | 14 | # ******************* ENVIRONMENT SETUP ******************* |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | # Set up standard system/user environment configuration (including setup of |
---|
| 19 | # environment variables, attachment of lockers, and setting of search path) |
---|
| 20 | |
---|
[21129] | 21 | # If we see ENV_SET set to empty, we could be a tcsh user who has |
---|
| 22 | # decided to run bash, or we could be a bash user suffering from the |
---|
| 23 | # misfeature that the standard xsession script runs the tcsh dotfiles |
---|
| 24 | # for all users. Running the environment setup for the former |
---|
| 25 | # category of user would be unfriendly (it resets the homedir and |
---|
[22940] | 26 | # changes the path), so for now, only run environment setup for bash |
---|
| 27 | # users. If the xsession problem is ever fixed, change this |
---|
| 28 | # conditional to check for '"${ENV_SET+set}" != set' and eliminate the |
---|
| 29 | # shell check. |
---|
[21129] | 30 | if [ "${ENV_SET:+set}" != set -a "${SHELL##*/}" = bash ]; then |
---|
[13196] | 31 | |
---|
| 32 | export ENV_SET=t # Avoid unnecessary repeat |
---|
[22913] | 33 | export HOSTTYPE="`/bin/machtype`" |
---|
[13196] | 34 | |
---|
[22975] | 35 | if [ -r "$HOME/.generation" ]; then |
---|
| 36 | export ATHENA_DOTFILE_GENERATION=`cat "$HOME/.generation"` |
---|
| 37 | else |
---|
| 38 | export ATHENA_DOTFILE_GENERATION=0 |
---|
| 39 | fi |
---|
| 40 | |
---|
[13196] | 41 | umask 077 # Strictly protect files |
---|
| 42 | # (does not apply in AFS) |
---|
[21164] | 43 | ulimit -S -c 0 # Don't allow coredumps |
---|
[13196] | 44 | export EDITOR=emacs # Set default editor |
---|
| 45 | export MM_CHARSET=iso-8859-1 |
---|
| 46 | |
---|
[23438] | 47 | export EMAIL="$USER@mit.edu" # Set default email address |
---|
| 48 | |
---|
[22913] | 49 | export MORE=-s |
---|
[13222] | 50 | |
---|
[22975] | 51 | # Set double-sided printing for sufficiently recent users. |
---|
| 52 | if [ 1 -le "$ATHENA_DOTFILE_GENERATION" ]; then |
---|
| 53 | export LPROPT=-Zduplex |
---|
| 54 | fi |
---|
| 55 | |
---|
[22913] | 56 | export ATHENA_SYS=`/bin/machtype -S` |
---|
| 57 | export ATHENA_SYS_COMPAT=`/bin/machtype -C` |
---|
[13196] | 58 | |
---|
[13238] | 59 | if [ -z "$ATHENA_SYS" ]; then |
---|
[13196] | 60 | export ATHENA_SYS=@sys |
---|
[13238] | 61 | fi |
---|
[13196] | 62 | |
---|
[23132] | 63 | if [ "${PRINTER+set}" != set \ |
---|
[23513] | 64 | -a -e /var/run/athena-clusterinfo.csh ]; then |
---|
[23132] | 65 | PRINTER=`awk '/LPR/ { print $3 }' \ |
---|
[23513] | 66 | /var/run/athena-clusterinfo.csh` |
---|
[13196] | 67 | if [ -n "$PRINTER" ]; then export PRINTER; fi |
---|
| 68 | fi |
---|
| 69 | |
---|
| 70 | # Reset the HOME variable to correspond to the actual location |
---|
| 71 | # of the user's home directory. This will avoid having long |
---|
| 72 | # pathnames being printed when /mit/<user> is a symlink to a |
---|
| 73 | # path within AFS. |
---|
[13222] | 74 | |
---|
[22439] | 75 | x=`(cd && /bin/pwd) 2>/dev/null` |
---|
[13196] | 76 | if [ -n "$x" ]; then |
---|
| 77 | export HOME=$x |
---|
[22439] | 78 | if [ "$x" = "`/bin/pwd`" ]; then |
---|
| 79 | cd "$HOME" |
---|
| 80 | fi |
---|
[13196] | 81 | fi |
---|
| 82 | unset x |
---|
| 83 | |
---|
| 84 | # Run user environment customizations identified in your |
---|
| 85 | # ~/.bash_environment file. This is the place to include your |
---|
| 86 | # own environment variables, attach commands, and other system |
---|
| 87 | # wide setup commands. You can also cancel default behaviors |
---|
[13242] | 88 | # listed above. |
---|
[13196] | 89 | # ~/.bash_environment is not sourced if NOCALLS is set (i.e., |
---|
| 90 | # if you selected the xlogin "Ignore your customizations" |
---|
| 91 | # option when you logged in). |
---|
| 92 | |
---|
[13222] | 93 | if [ "${NOCALLS+set}" != set -a -r ~/.bash_environment ]; then |
---|
[13196] | 94 | . ~/.bash_environment |
---|
| 95 | fi |
---|
[13564] | 96 | |
---|
[23030] | 97 | # If the user has a bindir in $HOME, put it in front of the path. |
---|
[22913] | 98 | athena_home_bin=$( /usr/bin/athdir "$HOME" ) |
---|
[23030] | 99 | PATH=${athena_home_bin:+$athena_home_bin:}$PATH |
---|
[22913] | 100 | unset athena_home_bin |
---|
[13196] | 101 | |
---|
| 102 | fi |
---|
| 103 | |
---|
[22913] | 104 | |
---|
[13196] | 105 | # ******************* BASH SETUP ******************* |
---|
| 106 | |
---|
| 107 | # Set up standard bash shell initializations |
---|
| 108 | |
---|
| 109 | # alias for re-establishing authentication |
---|
[22913] | 110 | renew () { kinit -54 $USER && fsid -a && zctl load /dev/null ; } |
---|
[13196] | 111 | |
---|
[13479] | 112 | if [ "${XSESSION+set}" = set ]; then |
---|
[23182] | 113 | logout () { gnome-session-save --kill --silent; exit; } # logout for X |
---|
[13196] | 114 | fi |
---|
| 115 | |
---|
| 116 | # aliases dealing with adding locker programs |
---|
| 117 | |
---|
[23782] | 118 | setup_tty () {(export SUBJECT="$@"; $SHELL)} |
---|
| 119 | setup_X () {(export SUBJECT="$@"; xterm -title "$@" &)} |
---|
[13196] | 120 | |
---|
[23782] | 121 | if [ -n "$XSESSION" ]; then |
---|
| 122 | alias setup=setup_X |
---|
| 123 | else |
---|
| 124 | alias setup=setup_tty |
---|
| 125 | fi |
---|
[13196] | 126 | |
---|
[23782] | 127 | remove () { export SUBJECT="$@"; |
---|
| 128 | source $initdir/env_remove.bash; |
---|
| 129 | unset SUBJECT; } |
---|
| 130 | |
---|
| 131 | if [ -n "$SUBJECT" -a -r $initdir/env_setup.bash ]; then |
---|
| 132 | source $initdir/env_setup.bash |
---|
| 133 | fi |
---|
| 134 | |
---|
| 135 | |
---|
[13222] | 136 | # All of the bash initializing commands above can be overridden by using |
---|
| 137 | # "unset" or "unalias" commands (or by changing things using "set" or |
---|
[13196] | 138 | # "alias" again) in your ~/.bashrc.mine file, which is sourced here. |
---|
| 139 | # ~/.bashsrc.mine is not sourced if the xlogin "Ignore your customizations" |
---|
| 140 | # option was selected to begin the session. |
---|
| 141 | |
---|
[13222] | 142 | if [ "${NOCALLS+set}" != set -a -r ~/.bashrc.mine ]; then |
---|
[13196] | 143 | . ~/.bashrc.mine |
---|
| 144 | fi |
---|