+# 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
## 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
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.
_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)
}
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
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
}
-md5diff() {
- [[ $(md5sum < "$1") != $(md5sum < "$2") ]]
-}
-
-
-
mkc() {
mkdir "$1"
c "$1"
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
#!/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