+PATH="$PATH:/opt/midfin/common/lib"
# to debug
#set -x
# redirect output to log file
# settings #
############
-CDPATH=.:/a
+CDPATH=.
# 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
## include files ###
###################
-for _x in $HOME/bin/bash-programs-by-ian/repos/*/*-function ~/opt/distro-functions/src/*; do
+for _x in $HOME/bin/bash-programs-by-ian/repos/*/*-function ~/bin/distro-functions/src/*; do
source "$_x"
done
unset _x
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
+path_add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
+path_add --ifexists --end /a/bin/sda/corpnext/cloudinit
+# todo, these need to be renamed to be less generic.
+# sync overrode something else useful
+#path_add $HOME/bin/bash-programs-by-ian/utils
source $HOME/mw_vars
###############
# note: gksudo is recommended for X apps because it does not set the
-# home directory to the same.
-
-if [[ $- == *i* ]]; then
- # extra space at the end allows aliases to work
- alias s='SUDOD="$PWD" sudo -i '
-else
- s() {
- if [[ $EUID != 0 || $1 == -* ]]; then
- SUDOD="$PWD" sudo -i "$@"
- else
- "$@"
- fi
- }
-fi
+# home directory to the same, and thus apps writing to ~ fuck things up
+# with root owned files.
+
+# 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
+s() {
+ if [[ $EUID != 0 || $1 == -* ]]; then
+ SUDOD="$PWD" sudo -i "$@"
+ else
+ "$@"
+ fi
+}
### functions ####
#####################
+
+
# netselect-apt finds a fast mirror.
# but we need to replace the mirrors ourselves,
# because it doesn't do that. best it can do is
fi
}
+
a() {
beet "${@}"
}
alias ack=ack-grep
fi
+postconfin() {
+ local MAPFILE
+ mapfile -t
+ local s
+ [[ $EUID == 0 ]] || s=s
+ $s postconf -v "${MAPFILE[@]}"
+}
gr() {
- grep -i --binary-files=without-match --color=auto "$@"
+ grep -iI --color=auto "$@"
}
grr() {
- grep -ri --binary-files=without-match --color=auto "$@"
+ grep -riI --color=auto "$@"
}
pub() {
- rsync -rhc /a/h/_site/ li:/var/www/iankelling.org/public_html
+ rld /a/h/_site/ li:/var/www/iankelling.org/public_html
}
bashrcpush () {
local startdir="$PWD"
cd ~
for x in "$@"; do
- ssh $x mkdir -p bin opt/distro-functions
- tar cz bin/bash-programs-by-ian bin/semi-private opt/distro-functions/src | ssh $x tar xz
+ ssh $x mkdir -p bin/distro-functions/src
+ tar cz bin/bash-programs-by-ian bin/semi-private bin/distro-functions/src | ssh $x tar xz
done
cd $(mktemp -d)
command cp /a/c/repos/bash/!(.git) ~/.gitconfig .
cd "$startdir"
}
+whatismyip() { curl ipecho.net/plain ; echo; }
+
# history search
k() { grep -P "$@" ${HISTFILE:-~/.bash_history} | tail -n 40; }
complete -o bashdefault -o default -o nospace -F _git i 2>/dev/null \
|| complete -o default -o nospace -F _git i
-# fast commit
+# fast commit all
ic() {
git commit -am "$*"
}
fi
}
+rbpipe() { rbt post -o --diff-filename=- "$@"; }
+rbp() { rbt post -o "$@"; }
# log with script. timing is $1.t and script is $1.s
}
+# like -e for functions. returns on error.
+# at the end of the function, disable with:
+# trap ERR
+funce() {
+ trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" }
+${FUNCNAME:+FUNCNAME=\"$FUNCNAME\" }${LINENO:+LINENO=\"$LINENO\" }\$?=$?"
+trap ERR
+return' ERR
+}
# timer in minutes
tm() {
}
+myunison() {
+ s unison -auto -owner -group
+}
+
+tu() {
+ local s;
+ local dir="$(dirname "$1")"
+ if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
+ s=s;
+ fi
+ $s teeu "$@"
+}
ts() { # start editing a new file
[[ $# != 1 ]] && echo "I need a filename." && return 1
local quiet
hl() { # history limit. Write extra history to archive file.
- local max_lines linecount tempfile prune_lines
+ local max_lines linecount tempfile prune_lines x
local harchive="${HISTFILE}_archive"
for x in "$HISTFILE" "$harchive"; do
[[ -e $x ]] || { touch "$x" && echo "notice from hl(): creating $x"; }
fi
}
+############## work stuff #############
+
+rn() {
+ pushd /sdx/test/sandbox/;
+ ./setup.sh;
+ ./run.sh;
+ popd
+}
+
+vrm() {
+ virsh destroy $1
+ virsh undefine $1
+}
+
+
+
+
+############# some other section
if [[ $- == *i* ]]; then
# commands to run when bash exits normally
trap "hl; _smh" EXIT
###########################################
if [[ "$SUDOD" ]]; then
cd "$SUDOD"
+ unset SUDOD
elif [[ -d /a ]] && [[ $PWD == $HOME ]] && [[ $- == *i* ]]; then
cd /a
fi
if [[ $SOE ]]; then
errcatch
fi
+
+# I'd prefer to have system-wide, plus user ruby, due to bug in it
+# https://github.com/rubygems/rubygems/pull/1002
+# further problems: installing multi-user ruby and user ruby,
+# you don't get multi-user ruby when you sudo to root, unless its sudo -i.
+# There a third hybrid form, which passenger error suggested I use,
+# but it didn't actually work.
+
+# in cased I never need this
+# rvm for non-interactive shell: modified from https://rvm.io/rvm/basics
+#if [[ $(type -t rvm) == file && ! $(type -t ruby) ]]; then
+# source $(rvm 1.9.3 do rvm env --path)
+#fi
+
+# based on warning from rvmsudo
+export rvmsudo_secure_path=1
+
+if [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
+ source "/usr/local/rvm/scripts/rvm"
+fi
+# make our last exit code be 0
+true