#!/bin/bash # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later # to debug #set -x # redirect output to log file. this doesn't work. todo figure out why #exec 1>>/a/tmp/bashlog #exec 2>>/a/tmp/bashlog # History related options first, or else # we risk screwing up history history. And this is duplicated # in ~/.bash_profile just for good measure # history number. History expansion is good. PS4='$LINENO+ ' # history file size limit, set to unlimited. # this needs to be different from the default because # default HISTFILESIZE is 500 and could clobber our history HISTFILESIZE= # max commands 1 session can append/read from history HISTSIZE=1000000 # the time format display when doing the history command # also, setting this makes the history file record time # of each command as seconds from the epoch HISTTIMEFORMAT="%Y-%m-%d %I:%M %p " # consecutive duplicate lines dont go in history HISTCONTROL=ignoredups # works in addition to HISTCONTROL to do more flexible things # it could also do the same things as HISTCONTROL and thus replace it, # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it. HISTIGNORE='pass *:[ ]*:otp *:oathtool *' # see comments in brc2 sl() function for background. if [[ $SSH_CONNECTION ]] \ && [[ $BRC != t ]]; then return 0 else # the distinction between login and non-login shells is lame, # get rid of it. note ssh shells normally its login if a command is passed if ! shopt -q login_shell; then if [[ -r /etc/profile ]]; then source /etc/profile fi # note, this is not exactly the same as a login shell, because that # reads ~/.bash_profile or alternative, which usually just sources # this file, and we don't want to do that and cause an infinite # loop. fi _tmp=$(readlink -f ${BASH_SOURCE[0]}) _tmp=${_tmp%/*} _tmp2=$_tmp/brc if [[ -s $_tmp2 ]]; then # shellcheck source=./brc source $_tmp2 fi # brc2 is for things i dont necessarily want on every system _tmp2=$_tmp/brc2 if [[ -s $_tmp2 ]]; then # shellcheck source=./brc2 source $_tmp2 else # This check is for when running the sl() command, # and the remote host got its type misidentified. _tmp2=$_tmp/../brc2 if [[ -s $_tmp2 ]]; then # shellcheck source=./brc2 source $_tmp2 fi fi fi # ensure no bad programs appending to this file will have an affect return 0