X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=7d58392d65fe59e5870d862232690bb74a527291;hb=b186607514fbcf10bd5664ccb759a6e873f048c7;hp=470c143f87a160b931ec323aeaff1840fbcc705f;hpb=d6def754cd241538c61456536b52ee51cbd85b42;p=distro-setup diff --git a/brc b/brc index 470c143..7d58392 100644 --- a/brc +++ b/brc @@ -224,6 +224,7 @@ export PROFILE_TASKS_TASK_OUTPUT_LIMIT=100 # i for insensitive. the rest from # X means dont remove the current screenworth of output upon exit # R means to show colors n things +# a useful flag is -F aka --quit-if-one-screen export LESS=RXij12 export SYSTEMD_LESS=$LESS @@ -260,6 +261,8 @@ if [[ $SOE ]]; then fi + + mysrc() { local path dir file path=$1 @@ -435,7 +438,7 @@ cl() { # we have ~33 buttons as of this writing, so lets # prune down the history every once in a while. if (( start > 500 )); then - tac ~/.cdirs | awk '!seen[$0]++' | head -n 200 | sponge ~/.cdirs + tac ~/.cdirs | awk '!seen[$0]++' | head -n 200 | tac | sponge ~/.cdirs || [[ $? == 141 ]] fi for (( j=$start; j >= 0; j-- )); do @@ -458,7 +461,7 @@ cl() { fi read -r -N 1 input if [[ $input != $'\n' ]]; then - c ${buttondirs[$input]} + c "${buttondirs[$input]}" fi } # back list @@ -703,7 +706,7 @@ bwm() { } -# for running in a fai rescue +# for running in a fai rescue. iank specific. kdrescue() { d=vgata-Samsung_SSD_850_EVO_2TB_S2RLNX0J502123D for f in $d vgata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V; do @@ -836,6 +839,10 @@ cat-new-files() { } +chownme() { + s chown -R $USER:$USER "$@" +} + # shellcheck disable=SC2032 chown() { # makes it so chown -R symlink affects the symlink and its target. @@ -856,6 +863,12 @@ cim() { d() { builtin bg "$@"; } ccomp bg d +# f would be more natural, but i already am using it for something +z() { builtin fg "$@"; } +ccomp fg z + +x() { builtin kill %%; } + dc() { diff --strip-trailing-cr -w "$@" # diff content } @@ -869,6 +882,26 @@ despace() { done } +# df progress +# usage: dfp MOUNTPOINT [SECOND_INTERVAL] +# SECOND_INTERVAL defaults to 90 +dfp() { + # mp = mountpoint + local a b mp interval + mp=$1 + interval=${2:-90} + if [[ ! $mp ]]; then + echo "dfp: error, missing 1st arg" >&2 + return 1 + fi + while true; do + a=$(df --output=used $mp | tail -n1) + sleep $interval + b=$(df --output=used $mp | tail -n1) + printf "used mib: %'d mib/min: %s\n" $(( b /1000 )) $(( (b-a) / (interval * 1000 / 60 ) )) + done +} + # get ipv4 ip from HOST. or if it is already a number, return that hostip() { local host="$1" @@ -942,7 +975,8 @@ ea() { printf "%s" "${arg}" |& hexdump -C done } -# echo vars. print var including escapes, etc + +# echo variables. print var including escapes, etc, like xxd for variable ev() { if (( ! $# )); then echo no args @@ -977,6 +1011,9 @@ etail2() { ccomp tail etail etail2 +showkeys() { + ssh "$@" cat .ssh/authorized_keys{,2} + } # print exim old pids @@ -1081,6 +1118,20 @@ faf() { # find all files. use -L to follow symlinks -o -name .undo-tree-history -prune \) -type f 2>/dev/null } +# usage ffconcat FILES_TO_CONCAT OUTPUT_FILE +ffconcat() { + local tmpf + tmpf=$(mktemp) + printf "file '%s'\n" "$1" >$tmpf + while (( $# > 1 )); do + shift + printf "file '%s'\n" "$1" >>$tmpf + done + # https://trac.ffmpeg.org/wiki/Concatenate + ffmpeg -f concat -safe 0 -i $tmpf -c copy "$1" + rm $tmpf +} + # full path without resolving symlinks fp() { local dir base @@ -2362,7 +2413,7 @@ s/^\Wcapability: (.*)/\1/;Ta;h;b # and changing directory, so we don't have any open # directories or files that could cause problems when # remounting. -z() { +zr() { local tmp tmp=$(type -p "$1") if [[ $tmp ]]; then @@ -2547,18 +2598,22 @@ if [[ $- == *i* ]]; then _title_escape="\033]0;" fi + # make the titlebar be the last command and the current directory. settitle () { - # this makes it so we show the current command if - # one is running, otherwise, show nothing - if [[ $1 == prompt-command ]]; then + + # These are some checks to help ensure we dont set the title at + # times that the debug trap is running other than the case we + # want. Some of them might not be needed. + if (( ${#FUNCNAME[@]} != 1 || ${#BASH_ARGC[@]} != 2 || $BASH_SUBSHELL != 0 )); then return 0 fi - if (( ${#BASH_ARGC[@]} == 1 && BASH_SUBSHELL == 0 )); then - echo -ne "$_title_escape ${PWD/#$HOME/~} " - printf "%s" "$*" - echo -ne "\007" + if [[ $1 == prompt-command ]]; then + return 0 fi + echo -ne "$_title_escape ${PWD/#$HOME/~} " + printf "%s" "$*" + echo -ne "\007" } # note, this wont work: