various fixes, mostly for etiona
[distro-setup] / brc
diff --git a/brc b/brc
index 9ee0777cf06f0b78cbcbcf00c615acc06e0e2d41..51a04dcac0d59c3a29bd081522ee11a51dc738da 100644 (file)
--- a/brc
+++ b/brc
@@ -12,6 +12,12 @@ elif [[ -s ~/.iank/err ]]; then
   source ~/.iank/err
 fi
 
+# In t8, it runs clear_console for login shells by default. I don't want
+# my console cleared. And linux ttys get cleared without this.
+if shopt login_shell >/dev/null && [[ -e ~/.bash_logout ]]; then
+  rm ~/.bash_logout
+fi
+
 # for testing error catching:
 # t2() {
 #   echo t2
@@ -27,8 +33,6 @@ fi
 
 CDPATH=.
 
-set -o pipefail
-
 # remove all aliases. aliases provided by the system tend to get in the way,
 # for example, error happens if I try to define a function the same name as an alias
 unalias -a
@@ -155,28 +159,9 @@ if [[ $- == *i* ]]; then
 
 fi
 
-
-# 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 *'
-
 export BC_LINE_LENGTH=0
 
+# ansible option
 export PROFILE_TASKS_TASK_OUTPUT_LIMIT=100
 
 # note, if I use a machine I dont want files readable by all users, set
@@ -332,7 +317,7 @@ cam() {
 
 
 ccat () { # config cat. see a config without extra lines.
-  grep '^\s*[^;[:space:]#]' "$@"
+  grep '^\s*[^;[:space:]#]' "$@" || [[ $? == 1 ]]
 }
 
 
@@ -783,11 +768,11 @@ lower() { # make first letter of filenames lowercase.
 
 
 k() { # history search
-  grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history}  | tail -n 80;
+  grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history}  | tail -n 80 || [[ $? == 1 ]];
 }
 
 ks() { # history search
-  grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history}  | uniq;
+  grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history}  | uniq || [[ $? == 1 ]];
 }
 
 
@@ -827,7 +812,7 @@ pkx() { # package extract
   c $(mktemp -d)
   pkg=$1
   # shellcheck disable=SC2012
-  cached=$(ls -t /var/cache/apt/archives/$pkg* | tail -n1 2>/dev/null)
+  cached=$(ls -t /var/cache/apt/archives/$pkg* | tail -n1 2>/dev/null) ||:
   if [[ $cached ]]; then
     cp $cached .
   else
@@ -869,7 +854,7 @@ grep ps and output in a nice format"
   # final grep is because some commands tend to have a lot of trailing spaces
   y=$(echo "$x" | grep -iP "$@" | grep -o '.*[^ ]') ||:
   if [[ $y ]]; then
-    echo "$x" | head -n 1
+    echo "$x" | head -n 1 || [[ $? == 141 ]]
     echo "$y"
   fi
 }