X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=2a770ae0e416297add55e9293f1779907f44681e;hb=774fe9ab8c8d5c71614feda5a283b4a91fb3f145;hp=e0f2a883d209344e04e4c5a7d4b4bc9cd46d0726;hpb=da085f71e5ae00a9f78ed903be6ae675f66eacfa;p=distro-setup diff --git a/brc b/brc index e0f2a88..2a770ae 100644 --- a/brc +++ b/brc @@ -238,8 +238,7 @@ export SL_INFO_DIR=/p/sshinfo if [[ -s $bashrc_dir/path-add-function ]]; then source $bashrc_dir/path-add-function if [[ $SSH_CLIENT ]]; then - # [[ -d /home/iank/.iank/e/e ]] mounts it unnecessarily, so use this. - if grep -qF /home/iank/.iank/e/e /etc/auto.iank /etc/exports &>/dev/null; then + if grep -qF /home/iank/.iank/e/e /etc/exports &>/dev/null; then export EMACSDIR=/home/iank/.iank/e/e fi path-add $bashrc_dir @@ -427,15 +426,17 @@ utcl() { # utc 24 hour time to local hour 24 hour time } # c. better cd -if type -p wcd &>/dev/null; then - if [[ $LC_INSIDE_EMACS ]]; then - c() { wcd -c -z 50 -o "$@"; } +if ! type -t c &>/dev/null; then + if type -p wcd &>/dev/null; then + if [[ $LC_INSIDE_EMACS ]]; then + c() { wcd -c -z 50 -o "$@"; } + else + # lets see what the fancy terminal does from time to time + c() { wcd -c -z 50 "$@"; } + fi else - # lets see what the fancy terminal does from time to time - c() { wcd -c -z 50 "$@"; } + c() { cd "$@"; } fi -else - c() { cd "$@"; } fi ccomp cd c @@ -1119,7 +1120,7 @@ low() { # make filenames lowercase, remove bad chars fi f="${arg##*/}" new="${f,,}" # downcase - new="${new//[^[:alnum:]._-]/_}" # sub bad chars + new="${new//[^a-zA-Z0-9._-]/_}" # sub bad chars new="${new#"${new%%[[:alnum:]]*}"}" # remove leading/trailing non-alnum new="${new%"${new##*[[:alnum:]]}"}" # remove bad underscores, like __ and _._ @@ -1321,6 +1322,13 @@ rsu() { # [OPTS] HOST PATH } ccomp rsync rsd rsa rst rsu +# find programs listening on a port +ssp() { + local port=$1 + # to figure out these args, i had to look at the man page from git version, as of 2022-04. + s ss -lpn state listening sport = $port +} + resolvcat() { local f if [[ $(systemctl is-active nscd ||:) != inactive ]]; then @@ -1328,7 +1336,7 @@ resolvcat() { fi f=/etc/resolv.conf echo $f:; ccat $f - hr; s ss -lpn 'sport = 53' + hr; s ss -lpn sport = 53 if systemctl is-enabled dnsmasq &>/dev/null || [[ $(systemctl is-active dnsmasq ||:) != inactive ]]; then # this will fail is dnsmasq is failed hr; m ser status dnsmasq | cat || : @@ -1372,6 +1380,10 @@ rmstrips() { ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less } +sudo () { + command sudo "$@" || return $? + DID_SUDO=true +} s() { # background # I use a function because otherwise we cant use in a script, @@ -1894,6 +1906,12 @@ psnetns() { if [[ $x ]]; then echo "$x"; else echo $l; fi; done } +nonet() { + if ! s ip netns list | grep -Fx nonet &>/dev/null; then + s ip netns add nonet + fi + sudo -E env /sbin/ip netns exec nonet sudo -E -u iank /bin/bash +} m() { printf "%s\n" "$*"; "$@"; }