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 | |
---|
7 | initdir=/usr/lib/init |
---|
8 | |
---|
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 |
---|
12 | */usr/lib/openssh/sftp-server) |
---|
13 | SILENT=yes |
---|
14 | ;; |
---|
15 | scp\ *) |
---|
16 | SILENT=yes |
---|
17 | ;; |
---|
18 | esac |
---|
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 [ "${ENV_SET:+set}" != set ]; then |
---|
26 | |
---|
27 | export ENV_SET=t # Avoid unnecessary repeat |
---|
28 | export HOSTTYPE="`/bin/machtype`" |
---|
29 | |
---|
30 | # Ensure user's homedir is attached, for legacy things |
---|
31 | # that care about attachtab |
---|
32 | # Only attach if running as an Athena user, not e.g. using sudo. |
---|
33 | if [ "$DEBATHENA_HOME_TYPE" = afs ]; then |
---|
34 | /bin/attach -h -q "${ATHENA_USER:-$USER}" |
---|
35 | fi |
---|
36 | |
---|
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 | |
---|
43 | ulimit -S -c 0 # Don't allow coredumps |
---|
44 | export EDITOR=emacs # Set default editor |
---|
45 | export MM_CHARSET=iso-8859-1 |
---|
46 | |
---|
47 | export EMAIL="$USER@mit.edu" # Set default email address |
---|
48 | |
---|
49 | export MORE=-s |
---|
50 | |
---|
51 | export ATHENA_SYS=`/bin/machtype -S` |
---|
52 | export ATHENA_SYS_COMPAT=`/bin/machtype -C` |
---|
53 | |
---|
54 | if [ -z "$ATHENA_SYS" ]; then |
---|
55 | export ATHENA_SYS=@sys |
---|
56 | fi |
---|
57 | |
---|
58 | if [ "${PRINTER+set}" != set \ |
---|
59 | -a -e /var/run/athena-clusterinfo.sh ]; then |
---|
60 | PRINTER="$( . /var/run/athena-clusterinfo.sh && echo $LPR )" |
---|
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. |
---|
68 | |
---|
69 | x=`(cd && /bin/pwd) 2>/dev/null` |
---|
70 | if [ -n "$x" ]; then |
---|
71 | export HOME=$x |
---|
72 | if [ "$x" = "`/bin/pwd`" ]; then |
---|
73 | cd "$HOME" |
---|
74 | fi |
---|
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 |
---|
82 | # listed above. |
---|
83 | # ~/.bash_environment is not sourced if NOCALLS is set (i.e., |
---|
84 | # if you selected the xlogin "Ignore your customizations" |
---|
85 | # option when you logged in). |
---|
86 | |
---|
87 | if [ "${NOCALLS+set}" != set -a -r ~/.bash_environment ]; then |
---|
88 | if [ "$SILENT" = "yes" ]; then |
---|
89 | . ~/.bash_environment &> /dev/null |
---|
90 | else |
---|
91 | . ~/.bash_environment |
---|
92 | fi |
---|
93 | fi |
---|
94 | |
---|
95 | # If the user has a bindir in $HOME, put it in front of the path. |
---|
96 | athena_home_bin=$( /usr/bin/athdir "$HOME" ) |
---|
97 | PATH=${athena_home_bin:+$athena_home_bin:}$PATH |
---|
98 | unset athena_home_bin |
---|
99 | |
---|
100 | fi |
---|
101 | |
---|
102 | |
---|
103 | # ******************* BASH SETUP ******************* |
---|
104 | |
---|
105 | # Set up standard bash shell initializations |
---|
106 | |
---|
107 | if [ "${XSESSION+set}" = set ]; then |
---|
108 | if [ -x /usr/bin/gnome-session-quit ]; then |
---|
109 | logout () { /usr/lib/init/check-for-reboot; gnome-session-quit --no-prompt; exit; } # logout for X |
---|
110 | else |
---|
111 | logout () { /usr/lib/init/check-for-reboot; gnome-session-save --kill --silent; exit; } # logout for X |
---|
112 | fi |
---|
113 | fi |
---|
114 | |
---|
115 | # aliases dealing with adding locker programs |
---|
116 | |
---|
117 | setup_tty () {(export SUBJECT="$@"; $SHELL)} |
---|
118 | setup_X () {(export SUBJECT="$@"; xterm -title "$@" &)} |
---|
119 | |
---|
120 | if [ -n "$XSESSION" ]; then |
---|
121 | alias setup=setup_X |
---|
122 | else |
---|
123 | alias setup=setup_tty |
---|
124 | fi |
---|
125 | |
---|
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 | |
---|
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 |
---|
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 | |
---|
141 | if [ "${NOCALLS+set}" != set -a -r ~/.bashrc.mine ]; then |
---|
142 | if [ "$SILENT" = "yes" ]; then |
---|
143 | . ~/.bashrc.mine &> /dev/null |
---|
144 | else |
---|
145 | . ~/.bashrc.mine |
---|
146 | fi |
---|
147 | fi |
---|
148 | if [ "${skip_sanity_checks+set}" != set ]; then |
---|
149 | missing=0 |
---|
150 | echo $PATH | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /bin |
---|
151 | [ $? -eq 0 ] || missing=1 |
---|
152 | echo $PATH | /usr/bin/tr ':' '\n' | /bin/grep -Fqx /usr/bin |
---|
153 | [ $? -eq 0 ] || missing=1 |
---|
154 | if [ $missing -eq 1 ]; then |
---|
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." |
---|
156 | echo -e "$text" >&2 |
---|
157 | [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text" |
---|
158 | fi |
---|
159 | if [ -n "${LD_ASSUME_KERNEL+x}" ]; then |
---|
160 | unset LD_ASSUME_KERNEL |
---|
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." |
---|
162 | echo -e "$text" >&2 |
---|
163 | [ -n "$DISPLAY" ] && /usr/bin/zenity --warning --text="$text" |
---|
164 | fi |
---|
165 | fi |
---|
166 | |
---|
167 | |
---|