Skip to content

Commit

Permalink
edit (display-shell-version): show zoxide version and fzf-integration…
Browse files Browse the repository at this point in the history
… warnings
  • Loading branch information
akinomyoga committed Dec 8, 2022
1 parent 40625ac commit 3bc3bea
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README-ja_JP.md
Expand Up @@ -581,6 +581,11 @@ function ble/widget/my/example1 {
ble-bind -f C-t my/example1
```

## 2.8 fzf との統合

`fzf``ble.sh` と一緒にお使いいただく場合には、[`contrib/fzf` 統合機能](https://github.com/akinomyoga/blesh-contrib#pencil-fzf-integration) を用いて `fzf` を設定していただく必要があります。
詳細についてはリンク先の説明を御覧ください。

# 3 ヒント

## 3.1 複数行モード
Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -554,6 +554,11 @@ function ble/widget/my/example1 {
ble-bind -f C-t my/example1
```

## 2.8 fzf integration

If you would like to use `fzf` in combination with `ble.sh`, you need to configure `fzf` using [the `contrib/fzf` integration](https://github.com/akinomyoga/blesh-contrib#pencil-fzf-integration).
Please follow the instructions in the link.

# 3 Tips

## 3.1 Use multiline mode
Expand Down
2 changes: 1 addition & 1 deletion contrib
7 changes: 5 additions & 2 deletions docs/ChangeLog.md
Expand Up @@ -140,6 +140,10 @@
- edit (`widget:display-shell-version`): include `ble.sh` version `#D1545` 750ca38
- edit (`display-shell-version`): detect configurations and print details `#D1781` 5015cb56
- edit (`display-shell-version`): show information of the OS distribution and properly handle saved locales `#D1854` 066ec63 bdb7dd6
- edit (`display-shell-version`): show `gawk`, `make`, and `git` versions of the build time `#D1892` e618133
- edit (`display-shell-version`): support running as a user command (reported by DhruvaG2000) `#D1893` e618133
- edit (`display-shell-version`): show warnings for fzf-integration `#D1907` xxxxxxx
- edit (`display-shell-version`): show the `zoxide` version `#D1907` xxxxxxx
- complete (`ble-sabbrev`): support colored output `#D1546` 750ca38
- decode (`ble-bind`): support colored output `#D1547` 750ca38
- decode (`ble-bind`): output bindings of the specified keymaps with `ble-bind -m KEYMAP` (fixup 750ca38) `#D1559` 6e0245a
Expand Down Expand Up @@ -203,8 +207,6 @@
- prompt: preserve transient prompt with `same-dir` after `clear-screen` `#D1876` 69013d9
- color: let `bleopt term_index_colors` override the default if specified `#D1878` 7d238c0
- canvas: update Unicode version 15.0.0 `#D1880` 49e55f4
- edit (`display-shell-version`): show `gawk`, `make`, and `git` versions of the build time `#D1892` e618133
- edit (`display-shell-version`): support running as a user command (reported by DhruvaG2000) `#D1893` e618133
- decode (`vi_imap-rlfunc.txt`): update the widget for `backward-kill-word` as `kill-backward-{u => c}word` `#D1896` e19b796

## Fixes
Expand Down Expand Up @@ -429,6 +431,7 @@
- history: work around broken timestamps in `HISTFILE` (reported by johnyaku) `#D1831` 5ef28eb
- progcomp: disable `command_not_found_handle` (reported by telometto, wisnoskij) `#D1834` 64d471a d5fe1d1 973ae8c
- complete: add completion integration with `zoxide` (reported by ferdinandyb) `#D1838` a96bafe
- contrib/integration/zoxide: update `contrib/integration/zoxide` for zoxide v0.8.1 `#D1907` xxxxxxx
- util (`modifyOtherKeys`): work around delayed terminal identification `#D1842` 14f3c81
- util (`modifyOtherKeys`): fix a bug that kitty protocol is never activated `#D1842` 14f3c81
- util (`modifyOtherKeys`): pass-through kitty protocol sequences (motivated by ferdinandyb) `#D1845` f66e0c1
Expand Down
51 changes: 51 additions & 0 deletions note.txt
Expand Up @@ -1855,6 +1855,17 @@ bash_tips
- leakvars
- keymap の移動 (これは別 commit にする?)

2022-12-06

* wezterm が DA2 を変えている
1;277;0 になっている。xterm との区別ができない気がする。

xterm ですらちゃんと動いていない。うーん。ちゃんと hook はできている。つま
り、modifyOtherKeys のシーケンス自体を正しく出力できていない可能性? 内部で
どのように設定しているかを出力しつつ振る舞いを調べる必要がある。

* ble-reload した時に M-z が効かなくなる

2022-12-03

* declare -f の出力は特殊関数名には使えないのではないか?
Expand Down Expand Up @@ -1886,6 +1897,9 @@ bash_tips
2022-12-04 cevhyruz への私信での解説を何処かに移植して説明するのが良い気が
する。

https://github.com/akinomyoga/ble.sh/issues/246#issuecomment-1294893636
ここでも少し言及している。

* menu-complete: 一時挿入をしない設定
https://github.com/akinomyoga/ble.sh/discussions/252#discussioncomment-4293518

Expand Down Expand Up @@ -6667,6 +6681,43 @@ bash_tips

2022-12-05

* README: fzf-integration について記述する (motivated by SuperSandro2000) [#D1907]
https://github.com/akinomyoga/ble.sh/issues/259

* display-shell-version にも integration が入っていない時にメッセージを表示
する様にする。fzf についてはメッセージを出力した。

その他 (bash-preexec, zoxide) については必要になった時点で自動的にロードさ
れる事になっているので、その場で未だロードされていなくてもそのままにしてお
く事にする。と思ったが zoxide がない。

* done: zoxide についても情報を表示する事にする。

zoxide の初期化スクリプトで一番古い関数は何だろうか。

__zoxide_hook は以下のコミット (2020-09-16) で _zoxide_hook から改名され
ている。この関数は最新版の zoxide でも存在している。

https://github.com/ajeetdsouza/zoxide/commit/f4525db02fde1efa77f56f9f50b27cc1830d4912

_zoxide_hook は以下のコミット (2020-03-13) で導入されている。

https://github.com/ajeetdsouza/zoxide/commit/9c8e8da71a03f5c3c070247f5b0bffd971a70f62

_zoxide_precmd は以下のコミット (2020-03-11) で追加されている。これが
bash 対応の最初と思われる。

https://github.com/ajeetdsouza/zoxide/commit/f0c5e28fd7e56d7cec045a40154ab4768339da44

取り敢えず __zoxide_hook を使って判定する事にする。

* done: 動作を確認してみた所 _z という関数が存在しない。つまり、zoxide の側
で変更があったという事だろうか。以下のコミット (2021-12-29 v0.8.1..) によ
ると _z から __zoxide_z_complete に改名された様である。

https://github.com/ajeetdsouza/zoxide/commit/d106f4e3580d5594d8f1c96c256a8f085e2781a4


* colorglass: saturation (彩度) についての設定を追加する (motivated by auwsom) [#D1906]
https://github.com/akinomyoga/ble.sh/issues/258

Expand Down
32 changes: 31 additions & 1 deletion src/edit.sh
Expand Up @@ -3661,6 +3661,7 @@ function ble/edit/display-version/check:fzf {
ble/util/import/is-loaded contrib/fzf-key-bindings && integ=$label_integration

ble/edit/display-version/add-line "${sgrC}fzf$sgr0 ${sgrF}key-bindings$sgr0, $version$integ"
[[ $integ ]] || ble/edit/display-version/add-line "$label_warning: fzf integration \"contrib/fzf-key-bindings\" is not activated."
fi

# fzf-completion
Expand All @@ -3676,6 +3677,7 @@ function ble/edit/display-version/check:fzf {
ble/util/import/is-loaded contrib/fzf-completion && integ=$label_integration

ble/edit/display-version/add-line "${sgrC}fzf$sgr0 ${sgrF}completion$sgr0, $version$integ"
[[ $integ ]] || ble/edit/display-version/add-line "$label_warning: fzf integration \"contrib/fzf-completion\" is not activated."
fi
}
function ble/edit/display-version/check:starship {
Expand Down Expand Up @@ -3797,11 +3799,37 @@ function ble/edit/display-version/check:gitstatus {

ble/edit/display-version/add-line "${sgrF}romkatv/gitstatus$sgr0, $version"
}
function ble/edit/display-version/check:zoxide {
ble/is-function __zoxide_hook || return 1

# get starship path
local sed_script='s/^[[:space:]]*PS1="\$(\(.\{1,\}\) prompt .*)";\{0,1\}$/\1/p'
ble/util/assign-array starship 'declare -f starship_precmd | ble/bin/sed -n "$sed_script"'
if ! ble/bin#has "$starship"; then
{ builtin eval -- "starship=$starship" && ble/bin#has "$starship"; } ||
{ starship=starship; ble/bin#has "$starship"; } || return 1
fi

local path=
ble/util/assign path 'type -P zoxide 2>/dev/null'
[[ $path ]] || return 1

local version=
ble/util/assign-array version '\command zoxide --version'
[[ $version ]] || return 1
version=${version#zoxide }
version=${version#v}

local integ=
ble/util/import/is-loaded contrib/integration/zoxide && integ=$label_integration
ble/edit/display-version/add-line "${sgrF}zoxide${sgr0}, version $sgrV$version$sgr0 ($path)$integ"
}
function ble/widget/display-shell-version {
ble-edit/content/clear-arg

local sgrC= sgrF= sgrV= sgrA= sgr2= sgr3= sgr0=
local sgrC= sgrF= sgrV= sgrA= sgr2= sgr3= sgr0= bold=
if [[ -t 1 ]]; then
bold=$_ble_term_bold
sgr0=$_ble_term_sgr0
ble/color/face2sgr command_file; sgrC=$ret
ble/color/face2sgr command_function; sgrF=$ret
Expand All @@ -3812,6 +3840,7 @@ function ble/widget/display-shell-version {
fi
local label_noarch=" (${sgrA}noarch$sgr0)"
local label_integration=" $_ble_term_bold(integration: on)$sgr0"
local label_warning="${bold}WARNING$sgr0"

local os_release=
if [[ -s /etc/os-release ]]; then
Expand Down Expand Up @@ -3839,6 +3868,7 @@ function ble/widget/display-shell-version {
ble/edit/display-version/check:oh-my-bash
ble/edit/display-version/check:sbp
ble/edit/display-version/check:gitstatus
ble/edit/display-version/check:zoxide

# locale
local q=\'
Expand Down

0 comments on commit 3bc3bea

Please sign in to comment.