source "$x"
done
-# so I can share my bashrc
-source $HOME/bin/bash_private
+source $HOME/bin/bash_private # so I can share my bashrc
source $HOME/path_add-function
CDPATH=.:/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
+
path_add /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools
#use extra globing features. See man bash, search extglob.
# 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
-
+C_DEFAULT_DIR=/a
grep -i --binary-files=without-match --color=auto "$@"
}
-gr() {
- gr -r "$@"
+grr() {
+ grep -ri --binary-files=without-match --color=auto "$@"
}
}
# force symbolic link creation.
-# trash-put any existing targets,
-# then send all arguments to ln -s
+# trash-put any existing files where links would be created.
+# mkdir -p the directory containing the link(s) if needed.
+# then do ln -s -- "$@"
lnf() {
+ if [[ $# -gt 2 && ! -d ${!#} ]]; then
+ mkdir -p "${!#}"
+ fi
if [[ $# -gt 1 && -d ${!#} ]]; then
local oldcwd=$PWD
cd ${!#} # last arg
for x in "${@:1:$(($#-1))}"; do # all but last arg
- # a broken symlink will fail the "exists" -e test
- [[ -e "${x##*/}" || -L "${x##*/}" ]] && trash-put "${x##*/}"
+ # remove any trailing slashes
+ x="${x%%+(/)}"
+ # remove any leading directory components
+ x="${x##*/}"
+ te "$x" && trash-put "$x"
done
cd "$oldcwd"
elif [[ $# -eq 2 ]]; then
- [[ -e "$2" || -L "$2" ]] && rm "$2"
+ if te "$2"; then
+ trash-put "$2"
+ elif [[ ! -d $(getdir "$2") ]]; then
+ mkdir -p $(getdir "$2")
+ fi
else
- [[ -e "${1##*/}" || -L "${1##*/}" ]] && rm "${1##*/}"
+ te "${1##*/}" && rm "${1##*/}"
fi
- ln -s "$@"
+ ln -s -- "$@"
}
fi
-
+# test existence
+te() {
+ local ret=0
+ for x in "$@"; do
+ [[ -e "$x" || -L "$x" ]] || ret=1
+ done
+ return $ret
+}
# fix root file ownership for FILE argument.
[[ -e $1 ]] || touch $1
if [[ $(stat -c "%u" "$1") == 0 ]] ; then
- argdir=$(dirstrip "$1")
+ argdir=$(getdir "$1")
if [[ $(stat -c "%u" "$argdir") != 0 ]] ; then
if ! chown "--reference=$argdir" "$1"; then
echo failed to fix bad ownership file permissons
-
hl() { # history limit. Write extra history to archive file.
local max_lines linecount tempfile
- if ! [[ -w $HISTFILE ]] || ! [[ -w ${HISTFILE}_archive ]]; then
- echo "error: a history file is not writable."
- return 1
- fi
+ for x in $HISTFILE ${HISTFILE}_archive; do
+ if [[ -e $x && ! -w $x ]]; then
+ echo "error: history file $x is not writable."
+ return 1
+ fi
+ done
history -w
if [[ $1 ]]; then
max_lines=$(($1 * 2)) # 2 lines for every history command
history -c
history -r
}
-# run hl when bash exits normally
-trap hl EXIT
+# commands to run when bash exits normally
+trap "hl; smh" EXIT
# temporary variables to test colorization