From: Ian Kelling Date: Sun, 7 Jul 2024 22:19:49 +0000 (-0400) Subject: minor bash improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=1f7213e3a0dcfc21b9946523748e4c342d455583;p=distro-setup minor bash improvements --- diff --git a/brc b/brc index b0f0067..48cb5c4 100644 --- a/brc +++ b/brc @@ -2752,10 +2752,10 @@ skgit() { # remote system, you can use sl --rsync, or the function for that slr # below. -# SL_TEST_CMD: Env var. Meant to be used to vary the files synced -# depending on the remote host. Run this string on the remote host the -# first time sl is run (or if we run slr). The result is passed to -# SL_TEST_HOOK. For example, +# SL_TEST_CMD: Env var. If set, we run this string on the remote host +# the first time sl is run (or if we run slr), and then the result is +# passed to SL_TEST_HOOK which gets run locally. It is meant to be used +# to vary the files synced depending on the remote host. For example, # export SL_TEST_CMD=". /etc/os-release ; echo \${VERSION//[^a-zA-Z0-9]/}" # SL_TEST_HOOK: Env var. It is run as $SL_TEST_HOOK. This can set @@ -2965,10 +2965,13 @@ slr() { sl --rsync "$@" } - -# ssh solo, without multiplexing. Good for debugging / testing. +# ssh with multiplexing. +ssm() { + sl -oControlPath=/tmp/ssh_mux_%u_%h_%p_%r "$@" + } +# ssh solo, without multiplexing. # currently the default, but I might switch back. sss() { - ssh -oControlMaster=no -oControlPath=/ "$@" + ssh -oControlPath=none "$@" } # ssh that respects -i as the only key to use. Good for debugging. @@ -3115,7 +3118,7 @@ psoff() { pson() { PROMPT_COMMAND=(prompt-command) if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then - trap 'auto-window-title "$BASH_COMMAND"' DEBUG + trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG fi } @@ -3487,12 +3490,14 @@ if [[ $- == *i* ]]; then local ps_char ps_color col tmp - # bash 5.0.17 gives an error when the last command used a process redirect like - # while read -r l; do e $l; done < <(echo ok) - if [[ ! $LC_INSIDE_EMACS && $BASH_VERSION == 5.[123456789]* || $BASH_VERSION == [6789]* ]]; then - IFS='[;' read -p $'\e[6n' -d R -rs tmp ||: - col="${tmp##*[^0-9]}" - fi + + # note, I tried reading the current column here in order to add a + # space if there was non-newline terminated output from the last + # command. However, I found that it made ssh escape char not + # work. In bash 5.0.17 after a command using <() it failed and + # output something like ";21" to the terminal after the prompt. It + # did work in 5.1 something. It did not work in emacs. And, one time + # it just randomly output to the terminal. Not worth it. unset IFS @@ -3581,7 +3586,7 @@ if [[ $- == *i* ]]; then fi # version 211203 does not have this feature, 230805 does - if [[ $KONSOLE_VERSION && $KONSOLE_VERSION == [3456789]* || $KONSOLE_VERSION == 2[3456789]* ]]; then + if [[ $SSH_CLIENT ]] || [[ $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 # @@ -3649,7 +3654,8 @@ if [[ $- == *i* ]]; then # condition from the screen man page i think. # note: duplicated in tx() if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then - trap 'auto-window-title "$BASH_COMMAND"' DEBUG + # 40 chars is plenty. + trap 'auto-window-title "${BASH_COMMAND:0:40}"' DEBUG else trap DEBUG fi