small cleanup
authorIan Kelling <ian@iankelling.org>
Sun, 14 Aug 2016 05:33:30 +0000 (22:33 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:41:25 +0000 (16:41 -0700)
.bashrc
.profile
path_add-function

diff --git a/.bashrc b/.bashrc
index f9e2305f490565386ba06e767f178bd2fb766aeb..3dc94d42688bc01d40cbb2a3f6fb9c9de4fbc8b5 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -1,3 +1,17 @@
+# Copyright (C) 2016 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
 # to debug
 #set -x
 # redirect output to log file. this doesn't work. todo figure out why
@@ -196,7 +210,7 @@ C_DEFAULT_DIR=/a
 ## include files ###
 ###################
 
-for _x in /a/bin/distro-functions/src/* /a/bin/*/*-function; do
+for _x in /a/bin/distro-functions/src/* /a/bin/*/*-function?(s); do
     source "$_x"
 done
 unset _x
@@ -204,7 +218,7 @@ unset _x
 for x in /a/bin/bash_unpublished/*; do source $x; done
 source $(dirname $(readlink -f $BASH_SOURCE))/path_add-function
 source /a/bin/log-quiet/logq-function
-source /a/bin/log-once/log-once-function
+source /a/bin/log-quiet/log-once-function
 path_add /a/exe
 path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
 # todo, these need to be renamed to be less generic.
@@ -302,7 +316,7 @@ _cdiff-prep() {
 
 _khfix_common() {
     local h=${1##*@}
-    ssh-keygen -R $h
+    ssh-keygen -R $h -f $(readlink -f ~/.ssh/known_hosts)
     local x=$(timeout 0.1 ssh -v $1 |& sed -rn "s/debug1: Connecting to $h \[([^\]*)].*/\1/p");
     ssh-keygen -R $x -f $(readlink -f ~/.ssh/known_hosts)
 }
@@ -372,15 +386,22 @@ cdiff() {
     done < "$unified"
 }
 
-cgpl ()
+cgpl()
 {
-    if [[ $# == 0 ]]; then
+    if (($#)); then
+        cp /a/bin/data/COPYING "$@"
+    else
         cp /a/bin/data/COPYING .
+    fi
+}
+capache()
+{
+    if (($#)); then
+        cp /a/bin/data/LICENSE "$@"
     else
-        cp /a/bin/data/COPYING "$@"
+        cp /a/bin/data/LICENSE .
     fi
 }
-
 chown() {
     # makes it so chown -R symlink affects the symlink and its target.
     if [[ $1 == -R ]]; then
@@ -574,6 +595,30 @@ fw() {
     firefox -P default "$@" >/dev/null 2>&1
 }
 
+getdir () {
+    local help="Usage: getdir [--help] PATH
+Output the directory of PATH, or just PATH if it is a directory."
+    if [[ $1 == --help ]]; then
+        echo "$help"
+        return 0
+    fi
+    if [[ $# -ne 1 ]]; then
+        echo "getdir error: expected 1 argument, got $#"
+        return 1
+    fi
+    if [[ -d $1 ]]; then
+        echo "$1"
+    else
+        local dir="$(dirname "$1")"
+        if [[ -d $dir ]]; then
+            echo "$dir"
+        else
+            echo "getdir error: directory does not exist"
+            return 1
+        fi
+    fi
+}
+
 git_empty_branch() { # start an empty git branch. carefull, it deletes untracked files.
     [[ $# == 1 ]] || { echo 'need a branch name!'; return 1;}
     local gitroot
@@ -732,12 +777,6 @@ make-targets() {
 }
 
 
-md5diff() {
-    [[ $(md5sum < "$1") != $(md5sum < "$2") ]]
-}
-
-
-
 mkc() {
     mkdir "$1"
     c "$1"
@@ -867,12 +906,8 @@ EOF
 
 s() {
     # background
-    # alias s='SUDOD="$PWD" sudo -i '
-    # because this is an alias, and the extra space at the end, it would allow
-    #  aliases to be used with it. but aliases aren't used in scripts,
-    #  better to eliminate inconsistencies. Plus, you can't do s=s; $s command
-    #  with an alias, which I like to do in some functions
-    # extra space at the end allows aliases to work
+    # I use a function because otherwise we can't use in a script,
+    # can't assign to variable.
     #
     # note: gksudo is recommended for X apps because it does not set the
     # home directory to the same, and thus apps writing to ~ fuck things up
index a6429f17267cbefbc005d0dee378c8dce09d7e1c..6596cb5e4381a761102e3daf35905c7a5990567b 100644 (file)
--- a/.profile
+++ b/.profile
@@ -1,6 +1,2 @@
 # see .bashrc_profile for commentary
 echo this is ~/.profile, either my .bashrc_profile is unavailable or this is posix mode or not bash
-
-export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
-
-[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
index 0dbaf9fa58de4533c48d68826ce03c37416959ac..9537fe73076a308e22000c53b95902f00f7f7fbb 100644 (file)
@@ -1,8 +1,22 @@
 #!/bin/bash
+# Copyright (C) 2016 Ian Kelling
+
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+
+#     http://www.apache.org/licenses/LICENSE-2.0
+
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
 # avoiding bashisms so it can be used in edge cases where I don't have bash,
 # however, I'm not super confident that I've avoided them all
 #
-#
 path_add() {
     local help="usage: path_add [options] PATH
 --help:     print this