a few new functions
[distro-setup] / .bashrc
diff --git a/.bashrc b/.bashrc
index dfc10aeaa90ab021500cacfc3b88cc81f82763a4..3725a9f1a56594f2fc3ae7998db933b9ffcd4d52 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -39,6 +39,7 @@
 # assume we want ssh commands to source this file if we are sourcing it,
 # and we haven't specified otherwise already
 [[ ! $BASH_LOGIN_SHELL ]] && export BASH_LOGIN_SHELL=true
+#BASH_LOGIN_SHELL=false # temporary override
 
 # first conditions show that we are an ssh command without an interactive shell
 if [[ $SSH_CONNECTION ]] \
@@ -80,7 +81,9 @@ unalias -a
 # use extra globing features.
 shopt -s extglob
 # include .files when globbing, but ignore files name . and ..
-# setting this also sets dotglob
+# setting this also sets dotglob.
+# Note, this doesn't work in bash 4.4 anymore, for paths with
+# more than 1 directory, like a/b/.foo, since * is fixed to not match /
 export GLOBIGNORE=*/.:*/..
 
 # broken with bash_completion package. Saw a bug for this once. Don't anymore.
@@ -110,15 +113,16 @@ shopt -s histappend
 shopt -s checkwinsize
 # attempt to save multiline single commands as single history entries.
 shopt -s cmdhist
+# enable **
 shopt -s globstar
 
 
 # inside emacs fixes
-if [[ $INSIDE_EMACS ]]; then
+if [[ $RLC_INSIDE_EMACS ]]; then
     # EMACS is used by bash on startup, but we don't need it anymore.
     # plus I hit a bug in a makefile which inherited it
     unset EMACS
-    export INSIDE_EMACS
+    export RLC_INSIDE_EMACS
     export PAGER=cat
     export MANPAGER=cat
     # scp completion does not work, but this doesn't fix it. todo, figure this out
@@ -151,7 +155,7 @@ fi
 
 if [[ $- == *i* ]]; then
     # for readline-complete.el
-    if [[ $INSIDE_EMACS ]]; then
+    if [[ $RLC_INSIDE_EMACS ]]; then
         # all for readline-complete.el
         stty echo
         bind 'set horizontal-scroll-mode on'
@@ -209,7 +213,6 @@ C_DEFAULT_DIR=/a
 ###################
 ## include files ###
 ###################
-
 for _x in /a/bin/distro-functions/src/* /a/bin/!(githtml)/*-function?(s); do
     source "$_x"
 done
@@ -225,6 +228,7 @@ path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-t
 #path_add $HOME/bin/bash-programs-by-ian/utils
 
 
+
 ###############
 ### aliases ###
 ###############
@@ -259,7 +263,6 @@ unalias ls ll grep &>/dev/null ||:
 
 
 
-
 #####################
 ###  functions   ####
 #####################
@@ -334,6 +337,13 @@ a() {
 
 ack() { ack-grep "$@"; }
 
+astudio() {
+    # googling android emulator libGL error: failed to load driver: r600
+    # lead to http://stackoverflow.com/a/36625175/14456
+    export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1
+    /a/opt/android-studio/bin/studio.sh "$@" &r;
+}
+
 bashrcpush () {
     local startdir="$PWD"
     cd ~
@@ -342,7 +352,7 @@ bashrcpush () {
         tar cz bin/semi-private bin/distro-functions/src | ssh $x tar xz
     done
     cd $(mktemp -d)
-    command cp /a/c/repos/bash/!(.git) ~/.gitconfig .
+    command cp /a/c/repos/bash/!(.git|..|.) ~/.gitconfig .
     for x in "$@"; do
         tar cz * | ssh $x tar xz
     done
@@ -646,6 +656,14 @@ and works in older versions of git which did not have that."
     echo "${p%%/.git}"
 }
 
+# quit will prompt if the program crashes.
+gmacs() { gdb -ex=r -ex=quit --args emacs "$@"; r; }
+
+gse() {
+    git send-email --notes '--envelope-sender=<ian@iankelling.org>' \
+        --suppress-cc=self "$@"
+}
+
 gr() {
     grep -iIP --color=auto "$@"
 }
@@ -658,6 +676,18 @@ grr() {
     fi
 }
 
+hstatus() {
+    # do git status on published repos
+    cd /a/bin/githtml
+    for x in !(forks) forks/* ian-specific/*; do
+        cd `readlink -f $x`/..
+        hr
+        echo $x
+        i status
+        cd /a/bin/githtml
+    done
+}
+
 hl() { # history limit. Write extra history to archive file.
     # todo: this is not working or not used currently
     local max_lines linecount tempfile prune_lines x
@@ -706,9 +736,10 @@ ic() {
 }
 
 
-ifn () {
+ifn() {
     # insensitive find
-    find -L . -iname "*$**" 2>/dev/null
+    find -L . -not \( -name .svn -prune -o -name .git -prune \
+         -o -name .hg -prune \) -iname "*$**" 2>/dev/null
 }
 
 
@@ -956,6 +987,13 @@ sb() { # sudo bash -c
 }
 complete -F _root_command s sb
 
+scssl() {
+    # s gem install scss-lint
+    pushd /a/opt/thoughtbot-guides
+    git pull --stat
+    popd
+    scss-lint -c /a/opt/thoughtbot-guides/style/sass/.scss-lint.yml "$@"
+}
 
 ser() {
     local s; [[ $EUID != 0 ]] && s=sudo
@@ -1092,7 +1130,7 @@ te() {
 
 tm() {
     # timer in minutes
-    (sleep $(calc "$@ * 60") && mpv --volume 50 /a/bin/data/alarm.mp3) > /dev/null 2>&1 &
+    (sleep $(calc "$@ * 60") && mpv --volume 50 /a/bin/data/alarm.mp3 --loop=no) > /dev/null 2>&1 &
 }
 
 ts() { # start editing a new file
@@ -1352,7 +1390,7 @@ if [[ $- == *i* ]]; then
     shopt -s autocd
     shopt -s dirspell
     PS1='\w'
-    if [[ $- == *i* ]]  && [[ ! $INSIDE_EMACS ]]; then
+    if [[ $- == *i* ]]  && [[ ! $RLC_INSIDE_EMACS ]]; then
         PROMPT_DIRTRIM=2
        bind -m vi-command B:shell-backward-word
        bind -m vi-command W:shell-forward-word
@@ -1405,8 +1443,6 @@ fi
 
 
 
-
-
 ###########################################
 # stuff that makes sense to be at the end #
 ###########################################
@@ -1456,6 +1492,15 @@ fi
 
 path_add --end ~/.npm-global
 
+
+# didn't get drush working, if I did, this seems like the
+# only good thing to include for it.
+# Include Drush completion.
+# if [ -f "/home/ian/.drush/drush.complete.sh" ] ; then
+#     source /home/ian/.drush/drush.complete.sh
+# fi
+
+
 # https://wiki.archlinux.org/index.php/Xinitrc#Autostart_X_at_login
 # i added an extra condition as gentoo xorg guide says depending on
 # $DISPLAY is fragile.