view .bashrc @ 283:09a1242050d3

Moving to the new host today
author Steve Huston <huston@srhuston.net>
date Mon, 15 Jul 2024 11:23:21 -0400
parents df0b24d4fabd
children f62fb9579277
line wrap: on
line source

# This file is sourced for shells which are interactive but not a
# login shell; however, since it is also sourced within
# $HOME/.bash_profile, the end result is that this file is sourced for all
# shells.

# macOS 10.15 (Catalina) and further changed the default shell to zsh.  While
# it may be a simple transition, I've seen too many problems with zsh to want
# to change yet.  So this will tell the machine to not bother me about it when
# opening new terminal windows.  It really should be in ~/.bash_profile but
# then existing screen sessions won't get the message, and it doesn't hurt to
# be here anyway.

export BASH_SILENCE_DEPRECATION_WARNING=1

# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi

# DOTHOME is where dotfiles (like this one) live that might be used here, or
# might be shared to other places from here, so rather than duplicate them we
# put them in a subdirectory that is safe to "export" but will need to know
# where they live.  Then if imported somewhere else, that location may be
# different than here - like in a temporary directory - so we'll need to know
# what it is and refer to it as such.  The equivalent script to this very one
# that would load those files will have to set this first.

export DOTHOME="$HOME/.shared"

# Source shared files
if [ -f ${DOTHOME}/shared_bashrc ]; then
  . ${DOTHOME}/shared_bashrc
fi

# Load local aliases
if [ -f $HOME/.bash_aliases ]; then
  . $HOME/.bash_aliases
fi

#
# Environment variables
#

export RUBYLIB=$HOME/Installs/rubygems/lib
export GEM_HOME=$HOME/Installs/rubygems/gems
export TOMENET_PATH=$HOME/Installs/tomenet/lib/
# Since I've started playing with some node.js things, this is included in its
# setup.
export NVM_DIR="$HOME/.config/nvm"

if [ -f $HOME/.screen/$HOST ]; then
  # If we have a local one for this host, use it; if not the default set in
  # the shared settings will be there
  export SCREENRC=$HOME/.screen/$HOST
fi

# Set some friendly options for history
# Append to ~/.bash_history, don't overwrite it
shopt -s histappend
# Set the history a bit larger, both on disk and in memory
export HISTFILESIZE=10000
export HISTSIZE=10000
# Ignore lines starting with a space, and duplicates of the previous command;
# also, if a line is a dupe from earlier history, remove the previous line
# entirely
export HISTCONTROL='ignoreboth:erasedups'
# Ignore some commonly used and not noteworthy commands
export HISTIGNORE='bg:fg:jobs:history:ret:rbh:rj:rx:keys:ssh-add*:jobs:proxy*'
# Put a timestamp on history lines
export HISTTIMEFORMAT='%F %T '
# Fold multi-line commands into a single line
# This seems to be 'on' in many places already, but let's make sure
shopt -s cmdhist

#
# Paths
#

# A test for modules, to be implemented in time:
# if [ "`type -t module`" == "function" ]; then
#   module load foo
# fi

# Standard-ish paths; some of these may be in place already, but if
# they're not they should probably go near the front of the pack.
for P in /sbin /usr/sbin /usr/local/bin /usr/local/sbin \
  /opt/local/bin /opt/local/sbin /usr/X11R6/bin; do
  if [ -d $P ]; then
    [[ $PATH =~ (^|:)$P($|:) ]] || \
    export PATH=${P}${PATH:+:$PATH}
  fi
done

for M in /usr/local/share/man /usr/local/man /opt/local/share/man ; do
  if [ -d $M ]; then
    [[ $MANPATH =~ (^|:)$M($|:) ]] || \
    export MANPATH=${M}${MANPATH:+:$MANPATH}
  fi
done

# Local install paths - install things to $HOME/Installs directories, and
# they will automatically get the proper paths added.  Most things
# that use autoconf will do this with
# './configure --prefix=$HOME/Installs'
for D in $HOME/Installs/* ; do
  if [ -d $D/bin ]; then
    [[ $PATH =~ (^|:)$D/bin($|:) ]] || \
    export PATH=$D/bin${PATH:+:$PATH}
  fi

  if [ -d $D/share/man ]; then
    [[ $MANPATH =~ (^|:)$D/share/man($|:) ]] || \
    export MANPATH=$D/share/man:${MANPATH:+$MANPATH}
  fi

  if [ -d $D/man ]; then
    [[ $MANPATH =~ (^|:)$D/man($|:) ]] || \
    export MANPATH=$D/man:${MANPATH:+$MANPATH}
  fi
done

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

# Now make sure $HOME/bin is top of the list (or at least present)
if [ -d $HOME/bin ]; then
  [[ $PATH =~ (^|:)$HOME/bin($|:) ]] || \
  export PATH=$HOME/bin${PATH:+:$PATH}
fi

# Last, make sure to end MANPATH with a ':' to force include of system paths
# (some versions of man take care of this, but it doesn't hurt to have it
# anyway)
[[ $MANPATH =~ :$ ]] || export MANPATH=$MANPATH:

# Store MIBs in ~/mibs and they'll be added here.  Can nest directories
# (they'll be searched).
if [ -d $HOME/mibs ]; then
  for D in `find $HOME/mibs -type d` ; do
    [[ $MIBDIRS =~ (^\+|:)$D($|:) ]] || \
    export MIBDIRS=${MIBDIRS:+$MIBDIRS:}$D
  done

  [[ $MIBDIRS =~ ^\+ ]] || export MIBDIRS=+$MIBDIRS
  export MIBS=ALL
fi