840a353a108f82a0ebbb531e962151e23fb2440d
[distro-setup] / .bashrc
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 # to debug
6 #set -x
7 # redirect output to log file. this doesn't work. todo figure out why
8 #exec 1>>/a/tmp/bashlog
9 #exec 2>>/a/tmp/bashlog
10
11
12 # History related options first, or else
13 # we risk screwing up history history. And this is duplicated
14 # in ~/.bash_profile just for good measure
15 # history number. History expansion is good.
16 PS4='$LINENO+ '
17 # history file size limit, set to unlimited.
18 # this needs to be different from the default because
19 # default HISTFILESIZE is 500 and could clobber our history
20 HISTFILESIZE=
21 # max commands 1 session can append/read from history
22 HISTSIZE=1000000
23 # the time format display when doing the history command
24 # also, setting this makes the history file record time
25 # of each command as seconds from the epoch
26 HISTTIMEFORMAT="%Y-%m-%d %I:%M %p "
27 # consecutive duplicate lines dont go in history
28 HISTCONTROL=ignoredups
29 # works in addition to HISTCONTROL to do more flexible things
30 # it could also do the same things as HISTCONTROL and thus replace it,
31 # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
32 HISTIGNORE='pass *:[ ]*:otp *:oathtool *'
33
34
35 # see comments in brc2 sl() function for background.
36 if [[ $SSH_CONNECTION ]] \
37 && [[ $BRC != t ]]; then
38 return 0
39 else
40
41 # the distinction between login and non-login shells is lame,
42 # get rid of it. note ssh shells normally its login if a command is passed
43 if ! shopt -q login_shell; then
44 if [[ -r /etc/profile ]]; then
45 source /etc/profile
46 fi
47 # note, this is not exactly the same as a login shell, because that
48 # reads ~/.bash_profile or alternative, which usually just sources
49 # this file, and we don't want to do that and cause an infinite
50 # loop.
51 fi
52 _tmp=$(readlink -f ${BASH_SOURCE[0]})
53 _tmp=${_tmp%/*}
54 _tmp2=$_tmp/brc
55 if [[ -s $_tmp2 ]]; then
56 # shellcheck source=./brc
57 source $_tmp2
58 fi
59 # brc2 is for things i dont necessarily want on every system
60 _tmp2=$_tmp/brc2
61 if [[ -s $_tmp2 ]]; then
62 # shellcheck source=./brc2
63 source $_tmp2
64 else
65 # This check is for when running the sl() command,
66 # and the remote host got its type misidentified.
67 _tmp2=$_tmp/../brc2
68 if [[ -s $_tmp2 ]]; then
69 # shellcheck source=./brc2
70 source $_tmp2
71 fi
72 fi
73 fi
74 # ensure no bad programs appending to this file will have an affect
75 return 0