# exit "$@" 2>/dev/null
}
-# Like sed -i, but running whatever command you want with sponge.
+# Like sed -i ... FILE, but running whatever command you want with sponge.
ri() {
# shellcheck disable=SC2124 # false positive
local file="${@: -1}" # last arg
if history -a; then
# If are sshed to HOST2, our history will get overwritten after
# syncing with HOST2 so don't bother.
- if [[ $SSH_CLIENT && $HOST2 != "$HOSTNAME" && $LC_USEBASHRC == sl_* && -w /tmp/S.$LC_USEBASHRC ]]; then
+ if [[ $SSH_CLIENT && $HOST2 != "$HOSTNAME" && $LC_USEBASHRC == sl_* && ${_sl_hist_cmd[0]} != none && -w /tmp/S.$LC_USEBASHRC ]]; then
if [[ $_did_ssh_prompt1 ]]; then
- h="$(history 1)"
+ h="$(history 1 | sed -r 's/^ *([^ ]+ +){4}//')"
+ if [[ ! -v _sl_hist_cmd ]]; then
+ # in trisquel, netcat-traditional does not support -U.
+ if type -p nc &>/dev/null && nc -h |& grep -Eq '^[[:space:]]*-U'; then
+ _sl_hist_cmd=(nc -w 1 -U "/tmp/S.$LC_USEBASHRC")
+ elif type -p socat &>/dev/null; then
+ _sl_hist_cmd=(socat STDIO "UNIX-CONNECT:/tmp/S.$LC_USEBASHRC")
+ else
+ _sl_hist_cmd=(none)
+ fi
+ fi
# note: _sl_last_history is to avoid wastefully sending
# history which won't actually get saved.
if [[ $h != "$_sl_last_history" && $h =~ $cmd_regex ]]; then
_sl_last_history="$h"
- if type -p socat &>/dev/null; then
- sed -r 's/^ *([^ ]+ +){4}//' <<<"$h" | (socat - UNIX-CONNECT:/tmp/S.$LC_USEBASHRC &)
- elif type -p nc &>/dev/null; then
- sed -r 's/^ *([^ ]+ +){4}//' <<<"$h" | (nc -w 1 -U /tmp/S.$LC_USEBASHRC &)
- fi
+ ("${_sl_hist_cmd[@]}" <<<"$h" &)
fi
else
_sl_last_history="$(history 1)"
# printf string + newline
pn() { printf '%s\n' "$@"; }
+# loc = lines of code. nonverbose. Ignores dirs, so, loc *, or loc **.
+#
+loc() {
+ local arg
+ for arg; do
+ [[ -s $arg && -f $arg ]] || continue
+ printf "%8s %s\n" "$(cloc --json "$arg"|jq '.SUM.code')" "$arg"
+ done | sort -n
+}
+
# * stuff that makes sense to be at the end
# note, if we unset IFS, that will mess up completion scripts which
vpncmdroot() {
sdncmdroot wg-quick-tr@client.service "$@"
}
+# usage: vpni [suffix]
+# suffix selects non-default vpn.
+# shellcheck disable=SC2120 # expected
vpni() {
# m sudo nsenter --net=/var/run/netns/client sudo -u iank -i bash # for just the netns
- sdncmd wg-quick-tr@client.service bash
+ sdncmd wg-quick-tr@client$1.service bash
}
vpnbash() {
#m sudm nsenter --net=/var/run/netns/client bash # only gets netns
2 screens: Width=1916
2 screens: XPosition=2
2 screens: YPosition=2
-3840x2160 screen: Height=1076
-3840x2160 screen: Width=1393
-3840x2160 screen: XPosition=2
-3840x2160 screen: YPosition=1082
+3840x2160 screen: Height=2156
+3840x2160 screen: Width=1276
+3840x2160 screen: XPosition=1409
+3840x2160 screen: YPosition=2
DP-0=DP-0
DP-1 eDP-1=DP-1
DP-1-1 eDP-1=DP-1-1