-
-
Notifications
You must be signed in to change notification settings - Fork 86
[ 日本語 | English ]
⌨ How to bind "simultaneous key combinations" (as in key-chord.el
or vim-arpeggio
)?
# blerc
# Example 1: Bind j&k with timeout of 40 msec
ble-bind -m vi_imap -f 'j k' 'vi_imap/normal-mode'
ble-bind -m vi_imap -f 'k j' 'vi_imap/normal-mode'
ble-bind -m vi_imap -T j 40
ble-bind -m vi_imap -T k 40
# Example 2: Use library "vim-arpeggio.sh"
source "$_ble_base/lib/vim-arpeggio.sh"
bleopt vim_arpeggio_timeoutlen=40
ble/lib/vim-arpeggio.sh/bind -m vi_imap -f jk vi_imap/normal-mode
Links: Q
⌨ How to edit a command line in vim (like v
in default Bash vi-command
map)?
# blerc
# Example 1: Bind "C-x C-v" for Emacs mode
VISUAL='vim -X'
ble-bind -m emacs -f 'C-x C-v' 'edit-and-execute-command'
# Example 2: Bind "C-x C-v" for Vim mode
VISUAL='vim -X'
ble-bind -m vi_imap -f 'C-x C-v' 'edit-and-execute-command'
ble-bind -m vi_nmap -f 'C-x C-v' 'vi-command/edit-and-execute-command'
Links: Q
⌨ M-right does not work in my terminal.
This is related to your setting of the Meta key in the terminal. There are historically two different roles for Meta key in terminals:
- Meta character: One is to send a meta character (such as alphabets with accents, etc. depending on your settings of language, e.g., Á with "Meta + A"),
- Meta modifier: The other is to send an escape sequence which represents a modifier "Meta" (M- in Emacs notation).
Depending on your terminal and the preferred behavior, the appropriate setting could vary. Below is the setting for iTerm2:
-
Option 1 (Always Meta modifier): If you want to always send M-something with all the keys combined with Meta key, you can select "
Esc+
" for "Left/Right ⌥ Key" as in the image in this answer. -
Option 2 (Meta modifier only for function keys): This is the setting for the case you want to normally send meta characters for "Meta + character (such as alphabets/numbers/delimiters)", and only send escape sequences for "Meta + function (such as left/up/home/pagedown/delete, etc.)". It seems "Natural Text Editing" in iTerm2 does that, so you can try to enable "Natural Text Editing". In this case you need to turn the "Left/Right ⌥ Key" settings back to "Normal". If this setting does not work, please use the following Option 3.
-
Option 3 (Meta modifier for specified keys): If you want to send meta characters by default and want to one-by-one specify special key combinations that should send meta modifier, you can set a escape sequence for each key combination. Specifically for M-right, you can follow this answer. The answer describes the setting to let
Meta + left/right
send M-b/M-f to terminal applications. In this case please set the "Left/Right ⌥ Key" setting to "Normal" or "Meta". -
Option 4 (Meta character for "Left ⌥" and Meta modifier for "Right ⌥"): You can also assign different roles to "Left/Right ⌥". For example, if you want to send meta characters for "Left ⌥" and meta modifiers for "Right ⌥", please set "Left ⌥ Key" to be "Meta" and "Right ⌥ Key" to "Esc+".
Links: A.
⌨ How to use special key combinations such as S-RET, etc?
If you use the terminal with the feature called modifyOtherKeys
, you can use these key combinations by default.
If your terminal doesn't support modifyOtherKeys
but can be configured to send specified escape sequences,
please set the following escape sequences for the key combinations that you would like to use.
Key combination | Escape sequence | Key combination | Escape sequence |
---|---|---|---|
S-RET | ESC [ 1 3 ; 2 u | C-0 | ESC [ 4 8 ; 5 u |
C-RET | ESC [ 1 3 ; 5 u | C-1 | ESC [ 4 9 ; 5 u |
C-S-RET | ESC [ 1 3 ; 6 u | C-2 | ESC [ 5 0 ; 5 u |
S-TAB | ESC [ 9 ; 2 u | C-3 | ESC [ 5 1 ; 5 u |
C-TAB | ESC [ 9 ; 5 u | C-4 | ESC [ 5 2 ; 5 u |
C-S-TAB | ESC [ 9 ; 6 u | C-5 | ESC [ 5 3 ; 5 u |
S-SP | ESC [ 3 2 ; 2 u | C-6 | ESC [ 5 4 ; 5 u |
C-S-SP | ESC [ 3 2 ; 6 u | C-7 | ESC [ 5 5 ; 5 u |
S-BS | ESC [ 8 ; 2 u | C-8 | ESC [ 5 6 ; 5 u |
C-S-BS | ESC [ 8 ; 6 u | C-9 | ESC [ 5 7 ; 5 u |
For the detailed description, please see this section in the manual.
The terminals supporting modifyOtherKeys
include xterm, mintty, iTerm2, foot, and zutty.
References:
- [Bash 3.2 in macOS] keymap 'emacs' is not defined. · Issue #33 · akinomyoga/ble.sh
- How hard would it be to turn this into one? | Hacker News
- Multiline mode exec remapping · Issue #370 · akinomyoga/ble.sh
- Manual §3 Key Binding · akinomyoga/ble.sh Wiki
- Manual A2 Terminal Settings · akinomyoga/ble.sh Wiki
⌨ How to run the command by a single RET in nsearch mode?
You can specify immediate-accept
option to the nsearch widget.
For example, when you configure up and down for nsearch,
ble-bind -f up 'history-search-backward immediate-accept'
ble-bind -f down 'history-search-forward immediate-accept'
Links: comment
⌨ How to run the command by RET / C-m in MULTILINE mode?
# For emacs editing mode
ble-bind -m emacs -f 'C-m' 'accept-line'
ble-bind -m emacs -f 'RET' 'accept-line'
# For vim editing mode
ble-bind -m vi_imap -f 'C-m' 'accept-line'
ble-bind -m vi_imap -f 'RET' 'accept-line'
ble-bind -m vi_nmap -f 'C-m' 'accept-line'
ble-bind -m vi_nmap -f 'RET' 'accept-line'
⌨ How to run multiple widgets with a single key sequence?
You can define your own widget by creating a function of the name ble/widget/YOUR_WIDGET_NAME
and calls multiple widgets there as illustrated in the following example.
It is highly recommended to prefix the widget name with YOUR_NAME/
, my/
, blerc/
, dotfiles/
, etc.
in order not to conflict with the names of the existing standard widgets.
# Example of calling multiple widgets with the key C-t
function ble/widget/my/example1 {
ble/widget/beginning-of-logical-line
ble/widget/insert-string 'echo $('
ble/widget/end-of-logical-line
ble/widget/insert-string ')'
}
ble-bind -f C-t my/example1
⌨ How to kill/copy words including the spaces preceding them?
# blerc
ble-bind -f C-w 'kill-region-or kill-uword'
ble-bind -f M-w 'copy-region-or copy-uword'
🎨 Can I import filename highlighting settings from $LS_COLORS
?
# blerc
bleopt filename_ls_colors="$LS_COLORS"
Links:
🎨 Can I use SGR parameters to configure faces?
# blerc
ble-face filename_directory=sgrspec:'1;34'
Links: R
⚙️ How to set a delay of auto-complete?
# blerc
# Example 1: 300 msec
bleopt complete_auto_delay=300
# Example 2: 10 msec
bleopt complete_auto_delay=10
🎨 How to change the color of suggestions of auto-complete?
# blerc
# Example 1
ble-face auto_complete='fg=242,bg=235'
# Example 2
ble-face auto_complete='fg=231,bg=69'
# Example 3
ble-face auto_complete='fg=240,underline,italic'
# Example 4
ble-face auto_complete='fg=gray'
# Example 5
ble-face auto_complete='fg=242,italic'
Links: Q.
⌨ How to accept the suggestion by auto-complete by TAB?
# blerc
ble-bind -m auto_complete -f C-i auto_complete/insert
ble-bind -m auto_complete -f TAB auto_complete/insert
⌨ Can I change the word delimiter for M-right to accept a word in auto-complete?
Ble option complete_auto_wordbreaks
can be used to configure the word delimiter in auto-complete mode.
# Example 1: spaces (default)
bleopt complete_auto_wordbreaks=$' \t\n'
# Example 2: spaces + /
bleopt complete_auto_wordbreaks=$' \t\n/'
Links: A
⚙️ How to turn off the exit status mark [ble: exit ???]
?
# blerc
bleopt exec_errexit_mark=
By default, ble.sh
outputs a line like [ble: exit ???]
after the command with non-zero exit status.
To turn off this behavior, you can set empty string to the ble option exec_errexit_mark
.
Links: Q
⚙️ How to hide the mode line in Vim editing mode
Links: this comment
⚙️ How to show current vim mode in the prompt
See this comment
⚙️ How to achieve p10k transient prompt in ble.sh
See this comment
⚙️ How to print the command time in the prompt
See this comment
⚙️ Can I share the command history with other bash sessions?
# blerc
bleopt history_share=1
Links: S
[ 日本語 | English ]