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