satisfy shellcheck
[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
13 # History related options first and always, or else we risk screwing up
14 # the history file. This is duplicated in ~/.bash_profile just for good
15 # measure
16
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 # This 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 *:histrm *'
33
34
35
36 #### begin section that works with sl() function to return from
37 # noninteractive ssh shells, or tty. tty because often i
38 # use it when something is going and io is slow and my bashrc
39 # is too slow.
40 if [[ $LC_USEBASHRC != t && ( $SSH_CONNECTION || $TERM == linux ) ]]; then
41 # Here we did not opt-in to running our .bashrc file so we just
42 # return, but we still setup a function to source it without returning
43 # so if we want it we don't have to restart our ssh connection.
44 brc() {
45 export LC_USEBASHRC=t
46 # shellcheck disable=SC1090 # obviously, no need to follow a sourcing of this file
47 source ~/.bashrc
48 }
49 return 0
50 else
51
52 ###### Begin sourcing of files #####
53
54 # The distinction between login and non-login shells is super lame
55 # and pretty random. get rid of that distinction.
56 if ! shopt -q login_shell; then
57 if [[ -r /etc/profile ]]; then
58 source /etc/profile
59 fi
60 # note, this is not exactly the same as a login shell, because that
61 # reads ~/.bash_profile or alternative, which usually just sources
62 # this file, and we don't want to do that and cause an infinite
63 # loop.
64 fi
65
66 # source brc and brc2 if they exist. We have to readlink because we
67 # could be using sl() from ./brc.
68 _tmp=$(readlink -f ${BASH_SOURCE[0]})
69 bashrc_dir=${_tmp%/*}
70 _tmp=$bashrc_dir/brc
71 if [[ -s $bashrc_dir ]]; then
72 # shellcheck source=./brc
73 source $_tmp
74 fi
75 # brc2 is for things i dont necessarily want on every system
76 _tmp=$bashrc_dir/brc2
77 if [[ -s $_tmp ]]; then
78 # shellcheck source=./brc2
79 source $_tmp
80 else
81 # This check is for when running the sl() command,
82 # and the remote host got its type misidentified.
83 _tmp=$bashrc_dir/../brc2
84 if [[ -s $_tmp ]]; then
85 # shellcheck source=./brc2
86 source $_tmp
87 fi
88 fi
89 ###### End sourcing of files #####
90 fi
91 #### end section that works with sl() function to return from
92 #### noninteractive ssh shells
93
94
95 # ensure no bad programs appending to this file will have an affect
96 return 0
97
98 # kitty puts this here on startup, i need to build with some option to
99 # avoid it, whatever.
100
101 ## BEGIN_KITTY_SHELL_INTEGRATION
102 # if test -n "$KITTY_INSTALLATION_DIR" -a -e "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; then source "$KITTY_INSTALLATION_DIR/shell-integration/bash/kitty.bash"; fi
103 ## END_KITTY_SHELL_INTEGRATION