sistema_progs

Programas para customizar o meu entorno de traballo nos meus equipos persoais
Log | Files | Refs

D1665.bashrc2 (3520B)


      1 # -*- mode: sh-bash -*-
      2 
      3 type=fix3b
      4 
      5 if [[ $type == rep-c2w-auto-fail ]]; then
      6   source out/ble.sh --norc
      7 
      8   getCPos() {
      9     local v=() t=$(stty -g)
     10     stty -echo
     11     printf "\033[6n"
     12     IFS='[;' read -ra v -d R
     13     stty $t
     14     CPos=(${v[@]:1})
     15   }
     16 
     17   custom_prompt() {
     18     getCPos
     19     if [ $CPos -eq 1 ]; then
     20       PS1=""
     21     else
     22       PS1="\n"
     23     fi
     24   }
     25   PROMPT_COMMAND=custom_prompt
     26 
     27   ble-attach
     28 fi
     29 
     30 #------------------------------------------------------------------------------
     31 
     32 if [[ $type == rep-c2w-auto-fail-min ]]; then
     33   source out/ble.sh --norc
     34   getCPos() {
     35     local v=() t=$(stty -g)
     36     stty -echo
     37     printf "\033[6n"
     38     IFS='[;' read -ra v -d R
     39     stty $t
     40     CPos=(${v[@]:1})
     41   }
     42   PROMPT_COMMAND=getCPos
     43 fi
     44 
     45 #------------------------------------------------------------------------------
     46 
     47 if [[ $type == fix-exclude-blesh ]]; then
     48   custom_prompt() {
     49     cmd_cde=$?
     50     window_title
     51     if ! ble 2>/dev/null; then
     52       getCPos
     53       if [ $CPos -eq 1 ]; then
     54         PS1=""
     55       else
     56         PS1="\n"
     57       fi
     58     fi
     59     PS1+="\[$(tput setaf 1)\]┏━"
     60   }
     61 
     62   source out/ble.sh --norc
     63   getCPos() {
     64     if [[ ! ${_ble_attached-} ]]; then
     65       #if ! ble 2>/dev/null; then
     66       local v=() t=$(stty -g)
     67       stty -echo
     68       printf "\033[6n"
     69       IFS='[;' read -ra v -d R
     70       stty $t
     71       CPos=(${v[@]:1})
     72     fi
     73   }
     74   PROMPT_COMMAND=getCPos
     75 fi
     76 
     77 #------------------------------------------------------------------------------
     78 # 修正案2
     79 
     80 if [[ $type == fix2 ]]; then
     81   source out/ble.sh --norc
     82   custom_prompt() {
     83     printf -v PS1 $'\[ \b\e[%dC %s\r\]' $((COLUMNS-2)) "$(tput xenl && echo ' ')"
     84     PS1+='hello\$ '
     85   }
     86   PROMPT_COMMAND=custom_prompt
     87 fi
     88 
     89 if [[ $type == fix3 ]]; then
     90   source out/ble.sh --norc
     91 
     92   getCPos() {
     93     local v=() t=$(stty -g)
     94     stty -echo
     95     printf "\033[6n"
     96     IFS='[;' read -ra v -d R
     97     stty $t
     98     CPos=(${v[@]:1})
     99   }
    100 
    101   if [[ ${BLE_VERSION-} ]]; then
    102     ble/function#advice after ble/widget/clear-screen '_ble_edit_lineno=0'
    103     _check_clear_command() {
    104       local rex_eval_prefix='((eval|command|env|sudo)[[:space:]]+)?'
    105       local rex_clear_command='(tput[[:space:]]+)?(clear|reset)'
    106       local rex=$'(^|[\n;&|(])[[:space:]]*'$rex_eval_prefix$rex_clear_command'([ \t\n;&|)]|$)'
    107       [[ $BASH_COMMAND =~ $rex ]] && _ble_edit_lineno=0
    108     }
    109     blehook POSTEXEC+=_check_clear_command
    110   fi
    111 
    112   custom_prompt() {
    113     if
    114       if [[ $_ble_attached ]]; then
    115         ((_ble_edit_lineno==0))
    116       else
    117         getCPos; [ $CPos -eq 1 ]
    118       fi
    119     then
    120       PS1=""
    121     else
    122       PS1="\n"
    123     fi
    124     PS1+='hello\$ '
    125   }
    126   PROMPT_COMMAND=custom_prompt
    127 fi
    128 
    129 if [[ $type == fix3b ]]; then
    130   source out/ble.sh --norc
    131 
    132   getCPos() {
    133     local v=() t=$(stty -g)
    134     stty -echo
    135     printf "\033[6n"
    136     IFS='[;' read -ra v -d R
    137     stty $t
    138     CPos=(${v[@]:1})
    139   }
    140 
    141   if [[ ${BLE_VERSION-} ]]; then
    142     CPos=(1 1)
    143     blehook POSTEXEC+=getCPos
    144   fi
    145 
    146   custom_prompt() {
    147     if [[ ! ${_ble_attached-} ]]; then
    148       getCPos
    149     fi
    150     if [ $CPos -eq 1 ]; then
    151       PS1=""
    152     else
    153       PS1="\n"
    154     fi
    155     PS1+='hello\$ '
    156   }
    157   PROMPT_COMMAND=custom_prompt
    158 fi
    159 
    160 #------------------------------------------------------------------------------
    161 # minimal reproducer for absorbed characters
    162 
    163 if [[ $type == rep-absorb-chars ]]; then
    164   getCPos() {
    165     local v=() t=$(stty -g)
    166     stty -echo
    167     printf "\033[6n"
    168     IFS='[;' read -ra v -d R
    169     stty $t
    170     CPos=(${v[@]:1})
    171   }
    172   #PROMPT_COMMAND=getCPos
    173 
    174   something_slow() { sleep 2; }
    175   something_slow
    176 fi