annotate .bash_profile @ 14:94cfcec3b5b6

When bash is called non-interactively, PS1 is unset. However, if it's a login shell, ~/.bash_profile is still sourced. Therefore, testing PS1 tells us if this is a login but non-interactive shell (such as: ssh host 'uptime'). Testing PS1 before setting it preserves that state for later tests if desired.
author huston@80426f53-59d1-405d-934b-f07cd76f4a1a
date Sun, 30 Aug 2009 06:49:10 +0000
parents dacbbae5965c
children fe83d9892ee3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
1 # .bash_profile
1
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
2 # This file is sourced for interactive login shells, or
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
3 # non-interactive shells with the --login option. So things which you
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
4 # want to happen only on login shells should go here.
0
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
5
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
6 # Get the aliases and functions
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
7 if [ -f ~/.bashrc ]; then
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
8 . ~/.bashrc
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
9 fi
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
10
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
11 # User specific environment and startup programs
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
12
1
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
13 # BASH_ENV is sourced for non-interactive shells; however, since we
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
14 # source ~/.bashrc above I don't think we have to here also.
7e33b3191cf7 Merged in settings from home, and at the same time edited some of the
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 0
diff changeset
15 # export BASH_ENV=$HOME/.bashrc
0
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
16
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
17 # These lines are helpful if you routinely might login without passing an
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
18 # ssh-agent's authentication through. This way when you login, an agent is
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
19 # exec'd for you (the corresponding lines in .bash_logout should kill the
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
20 # agent when you logout, however they sometimes fail such as when killing your
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
21 # shell without a proper logout or closing the connection). I left it here,
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
22 # though I personally don't use/need it anymore.
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
23
0
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
24 #if [ "X$SSH_AUTH_SOCK" = "X" ] ; then
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
25 # eval `/usr/bin/ssh-agent`
c78481cfb082 Initial checkin:
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents:
diff changeset
26 #fi
6
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
27
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
28 # This part is quite useful if you have your dotfiles stored in subversion
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
29 # (though it could be edited fairly easily for any other version control
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
30 # system I'm sure). We check the timestamp of the file '$HOME/.dotfilets'.
13
dacbbae5965c Added Ruby setup variables
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 11
diff changeset
31 # If it's older than a month, run a 'svn st -u' and touch it; this way we
dacbbae5965c Added Ruby setup variables
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 11
diff changeset
32 # check once per month to see if we forgot to pull down an updated version.
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
33
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
34 # First set $STAT and $DATE since the syntax of the commands is different
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
35 # between Linux and Mac OS X. If this is run elsewhere, the eval will be
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
36 # false and the test not done below, so it's safe to not bother checking for
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
37 # zero-length variables on the test - it just won't run the svn status, so you
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
38 # won't be prompted if there's newer files available in your repository.
6
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
39
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
40 [[ `uname` == "Darwin" ]] && {
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
41 STAT="stat -f %m -t %s $HOME/.dotfilets"
11
0f5a560c00d4 Changed check time to one month, and made it backgrounded. These things don't
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 7
diff changeset
42 DATE="date -v -1m +%s"
6
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
43 }
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
44
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
45 [[ `uname` == "Linux" ]] && {
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
46 STAT="stat -c %Y $HOME/.dotfilets"
11
0f5a560c00d4 Changed check time to one month, and made it backgrounded. These things don't
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 7
diff changeset
47 DATE="date -d \"1 month ago\" +%s"
6
f5b253e17e34 Added test for .dotfilets, to check the status against the svn repo once per
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 1
diff changeset
48 }
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
49
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
50 [[ ! -f $HOME/.dotfilets || \
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
51 `eval $STAT` -lt `eval $DATE` ]] && {
11
0f5a560c00d4 Changed check time to one month, and made it backgrounded. These things don't
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 7
diff changeset
52 echo Dotfiles last checked over a month ago, running a status test.
0f5a560c00d4 Changed check time to one month, and made it backgrounded. These things don't
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 7
diff changeset
53 svn st -u && touch $HOME/.dotfilets &
7
1e8e782fccab Merge together the Linux and Darwin tests for the subversion status command,
huston@80426f53-59d1-405d-934b-f07cd76f4a1a
parents: 6
diff changeset
54 }