host info updates
[distro-setup] / .bashrc
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 # to debug
25 #set -x
26 # redirect output to log file. this doesn't work. todo figure out why
27 #exec 1>>/a/tmp/bashlog
28 #exec 2>>/a/tmp/bashlog
29
30
31
32 # History related options first and always, or else we risk screwing up
33 # the history file. This is duplicated in ~/.bash_profile just for good
34 # measure
35
36 # History file size limit, set to unlimited.
37 # this needs to be different from the default because
38 # default HISTFILESIZE is 500 and could clobber our history
39 HISTFILESIZE=
40 # max commands 1 session can append/read from history
41 HISTSIZE=1000000
42 # the time format display when doing the history command
43 # also, setting this makes the history file record time
44 # of each command as seconds from the epoch
45 HISTTIMEFORMAT="%Y-%m-%d %I:%M %p "
46 # consecutive duplicate lines dont go in history
47 HISTCONTROL=ignoredups
48 # This works in addition to HISTCONTROL to do more flexible things
49 # it could also do the same things as HISTCONTROL and thus replace it,
50 # but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
51 HISTIGNORE='pass *:otp *:oathtool *:histrm *'
52
53 # note: duplicated in /a/bin/ds/filesystem/etc/profile.d/environment.sh
54 umask 022
55
56
57
58 #### if (in
59 # noninteractive ssh shells or tty). tty because often i use it when
60 # something is going and io is slow and my bashrc is too slow.
61 if [[ $LC_USEBASHRC != t && ( $SSH_CONNECTION || $TERM == linux ) ]]; then
62 # Here we did not opt-in to running our .bashrc file so we just
63 # return, but we still setup a function to source it without returning
64 # so if we want it we don't have to restart our ssh connection.
65 brc() {
66 export LC_USEBASHRC=t
67 # shellcheck disable=SC1090 # obviously, no need to follow a sourcing of this file
68 source ~/.bashrc
69 }
70 return 0
71 else
72
73 ###### Begin sourcing of files #####
74
75 # The distinction between login and non-login shells is super lame
76 # and pretty random. get rid of that distinction.
77 if ! shopt -q login_shell; then
78 if [[ -r /etc/profile ]]; then
79 source /etc/profile
80 fi
81 # note, this is not exactly the same as a login shell, because that
82 # reads ~/.bash_profile or alternative, which usually just sources
83 # this file, and we don't want to do that and cause an infinite
84 # loop.
85 fi
86
87 # source brc and brc2 if they exist. We have to readlink because we
88 # could be using sl() from ./brc.
89 _tmp=$(readlink -f ${BASH_SOURCE[0]})
90 bashrc_dir=${_tmp%/*}
91 _tmp=$bashrc_dir/brc
92 if [[ -s $bashrc_dir ]]; then
93 # shellcheck source=./brc
94 source $_tmp
95 fi
96 # brc2 is for things i dont necessarily want on every system
97 _tmp=$bashrc_dir/brc2
98 if [[ -s $_tmp ]]; then
99 # shellcheck source=./brc2
100 source $_tmp
101 else
102 # This check is for when running the sl() command,
103 # and the remote host got its type misidentified.
104 _tmp=$bashrc_dir/../brc2
105 if [[ -s $_tmp ]]; then
106 # shellcheck source=./brc2
107 source $_tmp
108 fi
109 fi
110 if [[ $IANK_BASHRC_RUN ]]; then
111 $IANK_BASHRC_RUN ||:
112 fi
113 ###### End sourcing of files #####
114 fi
115 #### end section that works with sl() function to return from
116 #### noninteractive ssh shells
117
118
119 # ensure no bad programs appending to this file will have an affect
120 return 0
121
122 # kitty puts this here on startup, i need to build with some option to
123 # avoid it, whatever.
124
125 ## BEGIN_KITTY_SHELL_INTEGRATION
126 # 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
127 ## END_KITTY_SHELL_INTEGRATION
128
129 # Automatically added by the Guix install script.
130 if [ -n "$GUIX_ENVIRONMENT" ]; then
131 if [[ $PS1 =~ (.*)"\\$" ]]; then
132 PS1="${BASH_REMATCH[1]} [env]\\\$ "
133 fi
134 fi