various updates
authorIan Kelling <ian@iankelling.org>
Tue, 17 Jun 2014 06:36:04 +0000 (23:36 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:40:14 +0000 (16:40 -0700)
.bash_profile
.bashrc

index 45bec519025b7e3914396bebc08457f45fedfca1..a2254a1b49a06e98062dc76f79ff4e69b855e45e 100644 (file)
@@ -1,5 +1,14 @@
-# i prefer to just use screen on remote sessions
-#if [[ $TERM != screen* ]]; then
-#      exec screen -dRR
-#fi
+# man bash covers everything comprehensively of course.  i use ~/.bash_profile
+# to source bashrc, and .profile just echos that the normal bash startup process
+# is not happening.  I don't source bashrc in posix mode based on debian's
+# default, and posix mode is quirky, doesn't seem worth figuring it out This
+# setup ensures no distro can override anything, as they occasionally do things
+# I don't like. For example, debian's root .profile spamms with "mesg n"when
+# there is no tty. The mesg n ensures the terminal is not writable by other
+# users, but it is that way without the mesg n, and google search, and debian
+# wiki search, /usr/share/doc search gives no justification for it, and it's not
+# in fedora, so I'm pretty confident that it is useless redundant security, plus
+# it is purposefully in a user startup file, not a system one, so intended for
+# the user to change.
+
 [[ -f ~/.bashrc ]] && . ~/.bashrc
diff --git a/.bashrc b/.bashrc
index fcaa4b6e033bc23840692a30b15d03a6269deaf2..4ddbab9eeefaf2afbc3e953c7afd53fea8c2fd28 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -98,6 +98,7 @@ if [[ $INSIDE_EMACS ]]; then
     export MANPAGER=cat
     # for readline-complete.el
     stty echo
+    # todo, remote file completion fails, figure out how to turn it off
 fi
 
 
@@ -142,10 +143,10 @@ HISTFILE=$HOME/.bh
 HISTTIMEFORMAT="%I:%M %p %m/%d "
 # consecutive duplicate lines don't go in history
 HISTCONTROL=ignoredups
-# just defensively unsetting this
-# this var can replace HISTCONTROL to do more flexible things like
-# not saving single char history items or specific names
-unset HISTIGNORE
+# 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
+HISTIGNORE="k *"
 
 export BC_LINE_LENGTH=0
 
@@ -229,10 +230,11 @@ fi
 # this is idempotent
 debian_pick_mirror () {
     local x=$(mktemp -d)/f # safe way to get file name without creating one
-    sudo netselect-apt -o $x || return 1
-    x=$(_debian_pick_mirror_grep stable $x)
+    sudo netselect-apt -o "$x" || return 1
+    x=$(_debian_pick_mirror_grep stable "$x")
     sudo cp -f /etc/apt/sources.list /etc/apt/sources.list-original
     sudo sed -i "s/$(_debian_pick_mirror_grep wheezy)/$x/" /etc/apt/sources.list
+    aptitude update
 }
 
 _debian_pick_mirror_grep () {
@@ -266,8 +268,23 @@ grr() {
     grep -ri --binary-files=without-match --color=auto "$@"
 }
 
+bashrcpush () {
+    local startdir="$PWD"
+    cd ~
+    for x in "$@"; do
+        ssh $x mkdir -p bin
+        tar cz bin/bash-programs-by-ian bin/semi-private .profile | ssh $x tar xz
+    done
+    cd $(mktemp -d)
+    cp ~/path_add-function ~/.bashrc ~/.bash_profile ~/.profile ~/.bashrc_profile .
+    for x in "$@"; do
+        tar cz path_add-function .bashrc | ssh $x tar xz
+    done
+    cd "$startdir"
+}
 
-
+# history search
+k() { grep -P "$@" ${HISTFILE:-~/.bash_history}  | tail -n 40; }
 
 calc() { echo "scale=3; $*" | bc -l; }
 
@@ -364,7 +381,7 @@ git_empty_branch() { # start an empty git branch. carefull, it deletes untracked
     [[ $# == 1 ]] || { echo 'need a branch name!'; return 1;}
     local gitroot
     gitroot || return 1 # function to set gitroot
-    builtin cd $gitroot
+    builtin cd "$gitroot"
     git symbolic-ref HEAD refs/heads/$1
     rm .git/index
     git clean -fdx
@@ -533,7 +550,7 @@ te() {
 perm_fix() {
     local parent
     if [[ $EUID == 0 ]]; then
-       te "$1" || touch $1
+       te "$1" || touch "$1"
        if [[ $(stat -c "%u" "$1") == 0 ]] ; then
            argdir=$(getdir "$1")
            if [[ $(stat -c "%u" "$argdir") != 0 ]] ; then
@@ -889,7 +906,7 @@ if [[ $- == *i* ]]; then
         unset IFS
         history -a # save history
         history -n # read any new history
-        if [[ ! DESKTOP_SESSION == xmonad && $TERM == *(screen*|xterm*|rxvt*) ]]; then
+        if [[ ! $DESKTOP_SESSION == xmonad && $TERM == *(screen*|xterm*|rxvt*) ]]; then
             # from the screen man page
             if [[ $TERM == screen* ]]; then
                 local title_escape="\033]..2;"