# succeeds, add it to ${f[@]};
#
# The first arg that is an existing file starts the FILES args, or an arg "-".
+#
+# example shortening:
+# for f in *; do t -x $a && sk $a; done
+# becomes
+# fm t -x *; fe sk
fm() {
local file end_arg=false in_files=false
local -a files cmd
fi
done
}
-# example shortening:
-# for f in *; do t -x $a && sk $a; done
-# becomes
-# fm t -x *; fe sk
# execute on executables
done
}
+# test shortcut
t() { test "$@"; }
+# cd to directory of FILE
+#
+# usage: cf FILE_OR_DIR
+#
+cf() {
+ local dest
+ dest="$1"
+ if [[ ! -d $dest ]]; then
+ dest="${dest%/*}"
+ fi
+ c "$dest"
+}
+
+
+# Run without pipe & slightly less typing: command | grep
+#
+# usage: cgr GR_ARGS... ,. COMMAND...
+cgr() {
+ local arg in_cmd=false
+ local -a cmd grep
+ for arg; do
+ if [[ $arg == ,. ]]; then
+ in_cmd=true
+ shift
+ continue
+ fi
+ if $in_cmd; then
+ cmd+=("$arg")
+ else
+ grep+=("$arg")
+ fi
+ shift
+ done
+ "${cmd[@]}" | gr "${grep[@]}"
+}
# * stuff that makes sense to be at the end
m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@"
}
-# systemd namespace + mount namespace
-sdmn() {
- local ns unit user tmpf pre_check pid alt_user=false
- local -a final_args
- user=$USER
- while [[ $1 ]]; do
- case $1 in
- -u)
- alt_user=true
- user="$2"
- shift 2
- ;;
- -p)
- pre_check="$2"
- shift 2
- ;;
- *)
- break
- ;;
- esac
- done
-
- ns=$1
- unit=$2
- shift 2
- pid=$(servicepid $unit)
- env-tmpf "$@"
- if $alt_user; then
- final_args=("$@")
- else
- final_args=(bash -c ". $tmpf")
- fi
- if [[ $pre_check ]]; then
- sudm $pre_check
- else
- m sudm nsenter -t $pid -n -m mns-setup $ns
- fi
- m sudm nsenter -t $pid -n --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}"
-}
mnsd() { # mount namespace + systemd network namespace
local ns unit user tmpf pre_check pid alt_user=false
m sudm nsenter -t $pid -n -m mns-setup $ns
fi
fi
- m sudo nsenter -t $pid -n --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}"
+ m sudm nsenter -t $pid -n --mount=/root/mount_namespaces/$ns sudo -u $user -i "${final_args[@]}"
}
m /a/bin/buildscripts/go
# only needed for rg. cargo takes up 11 gigs, filled up the disk on je.
m /a/bin/buildscripts/rust
-m /a/bin/buildscripts/misc
+m /a/bin/buildscripts/textern
#m /a/bin/buildscripts/pithosfly
#m /a/bin/buildscripts/alacritty