sistema_progs

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

zoxide.bash (1773B)


      1 # ble/contrib/integration/zoxide.bash (C) 2022, akinomyoga
      2 
      3 function ble/contrib/integration:zoxide/completion.advice {
      4   if [[ ! ${_ble_attached-} ]]; then
      5     ble/function#advice/do
      6     return 0
      7   fi
      8 
      9   [[ :$comp_type: == *:auto:* || :$comp_type: == *:[maA]:* ]] && return 0
     10   compopt -o noquote
     11 
     12   ble/term/leave-for-widget
     13   ble/function#advice/do >/dev/null
     14   ble/term/enter-for-widget
     15   ble/textarea#invalidate
     16 
     17   # 単一候補生成の場合は他の候補 (sabbrev 等) を消去して単一確定させる
     18   if ((ADVICE_EXIT==0&&${#COMPREPLY[@]}==1)); then
     19     ble/complete/candidates/clear
     20     [[ $old_cand_count ]] &&
     21       ! ble/variable#is-global old_cand_count &&
     22       old_cand_count=0
     23   fi
     24 }
     25 
     26 function ble/contrib/integration:zoxide/command.advice {
     27   if [[ ${_ble_attached-} && ${READLINE_MARK+set} ]]; then
     28     ble/bin/stty icanon
     29     ble/function#advice/do
     30     ble/bin/stty -icanon
     31   else
     32     ble/function#advice/do
     33   fi
     34 }
     35 
     36 function ble/contrib/integration:zoxide/adjust {
     37   local found=
     38   if ble/is-function _z; then
     39     ble/function#advice around _z ble/contrib/integration:zoxide/completion.advice
     40     found=1
     41   fi
     42   if ble/is-function __zoxide_z_complete; then
     43     ble/function#advice around __zoxide_z_complete ble/contrib/integration:zoxide/completion.advice
     44     found=1
     45   fi
     46   if ble/is-function __zoxide_z; then
     47     ble/function#advice around __zoxide_z ble/contrib/integration:zoxide/command.advice
     48     found=1
     49   fi
     50   if ble/is-function __zoxide_zi; then
     51     ble/function#advice around __zoxide_zi ble/contrib/integration:zoxide/command.advice
     52     found=1
     53   fi
     54   [[ $found ]]
     55 }
     56 
     57 if ! ble/contrib/integration:zoxide/adjust; then
     58   ble/bin#has zoxide || return 1
     59   builtin eval -- "$(zoxide init bash)"
     60   ble/contrib/integration:zoxide/adjust
     61 fi