From: Ian Kelling Date: Sat, 1 Feb 2025 03:33:43 +0000 (-0500) Subject: misc improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=141b6bc670f08ce942cbdd1383f6766318b07501;p=distro-setup misc improvements --- diff --git a/brc b/brc index cbc1b76..355edb2 100644 --- a/brc +++ b/brc @@ -2254,6 +2254,8 @@ lowr() { done } +# note: this does not work for EOL chars. +# aka chomp in perl. note this doesn't work as you would want because its not a variable reference. todo: think about improving it. strips() { # remove leading whitespace characters var="${var#"${var%%[![:space:]]*}"}" @@ -3002,7 +3004,7 @@ sk-p() { sk() { # see https://savannah.gnu.org/maintenance/fsf/bash-style-guide/ for justifications local quotes others ret - quotes=2048,2068,2086,2119,2206,2254 + quotes=2048,2068,2086,2119,2206,2254,2231 others=2029,2032,2033,2054,2164,2317 shellcheck -x -W 999 -e $quotes,$others "$@" || ret=$? if (( ret >= 1 )); then @@ -3473,7 +3475,7 @@ psoff() { # Turn on my prompt hook function. pson() { PROMPT_COMMAND=(prompt-command) - if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then + if [[ $TYPESCRIPT_SHELL != true && $TERM == *(screen*|xterm*|rxvt*) ]]; then trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG fi } @@ -3970,27 +3972,28 @@ if [[ $- == *i* ]]; then # version 211203 does not have this feature, 230805 does. we can't # detect this over ssh. We could copy the var over ssh, but I'd # rather just wait until i'm not running the earlier konsole. - if [[ $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then + if [[ $TYPESCRIPT_SHELL != true && $TERM == xterm-256color && $KONSOLE_VERSION && ! $KONSOLE_VERSION == 2[01]* ]]; then # This is from konsole, copied after pressing ctrl-alt-] . - # I figured out what it does from reading git clone https://gitlab.freedesktop.org/Per_Bothner/specifications - # - #proposals/semantic-prompts.md + # I figured out what it does from reading + # https://gitlab.freedesktop.org/Per_Bothner/specifications/proposals/semantic-prompts.md + # locally in /a/opt/freedesktop-specifications/proposals/semantic-prompts.md # # I tried figuring out what they really do from the konsole source code, # but I gave up. # - # \[\e]133;L\a\] This makes it so the last command is always + # This makes it so the last command is always # newline terminated. That is kind nice, but I also want to know # when they aren't, and this screws up my we() function, so # removed. The doc notes that Fish and ZSH both show a specific # char to indicate that happened, that sounds nice so I figured # out how to do that on my own. + #\[\e]133;L\a\] # - # \[\e]133;D;$?\] # This is something to try to show the last exit code. I already do that # and colorize it so removed. + # \[\e]133;D;$?\] # - + # # This creates a think black line between prompts. if [[ ! $PS1 =~ 133 ]] ; then PS1='\[\e]133;A\a\]'"$PS1"'\[\e]133;B\a\]' # shellcheck disable=SC2034 # false positive @@ -4038,8 +4041,8 @@ if [[ $- == *i* ]]; then # # for titlebar. # condition from the screen man page i think. - # note: duplicated in tx() - if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then + # note: duplicated in pson() + if [[ $TYPESCRIPT_SHELL != true && $TERM == *(screen*|xterm*|rxvt*) ]]; then # 40 chars is plenty. trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG else @@ -4412,47 +4415,33 @@ xd() { "${cmd[@]}" "${files[@]}" } - -# Save some for loop typing. Run COMMAND on each of FILES, striping any -# leading paths. -# -# CD_DIRECTORY is assumed if FILES exist in the current directory. -# -# usage: [ CD_DIRECTORY ] COMMAND... FILES.. +# for f in *; do hr $f; some command $f; done +# forf some command * forf() { - local cdto f local -a cmd files while [[ $1 ]]; do if [[ -e $1 ]]; then - if [[ $1 == */* ]]; then - for arg; do - files+=( "${arg##*/}" ) - done - else - if [[ -d $1 ]]; then - cdto="${cmd[0]}" - shift - fi - files=("$@") - fi + for arg; do + files+=( "${arg##*/}" ) + done break fi cmd+=("$1") shift done - if [[ $cdto ]]; then - { - cd "$cdto" - for f in "${files[@]}"; do - "${cmd[@]:1}" "$f" - done - } - else - for f in "${files[@]}"; do - "${cmd[@]}" "$f" - done - fi + for f in "${files[@]}"; do + e "$f" + "${cmd[@]}" "$f" + done } +# Historical side note. For some reason, I kept having to write a pattern like: +# some_data=(*) +# cd /some/other/place +# for f in ${some_data[@]}; do some_command $f; done +# So, I wrote a function to do it quicker, but I have no idea +# what was causing me to have to keep doing that. So, I +# deleted it. it is in git history. + # exists or print. aka exists predicate. # diff --git a/brc2 b/brc2 index db85357..47d71c7 100644 --- a/brc2 +++ b/brc2 @@ -2302,7 +2302,11 @@ feh() { fw() { - firefox -P default "$@" >/dev/null 2>&1 + count=$1 + shift + for ((i=0; i $log_path.t + TYPESCRIPT_SHELL=true script -t $log_path.s 2> $log_path.t }