| 1 | # If not running interactively, then exit |
|---|
| 2 | if [ -n "$PS1" ]; then |
|---|
| 3 | |
|---|
| 4 | test -f ~/.bashrc_site_before && source ~/.bashrc_site_before |
|---|
| 5 | test -f /sw/bin/init.sh && . /sw/bin/init.sh |
|---|
| 6 | source ~/.aliases |
|---|
| 7 | |
|---|
| 8 | # speeding up text selection: The colon is a no-op for the Bourne family |
|---|
| 9 | # of shells. So just select whole lines and paste; with conventional |
|---|
| 10 | # prompts you have to be careful not to select the prompt as well. |
|---|
| 11 | |
|---|
| 12 | set_prompt () { |
|---|
| 13 | export PS1=": \u@\h \W; " |
|---|
| 14 | export PS2=":; " |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | # append commands from all terminals into the history file immediately |
|---|
| 18 | shopt -s histappend |
|---|
| 19 | PROMPT_COMMAND='history -a' |
|---|
| 20 | |
|---|
| 21 | stty sane 2>/dev/null |
|---|
| 22 | stty erase ^? |
|---|
| 23 | umask 022 |
|---|
| 24 | |
|---|
| 25 | IGNORE_EOF=1 |
|---|
| 26 | |
|---|
| 27 | export LESSCHARSET=iso8859 |
|---|
| 28 | export EDITOR=/usr/bin/vim |
|---|
| 29 | export CVSEDITOR=/usr/bin/vim |
|---|
| 30 | export CVS_RSH=ssh |
|---|
| 31 | export PAGER=less |
|---|
| 32 | export TEST_MODE=1 |
|---|
| 33 | #export LC_COLLATE=C |
|---|
| 34 | export DISPLAY=:0.0 |
|---|
| 35 | export TEST_AUTHOR=1 |
|---|
| 36 | export PROJROOT |
|---|
| 37 | export PTAGSFILE=~/.ptags |
|---|
| 38 | # for iTerm: |
|---|
| 39 | export TERM=linux |
|---|
| 40 | |
|---|
| 41 | export CPPFLAGS |
|---|
| 42 | for d in /{sw,usr/local}/include |
|---|
| 43 | do |
|---|
| 44 | test -d $d && CPPFLAGS="-I$d $CPPFLAGS" |
|---|
| 45 | done |
|---|
| 46 | |
|---|
| 47 | export LDFLAGS |
|---|
| 48 | for d in /{sw,usr/local}/lib |
|---|
| 49 | do |
|---|
| 50 | test -d $d && LDFLAGS="-L$d $LDFLAGS" |
|---|
| 51 | done |
|---|
| 52 | |
|---|
| 53 | # remove domain name from hostname, if domain name |
|---|
| 54 | # is in hostname (otherwise, just hostname). |
|---|
| 55 | export HOSTNAME=`hostname | sed s/\\\..\*//g` |
|---|
| 56 | |
|---|
| 57 | export PATH |
|---|
| 58 | export MANPATH |
|---|
| 59 | for d in /usr /{usr,opt}/{local,share,local/share,local/pgsql,git,git/share} ~{,/home,/perl} |
|---|
| 60 | do |
|---|
| 61 | test -d $d/bin && PATH=$d/bin:$PATH |
|---|
| 62 | test -d $d/man && MANPATH=$d/man:$MANPATH |
|---|
| 63 | done |
|---|
| 64 | |
|---|
| 65 | TESTPATH=/usr/local/teTeX/bin/i386-apple-darwin-current |
|---|
| 66 | test -d $TESTPATH && PATH=$TESTPATH:$PATH |
|---|
| 67 | |
|---|
| 68 | LESSPIPE=`which lesspipe.sh` |
|---|
| 69 | [[ $LESSPIPE ]] && export LESSOPEN="|$LESSPIPE %s" |
|---|
| 70 | |
|---|
| 71 | IGNOREEOF=1 # so first ^D doesn't logout, second ^D does |
|---|
| 72 | |
|---|
| 73 | cd () { |
|---|
| 74 | builtin cd "$*" |
|---|
| 75 | ls --color=auto |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | (which ncftp >/dev/null) && alias ftp=ncftp |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | # vim: If args are given, open those files. If no arg is given, use |
|---|
| 82 | # viminfo to jump to last known cursor position |
|---|
| 83 | |
|---|
| 84 | vi () { /usr/bin/vim ${@:- -c "normal '0"}; } |
|---|
| 85 | |
|---|
| 86 | # perl module development |
|---|
| 87 | cdpm () { cd $(dirname $(pmpath $1)); } |
|---|
| 88 | |
|---|
| 89 | pver () { |
|---|
| 90 | perl -MCPAN -e"print CPAN::Shell->format_result(q{Module}, q{$1})" |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | # so you can do |
|---|
| 94 | # vit Foo::Bar::Baz |
|---|
| 95 | # to edit the class |
|---|
| 96 | # cdt Foo::Bar::Baz |
|---|
| 97 | # to cd to the class's directory, we use vim tags. |
|---|
| 98 | # We also have custom completion rules for cdt and vit in |
|---|
| 99 | # .bash_completion. |
|---|
| 100 | |
|---|
| 101 | cdt () { cd `cdt.pl $1`; } |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | targets () { perl -ne 'print "$1\n" if /^(\w+):/' Makefile; } |
|---|
| 105 | |
|---|
| 106 | # Check for recent enough version of bash. |
|---|
| 107 | bash=${BASH_VERSION%.*}; bmajor=${bash%.*}; bminor=${bash#*.} |
|---|
| 108 | |
|---|
| 109 | # Check for interactive shell. |
|---|
| 110 | if [ -n "$PS1" ]; then |
|---|
| 111 | if [ $bmajor -eq 2 -a $bminor '>' 04 ] || [ $bmajor -gt 2 ]; then |
|---|
| 112 | if [ -r /etc/bash_completion ]; then |
|---|
| 113 | # Source completion code. |
|---|
| 114 | . /etc/bash_completion/bash_completion |
|---|
| 115 | . /etc/bash_completion/contrib/svk |
|---|
| 116 | fi |
|---|
| 117 | fi |
|---|
| 118 | fi |
|---|
| 119 | unset bash bminor bmajor |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | # list all instances of one or more files found within the $PATH. |
|---|
| 123 | |
|---|
| 124 | wh () { |
|---|
| 125 | perl -MFile::Which -e' |
|---|
| 126 | for $file (@ARGV) { |
|---|
| 127 | print "$_\n" for grep { !$seen{$_}++ } which($file) |
|---|
| 128 | } |
|---|
| 129 | ' $*; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | projptags () { |
|---|
| 133 | rm -f $PTAGSFILE |
|---|
| 134 | ptags $* --use $PROJROOT --exclude ~/.ptags_exclude >>$PTAGSFILE |
|---|
| 135 | |
|---|
| 136 | if [ -f $PTAGS_DYNAMIC ]; then |
|---|
| 137 | echo Generating dynamic ptags |
|---|
| 138 | $PTAGS_DYNAMIC >>$PTAGSFILE |
|---|
| 139 | fi |
|---|
| 140 | |
|---|
| 141 | sort -o $PTAGSFILE $PTAGSFILE |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | ORIGPATH=$PATH |
|---|
| 146 | |
|---|
| 147 | set_project () { |
|---|
| 148 | export PROJROOT=$1 |
|---|
| 149 | export PERL5OPT="-MDevel::SearchINC::FindLib=$PROJROOT" |
|---|
| 150 | export CF_CONF=local |
|---|
| 151 | |
|---|
| 152 | PATH=$ORIGPATH |
|---|
| 153 | for i in $(distfind) |
|---|
| 154 | do |
|---|
| 155 | if [ -d $i/bin ]; then |
|---|
| 156 | PATH=$i/bin:$PATH |
|---|
| 157 | fi |
|---|
| 158 | done |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | |
|---|
| 162 | set_prompt |
|---|
| 163 | test -f ~/.bashrc_site_after && . ~/.bashrc_site_after |
|---|
| 164 | |
|---|
| 165 | fi |
|---|