[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 | |
---|
[25097] | 9 | # Determine if we're in an sftp or scp session and if so, be quiet |
---|
| 10 | SILENT=no |
---|
| 11 | case "$BASH_EXECUTION_STRING" in |
---|
[25364] | 12 | */usr/lib/openssh/sftp-server) |
---|
[25097] | 13 | SILENT=yes |
---|
| 14 | ;; |
---|
[25099] | 15 | scp\ *) |
---|
[25097] | 16 | SILENT=yes |
---|
| 17 | ;; |
---|
| 18 | esac |
---|
| 19 | |
---|
[13196] | 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 | |
---|
[25343] | 25 | if [ "${ENV_SET:+set}" != set ]; then |
---|
[13196] | 26 | |
---|
| 27 | export ENV_SET=t # Avoid unnecessary repeat |
---|
[22913] | 28 | export HOSTTYPE="`/bin/machtype`" |
---|
[13196] | 29 | |
---|
[24770] | 30 | # Ensure user's homedir is attached, for legacy things |
---|
| 31 | # that care about attachtab |
---|
[24792] | 32 | # Only attach if running as an Athena user, not e.g. using sudo. |
---|
[24793] | 33 | if [ "$DEBATHENA_HOME_TYPE" = afs ]; then |
---|
| 34 | /bin/attach -h -q "${ATHENA_USER:-$USER}" |
---|
[24792] | 35 | fi |
---|
[24770] | 36 | |
---|
[22975] | 37 | if [ -r "$HOME/.generation" ]; then |
---|
| 38 | export ATHENA_DOTFILE_GENERATION=`cat "$HOME/.generation"` |
---|
| 39 | else |
---|
| 40 | export ATHENA_DOTFILE_GENERATION=0 |
---|
| 41 | fi |
---|
| 42 | |
---|
[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 | |
---|
[22913] | 51 | export ATHENA_SYS=`/bin/machtype -S` |
---|
| 52 | export ATHENA_SYS_COMPAT=`/bin/machtype -C` |
---|
[13196] | 53 | |
---|
[13238] | 54 | if [ -z "$ATHENA_SYS" ]; then |
---|
[13196] | 55 | export ATHENA_SYS=@sys |
---|
[13238] | 56 | fi |
---|
[13196] | 57 | |
---|
[23132] | 58 | if [ "${PRINTER+set}" != set \ |
---|
[25864] | 59 | -a -e /var/run/athena-clusterinfo.sh ]; then |
---|
| 60 | PRINTER="$( . /var/run/athena-clusterinfo.sh && echo $LPR )" |
---|
[13196] | 61 | if [ -n "$PRINTER" ]; then export PRINTER; fi |
---|
| 62 | fi |
---|
| 63 | |
---|
| 64 | # Reset the HOME variable to correspond to the actual location |
---|
| 65 | # of the user's home directory. This will avoid having long |
---|
| 66 | # pathnames being printed when /mit/<user> is a symlink to a |
---|
| 67 | # path within AFS. |
---|
[13222] | 68 | |
---|
[22439] | 69 | x=`(cd && /bin/pwd) 2>/dev/null` |
---|
[13196] | 70 | if [ -n "$x" ]; then |
---|
| 71 | export HOME=$x |
---|
[22439] | 72 | if [ "$x" = "`/bin/pwd`" ]; then |
---|
| 73 | cd "$HOME" |
---|
| 74 | fi |
---|
[13196] | 75 | fi |
---|
| 76 | unset x |
---|
| 77 | |
---|
| 78 | # Run user environment customizations identified in your |
---|
| 79 | # ~/.bash_environment file. This is the place to include your |
---|
| 80 | # own environment variables, attach commands, and other system |
---|
| 81 | # wide setup commands. You can also cancel default behaviors |
---|
[13242] | 82 | # listed above. |
---|
[13196] | 83 | # ~/.bash_environment is not sourced if NOCALLS is set (i.e., |
---|
| 84 | # if you selected the xlogin "Ignore your customizations" |
---|
[25098] | 85 | # option when you logged in). |
---|
[13196] | 86 | |
---|
[13222] | 87 | if [ "${NOCALLS+set}" != set -a -r ~/.bash_environment ]; then |
---|
[25097] | 88 | if [ "$SILENT" = "yes" ]; then |
---|
[25098] | 89 | . ~/.bash_environment &> /dev/null |
---|
| 90 | else |
---|
| 91 | . ~/.bash_environment |
---|
[25097] | 92 | fi |
---|
[13196] | 93 | fi |
---|
[13564] | 94 | |
---|
[23030] | 95 | # If the user has a bindir in $HOME, put it in front of the path. |
---|
[22913] | 96 | athena_home_bin=$( /usr/bin/athdir "$HOME" ) |
---|
[23030] | 97 | PATH=${athena_home_bin:+$athena_home_bin:}$PATH |
---|
[22913] | 98 | unset athena_home_bin |
---|
[13196] | 99 | |
---|
| 100 | fi |
---|
| 101 | |
---|
[22913] | 102 | |
---|
[13196] | 103 | # ******************* BASH SETUP ******************* |
---|
| 104 | |
---|
| 105 | # Set up standard bash shell initializations |
---|
| 106 | |
---|
[13479] | 107 | if [ "${XSESSION+set}" = set ]; then |
---|
[25379] | 108 | if [ -x /usr/bin/gnome-session-quit ]; then |
---|
[25644] | 109 | logout () { /usr/lib/init/check-for-reboot; gnome-session-quit --no-prompt; exit; } # logout for X |
---|
[25379] | 110 | else |
---|
[25644] | 111 | logout () { /usr/lib/init/check-for-reboot; gnome-session-save --kill --silent; exit; } # logout for X |
---|
[25379] | 112 | fi |
---|
[13196] | 113 | fi |
---|
| 114 | |
---|
| 115 | # aliases dealing with adding locker programs |
---|
| 116 | |
---|
[23782] | 117 | setup_tty () {(export SUBJECT="$@"; $SHELL)} |
---|
| 118 | setup_X () {(export SUBJECT="$@"; xterm -title "$@" &)} |
---|
[13196] | 119 | |
---|
[23782] | 120 | if [ -n "$XSESSION" ]; then |
---|
| 121 | alias setup=setup_X |
---|
| 122 | else |
---|
| 123 | alias setup=setup_tty |
---|
| 124 | fi |
---|
[13196] | 125 | |
---|
[23782] | 126 | remove () { export SUBJECT="$@"; |
---|
| 127 | source $initdir/env_remove.bash; |
---|
| 128 | unset SUBJECT; } |
---|
| 129 | |
---|
| 130 | if [ -n "$SUBJECT" -a -r $initdir/env_setup.bash ]; then |
---|
| 131 | source $initdir/env_setup.bash |
---|
| 132 | fi |
---|
| 133 | |
---|
| 134 | |
---|
[13222] | 135 | # All of the bash initializing commands above can be overridden by using |
---|
| 136 | # "unset" or "unalias" commands (or by changing things using "set" or |
---|
[13196] | 137 | # "alias" again) in your ~/.bashrc.mine file, which is sourced here. |
---|
| 138 | # ~/.bashsrc.mine is not sourced if the xlogin "Ignore your customizations" |
---|
| 139 | # option was selected to begin the session. |
---|
| 140 | |
---|
[13222] | 141 | if [ "${NOCALLS+set}" != set -a -r ~/.bashrc.mine ]; then |
---|
[25097] | 142 | if [ "$SILENT" = "yes" ]; then |
---|
[25098] | 143 | . ~/.bashrc.mine &> /dev/null |
---|
| 144 | else |
---|
| 145 | . ~/.bashrc.mine |
---|
[25097] | 146 | fi |
---|
[13196] | 147 | fi |
---|
[25590] | 148 | if [ "${skip_sanity_checks+set}" != set ]; then |
---|
[25593] | 149 | missing=0 |
---|
[25614] | 150 | echo $PATH | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /bin |
---|
[25601] | 151 | [ $? -eq 0 ] || missing=1 |
---|
[25614] | 152 | echo $PATH | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /usr/bin |
---|
[25601] | 153 | [ $? -eq 0 ] || missing=1 |
---|
[25593] | 154 | if [ $missing -eq 1 ]; then |
---|
[25601] | 155 | text="You appear to have incorrectly modified your PATH variable in your dotfiles,\nand as such have deleted /bin and/or /usr/bin from your PATH, which\nwill likely cause this login session to fail. Please correct this problem.\nThis warning can be disabled with 'skip_sanity_checks=t' in ~/.bashrc.mine." |
---|
[25590] | 156 | echo -e "$text" >&2 |
---|
| 157 | [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text" |
---|
| 158 | fi |
---|
[25647] | 159 | if [ -n "${LD_ASSUME_KERNEL+x}" ]; then |
---|
[25590] | 160 | unset LD_ASSUME_KERNEL |
---|
[25601] | 161 | text="In your dotfiles, you set LD_ASSUME_KERNEL. This generally causes undesirable behavior.\nIt has been unset for you.\nIf you really wanted it set, you can add 'skip_sanity_checks=t' to your ~/.bashrc.mine." |
---|
[25593] | 162 | echo -e "$text" >&2 |
---|
[25613] | 163 | [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text" |
---|
[25590] | 164 | fi |
---|
| 165 | fi |
---|
| 166 | |
---|
| 167 | |
---|