added my .inputrc
[distro-setup] / .bashrc
diff --git a/.bashrc b/.bashrc
index fcaa4b6e033bc23840692a30b15d03a6269deaf2..712d599618c5be47218f99db46da84b2d5c94674 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -26,21 +26,9 @@ if [[ $SSH_CONNECTION ]] \
     return
 fi
 
-# Side note on ssh.
 
 
 
-###################
-## include files ###
-###################
-
-for x in $HOME/bin/bash-programs-by-ian/repos/*/*-function; do
-    source "$x"
-done
-
-source $HOME/bin/semi-private # so I can share my bashrc
-source $HOME/path_add-function
-
 
 
 
@@ -50,6 +38,10 @@ source $HOME/path_add-function
 
 CDPATH=.:/a
 
+# 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
+
 # remove gnome keyring warning messages
 # there is probably a more proper way, but I didn't find any easily on google
 unset GNOME_KEYRING_CONTROL
@@ -59,8 +51,8 @@ shopt -s extglob
 #include .files when globbing.
 shopt -s dotglob
 #but ignore files name . and ..
-#those are default when this is set to anything, so we just set it to one of them
-export GLOBIGNORE=.
+# this also sets dotglob, but no harm in setting it explicitly
+export GLOBIGNORE=*/.:*/..
 
 # broken with bash_completion package. Saw a bug for this once. Don't anymore.
 # still broken in wheezy
@@ -98,6 +90,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,15 +135,14 @@ 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
 
-path_add --ifexists /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
-path_add $HOME/bin/bash-programs-by-ian/utils
+
 # note, if I use a machine I don't want files readable by all users, set
 # umask 077  # If fewer than 4 digits are entered, leading zeros are assumed
 
@@ -159,6 +151,20 @@ C_DEFAULT_DIR=/a
 
 
 
+###################
+## include files ###
+###################
+
+for x in $HOME/bin/bash-programs-by-ian/repos/*/*-function; do
+    source "$x"
+done
+source $HOME/identify-distro-functions
+source $HOME/bin/semi-private # so I can share my bashrc
+source $HOME/path_add-function
+path_add --ifexists /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
+path_add $HOME/bin/bash-programs-by-ian/utils
+
+
 ###############
 ### aliases ###
 ###############
@@ -215,6 +221,9 @@ if [[ $OS == Windows_NT ]]; then
 fi
 
 
+
+
+
 #####################
 ###  functions   ####
 #####################
@@ -229,10 +238,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 +276,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 | ssh $x tar xz
+    done
+    cd $(mktemp -d)
+    cp /a/c/repos/bash/!(.git) .
+    for x in "$@"; do
+        tar cz * | ssh $x tar xz
+    done
+    cd "$startdir"
+}
 
-
+# history search
+k() { grep -P "$@" ${HISTFILE:-~/.bash_history}  | tail -n 40; }
 
 calc() { echo "scale=3; $*" | bc -l; }
 
@@ -301,15 +326,6 @@ dc() {
 }
 
 
-distro_name() {
-    if [[ -f /etc/fedora-release ]]; then
-        echo fedora
-    else
-        grep "^ID=.*" /etc/os-release | sed 's/^ID=//'
-    fi
-}
-
-
 dt() {
     date "+%A, %B %d, %r" "$@"
 }
@@ -364,7 +380,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
@@ -460,6 +476,8 @@ despace() {
 }
 
 
+
+
 # package manager
 # aliases would be much more compact, but they can't be used as ssh commands
 # also, to be used in a script, you need -i which prints annoying
@@ -533,7 +551,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
@@ -745,6 +763,8 @@ else
 fi
 
 
+
+
 # todo, update this
 complete -F _longopt la lower low rlt rld rl lld ts ll dircp ex fcp fct fpst gr
 
@@ -889,7 +909,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;"
@@ -923,6 +943,9 @@ if [[ $- == *i* ]]; then
 fi
 
 
+
+
+
 ###########################################
 # stuff that makes sense to be at the end #
 ###########################################