Add bash line editor.

This commit is contained in:
2026-02-14 12:43:31 -05:00
parent c7a300cd58
commit 10251dd1cb
290 changed files with 49346 additions and 0 deletions

View File

@@ -0,0 +1,97 @@
\[ Language: [English](README.md) | **日本語** ]
# blesh-contrib
[akinomyoga/ble.sh](https://github.com/akinomyoga/ble.sh)向けの設定
特に指定のない限りこのリポジトリのファイルは [3条項 BSD ライセンス](LICENSE) で提供されます。
サブディレクトリ `airline` 以下のファイルは MIT ライセンスで提供されます。
<sup>〔訳註: これは[2020年5月20日日本標準時時点のREADME.md](https://github.com/akinomyoga/blesh-contrib/blob/8d89d469bd46d9d1158ab5295cd48a3df6942074/README.md) (8d89d46)の,技術的内容を変更しない日本語訳です〕</sup>
## :pencil: fzfとの統合
### 選択肢その1: `~/.fzf.bash`内で設定する
fzfを`ble.sh`と共に用いたい場合,`.fzf.bash`を次のように書き直します(`/path/to/fzf`は fzf ディレクトリへのパスに置き換えてください。※fzf バイナリではなくて **fzf ディレクトリ**へのパスです)。
```bash
# fzf.bash
# fzfの設定
# ---------
_ble_contrib_fzf_base=/path/to/fzf
if [[ ! "$PATH" == *"$_ble_contrib_fzf_base/bin"* ]]; then
export PATH="${PATH:+${PATH}:}/path/to/fzf/bin"
fi
# 自動補完
# ---------------
if [[ ${BLE_VERSION-} ]]; then
ble-import -d integration/fzf-completion
else
[[ $- == *i* ]] && source -- "$_ble_contrib_fzf_base/shell/completion.bash" 2> /dev/null
fi
# キー束縛
# ------------
if [[ ${BLE_VERSION-} ]]; then
ble-import -d integration/fzf-key-bindings
else
source -- "$_ble_contrib_fzf_base/shell/key-bindings.bash"
fi
```
### 選択肢その2: `~/.blerc`内で設定する
別の方法として,`blerc`において次のように直接設定を書くこともできます(`/path/to/fzf`は各人のfzfへのパスに置き換えてください
この場合,`.fzf.bash``.bashrc`の中で呼び出さ(`source`コマンドを用い)ないでください。
```bash
# blerc
# fzfの設定
_ble_contrib_fzf_base=/path/to/fzf
ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings
```
## :pencil: fzf-git
[fzf-git](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)での設定を`ble.sh`と共に用いるには,次のように設定してください。
```bash
# bashrc / fzf.bash
if [[ ${BLE_VERSION-} ]]; then
_ble_contrib_fzf_base=/path/to/fzf
_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio
ble-import -d integration/fzf-git
fi
```
または,`~/.blerc`内でも構成できます:
```bash
# blerc
_ble_contrib_fzf_base=/path/to/fzf
_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio
ble-import -d integration/fzf-git
```
シェル変数`$_ble_contrib_fzf_git_config`には,有効にする束縛の種別をコロン区切りで列挙します。
`key-binding`という値で,次の形式のキー束縛を有効にします: <kbd>C-g C-f</kbd>, <kbd>C-g C-b</kbd>, <kbd>C-g C-t</kbd>, <kbd>C-g C-h</kbd>及び<kbd>C-g C-r</kbd>。
`sabbrev`という値で,次の語に対する静的略語展開を有効にします: `gf`, `gb`, `gt`, `gh`及び`gr`
`arpeggio`という値で,次のキーの組み合わせを同時に押下できるようにします: <kbd>g f</kbd>, <kbd>g b</kbd>, <kbd>g t</kbd>, <kbd>g h</kbd>及び<kbd>g r</kbd>。
## :pencil: プロンプトシーケンス
### プロンプトシーケンス `\q{contrib/vim-mode}`
この指定はVimのモード名に展開されます。
```bash
# blerc
ble-import contrib/prompt-vim-mode
PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' # PS1にモード名を表示
bleopt keymap_vi_mode_show:= # モード行を表示しない
```

View File

@@ -0,0 +1,39 @@
[ Languages: **English** | [日本語](README-ja.md) (Japanese) ]
# blesh-contrib
Settings for [akinomyoga/ble.sh](https://github.com/akinomyoga/ble.sh)
Unless otherwise specified, files in this repository are licensed by [BSD
3-clause license](LICENSE). The files in `airline` are licensed by the MIT
License. The details are explained in sub-pages:
- &#x2699; [Integration with `fzf`](integration/fzf.md)
- :pencil: `contrib/integration/fzf-initialize`
- :pencil: `contrib/integration/fzf-completion`
- :pencil: `contrib/integration/fzf-key-bindings`
- :pencil: `contrib/integration/fzf-git`
- :pencil: `contrib/integration/fzf-menu`
- &#x2699; Other integrations (undocumented)
- :pencil: `contrib/integration/bash-preexec`
- &#x2699; Other integrations that will be automatically loaded
- :pencil: `contrib/integration/bash-completion`
- :pencil: `contrib/integration/nix-completion`
- :pencil: `contrib/integration/zoxide`
- :pencil: [`contrib/colorglass`](colorglass.md)
- :pencil: `contrib/histdb` (undocumented)
- &#x2699; [Prompt sequences](prompt.md)
- :pencil: `contrib/prompt-defer`
- :pencil: `contrib/prompt-elapsed`
- :pencil: `contrib/prompt-git`
- :pencil: `contrib/prompt-vim-mode`
- &#x2699; Color schemes `contrib/scheme/*`
- &#x2699; Airline themes `contrib/airline/*`
- &#x2699; Highlighting layers `contrib/layer/*`
- &#x2699; Miscellaneous configurations
- :pencil: `contrib/config/execmark`
- :pencil: `contrib/config/github265-prompt-path-level-colors`
- :pencil: `contrib/config/github288-filter-sabbrev-completion`
- :pencil: `contrib/config/github296-named-execmark`
- :pencil: `contrib/config/github302-perlre-server`
- :pencil: `contrib/config/github481-elapsed-mark-without-command`
- :pencil: `contrib/config/github483-elapsed-mark-on-error`

View File

@@ -0,0 +1,109 @@
# :pencil: colorglass
If your terminal supports 24-bit color, you can adjust the theme colors by
specifying gamma, contrast, hue rotation, etc. This also works for the
terminals without the 24-bit color support if `bleopt term_index_colors` is
properly set up, but the resulting colors would be reduced to a smaller number
of colors.
```bash
ble-import contrib/colorglass
# If your terminal does not support the 24-bit colors, please explicitly
# configure it by putting the following line:
#bleopt term_true_colors=
```
## Options
### Blopet `colorglass_gamma` (Integer)
This option specifies the change of gamma by percentage. For example, `bleopt
colorglass_gamma=5` performs the gamma correction with $\gamma=1.05$, and
`bleopt colorglass_gamma=-5` performs the gamma correction with $\gamma=0.95$
```bash
# default
bleopt colorglass_gamma=0
```
### Blopet `colorglass_contrast` (Integer)
This option specifies the contrast modification in the range -100..100.
```bash
# default
bleopt colorglass_contrast=0
```
### Blopet `colorglass_rotate` (Integer)
This option specifies the angle of hue rotation in degrees.
```bash
# default
bleopt colorglass_rotate=0
```
### Blopet `colorglass_saturation` (Integer)
This option specifies the change of saturation in the range -100..100.
```bash
# default
bleopt colorglass_saturation=0
```
### Blopet `colorglass_brightness` (Integer)
This option specifies the change of brightness in the range -100..100.
```bash
# default
bleopt colorglass_brightness=0
```
### Blopet `colorglass_alpha` (Integer)
This option specifies the opacity in the range 0..255 when the color is
synthesized with the background color specified by `bleopt colorglass_color`.
```bash
# defualt
bleopt colorglass_alpha=255
```
### Blopet `colorglass_color` (Integer)
This option specifies the background color used by the color synthesis by
`bleopt colorglass_alpha`.
```bash
# defualt
bleopt colorglass_color=0x8888FF
```
### Bleopt `colorglass_base16_palette` (Empty/Enumerate)
This option specifies a color scheme of `base16` colors (index colors 0..15).
When this option is set to a (non-empty) palette name, index colors 0..15 in
the output of `ble.sh` will be replaced by the corresponding 24-bit colors in
the palette. See [List of base16 palettes](https://akinomyoga.github.io/ble.sh/colorglass.base16.html)
or [`colorglass.base16.dat`](https://github.com/akinomyoga/blesh-contrib/blob/master/colorglass.base16.dat)
for the list of available palettes.
```bash
# defualt
bleopt colorglass_base16_palette=
```
### Bleopt `colorglass_blindness` (Enumerate)
When this option is set to a non-empty value, the colors under color blindness
are simulated. Five values `none`, `protanopia`, `deuteranopia`, `tritanopia`,
and `achromatopsia` are supported.
```bash
# default
bleopt colorglass_blindness=none
```

View File

@@ -0,0 +1,195 @@
# :pencil: Integration with `fzf`
## Configure fzf's `completion` and `key-bindings`
In the following cases, a special care is needed to make it work with `ble.sh`.
- When you want to load fzf's `completion.bash` (sometimes installed at
`/etc/bash_completion.d/fzf` or `/usr/share/bash-completion/completions/fzf`)
or `key-bindings.bash`.
- When you want to load fzf's settings by `eval "$(fzf --bash)"` (supported by
`fzf >= 0.48.0`).
We require those settings to be loaded through our modules :pencil:
[`contrib/integration/fzf-completion`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-completion.bash)
and :pencil:
[`contrib/integration/fzf-key-bindings`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-key-bindings.bash).
> [!IMPORTANT]
> If you want to integrate fzf's `completion.bash` with
> [`bash-completion`](https://github.com/scop/bash-completion),
> `bash-completion` needs to be loaded before fzf's `completion.bash` is
> loaded.
> [!IMPORTANT]
> In the Bash sessions where `ble.sh` is loaded, fzf's settings loaded
> elsewhere needs to be disabled. If you want to support the case without
> `ble.sh`, please enable the fzf's settings conditionally when `ble.sh` is not
> loaded.
There are several ways to configure them.
### Option 1: Set up in `~/.blerc`
The current recommended way is to directly write settings in your `.blerc` as follows:
```bash
# blerc
# If ble/contrib/integration/fzf cannot find the fzf directory, please set the
# following variable "_ble_contrib_fzf_base" manually. The value
# "/path/to/fzf-directory" should be replaced by a path to the fzf directory
# such as "$HOME/.fzf" or "/usr/share/fzf" that contain
# "shell/{completion,key-bindings}.bash" or "{completion,key-bindings}.bash".
#_ble_contrib_fzf_base=/path/to/fzf-directory
# Note: If you would like to combine fzf-completion with bash_completion, you
# need to load bash_completion earlier than fzf-completion.
#source -- /path/to/bash_completion.sh
# Set up fzf
ble-import -d integration/fzf-completion
ble-import -d integration/fzf-key-bindings
```
#### When you have additional settings for fzf
The option `-d` of `ble-import` in the above example means the asynchronous
loading of the modules. If you need to immediately load the module, please
drop the option `-d`. For example, if the user needs to call a function
defined in a module, the module can be loaded immediately, so that the user can
use the function.
```bash
ble-import integration/fzf-completion
_fzf_set_up_completion foo bar
```
However, in most cases, the user would probably want to reserve the execution
of the commands relying on the module by using the `-C callback` option. In
this way, the reserved command is evaluated when the module is successfully
loaded.
```bash
ble-import -d integration/fzf-completion \
-C '_fzf_set_up_completion foo bar'
```
### Option 2: Set up in `~/.fzf.bash`
If you have `~/.fzf.bash` for the fzf settings, you can rewrite your
`.fzf.bash` in the following way. In this case, `.fzf.bash` needs to be
sourced after `ble.sh`. Please replace `/path/to/fzf-directory`,
`/path/to/fzf/...` and `/path/to/bash_completion.sh` if necessary.
```bash
# fzf.bash
# If ble/contrib/integration/fzf cannot find the fzf directory, please set the
# following variable "_ble_contrib_fzf_base" manually. The value
# "/path/to/fzf-directory" should be replaced by a path to the fzf directory
# such as "$HOME/.fzf" or "/usr/share/fzf" that contain
# "shell/{completion,key-bindings}.bash" or "{completion,key-bindings}.bash".
#_ble_contrib_fzf_base=/path/to/fzf-directory
# Setup fzf
# ---------
if [[ ! "$PATH" == *"/path/to/fzf/bin"* ]]; then
export PATH="${PATH:+${PATH}:}/path/to/fzf/bin"
fi
# Auto-completion
# ---------------
if [[ $- == *i* ]]; then
# Note: If you would like to combine fzf-completion with bash_completion, you
# need to load bash_completion earlier than fzf-completion.
#source -- /path/to/bash_completion.sh
if [[ ${BLE_VERSION-} ]]; then
ble-import -d integration/fzf-completion
else
source -- /path/to/fzf/shell/completion.bash 2> /dev/null
fi
fi
# Key bindings
# ------------
if [[ ${BLE_VERSION-} ]]; then
ble-import -d integration/fzf-key-bindings
else
source -- /path/to/fzf/shell/key-bindings.bash
fi
```
## :pencil: `integration/fzf-completion`
The module `integration/fzf-completion` mentioned above also provides a widget.
### Widget `fzf-complete`
This widget performs fzf's completion normally triggered by the key `**`.
```
widget: fzf-complete [type]
@param[in,opt] type
This specifies the type of the completion. The shell function
"_fzf_${type}_completion" is used to perform the '**' completion. The
values available by default are "path", "file", "dir", "proc", "host",
"var", and "alias".
```
## :pencil: `integration/fzf-git`
If you want to use
[`junegunn/fzf-git.sh`](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)
(fzf settings for `git` formerly provided as a
[Gist](https://gist.github.com/junegunn/8b572b8d4b5eddd8b85e5f4d40f17236)) with
`ble.sh`, you instead need to use :pencil:
[`contrib/integration/fzf-git`](https://github.com/akinomyoga/blesh-contrib/blob/master/integration/fzf-git.bash).
```bash
# bashrc / fzf.bash
if [[ ${BLE_VERSION-} ]]; then
# If needed. See above for details:
#_ble_contrib_fzf_base=/path/to/fzf-directory
_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio
ble-import -d integration/fzf-git
fi
```
Or you can configure it in `~/.blerc`:
```bash
# blerc
# If needed. See above for details:
#_ble_contrib_fzf_base=/path/to/fzf-directory
_ble_contrib_fzf_git_config=key-binding:sabbrev:arpeggio
ble-import -d integration/fzf-git
```
The shell variable `_ble_contrib_fzf_git_config` is a colon-separated list of the enabled types of bindings.
The value `key-binding` enables the key bindings of the form <kbd>C-g C-f</kbd>, <kbd>C-g C-b</kbd>, <kbd>C-g C-t</kbd>, <kbd>C-g C-h</kbd>, <kbd>C-g C-r</kbd>, and <kbd>C-g C-s</kbd>.
The value `sabbrev` enables the sabbrev expansion for the words `gf`, `gb`, `gt`, `gh`, `gr`, and `gs`.
The value `arpeggio` enables the simultaneous key combinations of <kbd>g f</kbd>, <kbd>g b</kbd>, <kbd>g t</kbd>, <kbd>g h</kbd>, <kbd>g r</kbd>, and <kbd>g s</kbd>.
The value `old-functions` enables old function names: `is_in_git_repo`, `fzf-down`, `gh`, `gb`, `gt`, `gh`, `gr`, and `gs`.
## :pencil: `integration/fzf-menu`
This module configures so that when the menu completion is started, fzf is
started instead of `menu-complete` built in `ble.sh`.
```bash
# blerc
ble-import -d integration/fzf-menu
```

View File

@@ -0,0 +1,83 @@
# &#x2699; Prompt sequences
## :pencil: `contrib/prompt-vim-mode`
Source: [`prompt-vim-mode.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-vim-mode.bash)
### Prompt sequence `\q{contrib/vim-mode}`
This prompt sequence expands to the vim mode name.
```bash
# blerc (example)
ble-import contrib/prompt-vim-mode
PS1='[\u@\h \W]\q{contrib/vim-mode}\$ ' # show mode name in PS1
bleopt keymap_vi_mode_show:= # hide mode line
```
## :pencil: `contrib/prompt-git`
Source: [`prompt-git.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-git.bash)
```bash
# blerc (example)
ble-import contrib/prompt-git
bleopt prompt_rps1='\q{contrib/git-info}'
```
### Prompt sequence `\q{contrib/git-info}`
This expands to a string that explains the current git status.
### Prompt sequence `\q{contrib/git-name}`
This expands to the directory name of the repository.
### Prompt sequence `\q{contrib/git-hash N}`
This expands to the commit hash.
The hash is truncated to the length `N`.
The default value for `N` is `7`.
### Prompt sequence `\q{contrib/git-branch}`
This expands to the branch name (or tag name or hash) of `HEAD`.
### Prompt sequence `\q{contrib/git-path}`
This expands to the current path relative to the root directory of the repository.
## :pencil: `contrib/prompt-elapsed`
Source: [`prompt-elapsed.bash`](https://github.com/akinomyoga/blesh-contrib/blob/master/prompt-elapsed.bash)
Measures the time of the previous command execution.
```bash
# blerc (example)
ble-import contrib/prompt-elapsed
bleopt prompt_rps1='\g{fg=69,italic}\q{contrib/elapsed}'
```
### Prompt sequence `\q{contrib/elapsed}`
This expands to the high-resolution elapsed time for the command execution.
### Prompt sequence `\q{contrib/elapsed-real}`
This expands to the `real` time of `time`.
### Prompt sequence `\q{contrib/elapsed-user}`
This expands to the `user` time of `time`.
### Prompt sequence `\q{contrib/elapsed-sys}`
This expands to the `sys` time of `time`.
### Prompt sequence `\q{contrib/elapsed-cpu}`
This expands to the average cpu usage.