ble.sh: [Bash 3.2 in macOS] keymap 'emacs' is not defined.

ble version:

3.0.0

Bash version:

I’m on MacOS and have installed bash via Homebrew

$ bash -c 'echo $BASH_VERSION' 
5.0.11(1)-release
$ echo $BASH_VERSION
3.2.57(1)-release

When I add follow the instructions for configuring bleh.sh with .bashrc (except that I’m using .bash_profile) I get an error.

usage: sleep seconds
$ ... ~ $ ble.sh: Failed to load the default keymap. keymap 'emacs' is not defined.

Use "logout" to leave the shell.

Oddly enough if I manually source /bleh.sh then bleh.sh does load the first time. If I start a new session and try to source again I’ll get the same error.

Just wanted to add though that this is a cool project!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 33 (15 by maintainers)

Most upvoted comments

Oh, OK. Thanks.

yep all seems good again so thanks for swift response

The feature works great in ble-0.4 series, but in case you didn’t know an error message does pop up when loading ble.sh.

ble/builtin/trap: invalid signal specification "-".

Ah, you clearly explained this before and I overlooked that point. Thanks!

Thanks for all the help!

Thank you very much for your feedback!

However it’s interesting that M-right observe spaces as delimiters in autocomplete suggestions.

This is actually my preference and was an intended one. I added an option to configure the delimiters c294e31 (in master branch not in ble-0.3 because this is a new feature). You can configure the characters to be used for word breaks of <kbd>M-right</kbd> by the following settings.

# Example 1: spaces (default)
bleopt complete_auto_wordbreaks=$' \t\n'

# Example 2: spaces + /
bleopt complete_auto_wordbreaks=$' \t\n/'
  1. S-RET

Thanks for looking into those details and providing the escape codes! I have now have S-RET others working correctly.

  1. M-right

Wow, thanks for the thorough explanation. Let me be more specific and you can tell me if the behavior I have is the expected one:

Given terminal input cd d and an autocomplete suggestion of cd do/a/thing I thought that entering M-right would select and move the cursor the first end of the first path segment (i.e changing the current terminal input to cd do/). This is the behavior I get if I use Tab. However instead entering M-right completes to the whole segment cd do/a/thing. I think this is not the expected behavior since normally a / is treated as a delimiter - at least currently in iTerm2 using Natural Text Editing respects the / delimiters with regular (non-autcomplete suggested) Terminal line editor content.

However it’s interesting that M-right observe spaces as delimiters in autocomplete suggestions. For example, If I enter e and get a suggestion of echo hello world I can then use M-rightto move one word at a time - i.e I would need to enter M-right 3 times to reach the end of the autocomplete suggestions.

I followed your instructions and entered ble-edit/detach and got an error that looked something like -bash:ble-decode is not .... Unfortunately I’m not sure if that’s correct because when I entered the same command again it closed the session, losing the error text. Every time afterwards that I’ve entered ble-edit/detach after sourcing I get a different error message -bash: syntax error near unexpected token;.

From that state I ran the commands that you requested. Here’s the output:

$ type ble-decode/DEFAULT_KEYMAP
ble-decode/DEFAULT_KEYMAP is a function
ble-decode/DEFAULT_KEYMAP ()
{
    local ret;
    bleopt/get:default_keymap;
    local defmap=$ret;
    if ble-edit/bind/load-keymap-definition "$defmap"; then
        if [[ $defmap == vi ]]; then
            builtin eval -- "$2=vi_imap";
        else
            builtin eval -- "$2=\$defmap";
        fi && ble-decode/keymap/is-keymap "${!2}" && return 0;
    fi;
    echo "ble.sh: The definition of the default keymap \"$bleopt_default_keymap\" is not found. ble.sh uses \"safe\" keymap instead.";
    ble-edit/bind/load-keymap-definition safe && builtin eval -- "$2=safe" && bleopt_default_keymap=safe
}
$ declare -p _ble_decode_emacs_kmap_
declare -- _ble_decode_emacs_kmap_="([0]=\"1:ble/widget/set-mark\" [8]=\"1:ble/widget/delete-region-or backward-char\" [9]=\"1:ble/widget/complete\" [13]=\"1:ble/widget/accept-single-line-or-newline\" [32]=\"1:ble/widget/magic-space\" [45]=\"1:ble/widget/emacs/append-arg\" [48]=\"1:ble/widget/emacs/append-arg\" [49]=\"1:ble/widget/emacs/append-arg\" [50]=\"1:ble/widget/emacs/append-arg\" [51]=\"1:ble/widget/emacs/append-arg\" [52]=\"1:ble/widget/emacs/append-arg\" [53]=\"1:ble/widget/emacs/append-arg\" [54]=\"1:ble/widget/emacs/append-arg\" [55]=\"1:ble/widget/emacs/append-arg\" [56]=\"1:ble/widget/emacs/append-arg\" [57]=\"1:ble/widget/emacs/append-arg\" [127]=\"1:ble/widget/delete-region-or backward-char\" [1114112]=\"1:ble/widget/batch-insert\" [1114113]=\"1:ble/widget/self-insert\" [1114115]=\"1:ble/widget/emacs/__before_widget__\" [1114116]=\"1:ble/widget/emacs/__after_widget__\" [1114117]=\"1:ble/widget/safe/__attach__\" [1114125]=\"1:ble/widget/overwrite-mode\" [1114126]=\"1:ble/widget/@nomarked beginning-of-line\" [1114128]=\"1:ble/widget/delete-region-or forward-char\" [1114129]=\"1:ble/widget/@nomarked end-of-line\" [1114131]=\"1:ble/widget/command-help\" [1114151]=\"1:ble/widget/emacs/bracketed-paste\" [1114153]=\"1:ble/widget/@nomarked backward-line history\" [1114154]=\"1:ble/widget/@nomarked forward-line history\" [1114155]=\"1:ble/widget/@nomarked forward-char\" [1114156]=\"1:ble/widget/@nomarked backward-char\" [1114158]=\"1:ble/widget/auto-complete-enter\" [34668558]=\"1:ble/widget/@marked beginning-of-line\" [34668561]=\"1:ble/widget/@marked end-of-line\" [34668585]=\"1:ble/widget/@marked backward-line\" [34668586]=\"1:ble/widget/@marked forward-line\" [34668587]=\"1:ble/widget/@marked forward-char\" [34668588]=\"1:ble/widget/@marked backward-char\" [67108872]=\"1:ble/widget/emacs/undo\" [67108873]=\"1:ble/widget/menu-complete\" [67108877]=\"1:ble/widget/accept-line\" [67108896]=\"1:ble/widget/set-mark\" [67108909]=\"1:ble/widget/emacs/append-arg\" [67108911]=\"1:ble/widget/emacs/undo\" [67108912]=\"1:ble/widget/emacs/append-arg\" [67108913]=\"1:ble/widget/emacs/append-arg\" [67108914]=\"1:ble/widget/emacs/append-arg\" [67108915]=\"1:ble/widget/emacs/append-arg\" [67108916]=\"1:ble/widget/emacs/append-arg\" [67108917]=\"1:ble/widget/emacs/append-arg\" [67108918]=\"1:ble/widget/emacs/append-arg\" [67108919]=\"1:ble/widget/emacs/append-arg\" [67108920]=\"1:ble/widget/emacs/append-arg\" [67108921]=\"1:ble/widget/emacs/append-arg\" [67108927]=\"1:ble/widget/delete-region-or backward-char\" [67108928]=\"1:ble/widget/set-mark\" [67108956]=\"1:ble/widget/bell\" [67108957]=\"1:ble/widget/bell\" [67108958]=\"1:ble/widget/bell\" [67108959]=\"1:ble/widget/emacs/undo\" [67108961]=\"1:ble/widget/@nomarked beginning-of-line\" [67108962]=\"1:ble/widget/@nomarked backward-char\" [67108963]=\"1:ble/widget/discard-line\" [67108964]=\"1:ble/widget/delete-region-or forward-char-or-exit\" [67108965]=\"1:ble/widget/@nomarked end-of-line\" [67108966]=\"1:ble/widget/@nomarked forward-char\" [67108967]=\"1:ble/widget/bell\" [67108968]=\"1:ble/widget/delete-region-or backward-char\" [67108969]=\"1:ble/widget/complete\" [67108970]=\"1:ble/widget/accept-line\" [67108971]=\"1:ble/widget/kill-forward-line\" [67108972]=\"1:ble/widget/clear-screen\" [67108973]=\"1:ble/widget/accept-single-line-or-newline\" [67108974]=\"1:ble/widget/@nomarked forward-line history\" [67108975]=\"1:ble/widget/accept-and-next\" [67108976]=\"1:ble/widget/@nomarked backward-line history\" [67108977]=\"1:ble/widget/emacs/quoted-insert\" [67108978]=\"1:ble/widget/history-isearch-backward\" [67108979]=\"1:ble/widget/history-isearch-forward\" [67108980]=\"1:ble/widget/transpose-chars\" [67108981]=\"1:ble/widget/kill-backward-line\" [67108982]=\"1:ble/widget/emacs/quoted-insert\" [67108983]=\"1:ble/widget/kill-region-or uword\" [67108984]=\"_\" [67108985]=\"1:ble/widget/yank\" [67108986]=\"1:ble/widget/.SHELL_COMMAND 'fg'\" [67108991]=\"1:ble/widget/emacs/undo\" [68222990]=\"1:ble/widget/@nomarked beginning-of-text\" [68222991]=\"1:ble/widget/history-beginning\" [68222992]=\"1:ble/widget/delete-forward-cword\" [68222993]=\"1:ble/widget/@nomarked end-of-text\" [68222994]=\"1:ble/widget/history-end\" [68223019]=\"1:ble/widget/@nomarked forward-cword\" [68223020]=\"1:ble/widget/@nomarked backward-cword\" [100663393]=\"1:ble/widget/@marked beginning-of-line\" [100663394]=\"1:ble/widget/@marked backward-char\" [100663397]=\"1:ble/widget/@marked end-of-line\" [100663398]=\"1:ble/widget/@marked forward-char\" [100663406]=\"1:ble/widget/@marked forward-line\" [100663408]=\"1:ble/widget/@marked backward-line\" [101777422]=\"1:ble/widget/@marked beginning-of-text\" [101777425]=\"1:ble/widget/@marked end-of-text\" [101777451]=\"1:ble/widget/@marked forward-cword\" [101777452]=\"1:ble/widget/@marked backward-cword\" [134217736]=\"1:ble/widget/copy-backward-sword\" [134217741]=\"1:ble/widget/newline\" [134217760]=\"1:ble/widget/set-mark\" [134217761]=\"1:ble/widget/complete context=command\" [134217764]=\"1:ble/widget/complete context=variable\" [134217767]=\"1:ble/widget/sabbrev-expand\" [134217770]=\"1:ble/widget/complete insert_all\" [134217773]=\"1:ble/widget/emacs/append-arg\" [134217775]=\"1:ble/widget/complete context=filename\" [134217776]=\"1:ble/widget/emacs/append-arg\" [134217777]=\"1:ble/widget/emacs/append-arg\" [134217778]=\"1:ble/widget/emacs/append-arg\" [134217779]=\"1:ble/widget/emacs/append-arg\" [134217780]=\"1:ble/widget/emacs/append-arg\" [134217781]=\"1:ble/widget/emacs/append-arg\" [134217782]=\"1:ble/widget/emacs/append-arg\" [134217783]=\"1:ble/widget/emacs/append-arg\" [134217784]=\"1:ble/widget/emacs/append-arg\" [134217785]=\"1:ble/widget/emacs/append-arg\" [134217788]=\"1:ble/widget/history-beginning\" [134217790]=\"1:ble/widget/history-end\" [134217791]=\"1:ble/widget/complete show_menu\" [134217792]=\"1:ble/widget/complete context=hostname\" [134217794]=\"1:ble/widget/@marked backward-cword\" [134217798]=\"1:ble/widget/@marked forward-cword\" [134217805]=\"1:ble/widget/@marked non-space-beginning-of-line\" [134217820]=\"1:ble/widget/delete-horizontal-space\" [134217822]=\"1:ble/widget/history-expand-line\" [134217826]=\"1:ble/widget/@nomarked backward-cword\" [134217828]=\"1:ble/widget/kill-forward-cword\" [134217830]=\"1:ble/widget/@nomarked forward-cword\" [134217831]=\"1:ble/widget/complete context=glob\" [134217832]=\"1:ble/widget/kill-backward-cword\" [134217836]=\"1:ble/widget/redraw-line\" [134217837]=\"1:ble/widget/@nomarked non-space-beginning-of-line\" [134217842]=\"1:ble/widget/emacs/revert\" [134217847]=\"1:ble/widget/copy-region-or uword\" [134217850]=\"1:ble/widget/.SHELL_COMMAND 'fg'\" [134217854]=\"1:ble/widget/complete context=username\" [134217855]=\"1:ble/widget/copy-backward-sword\" [135331856]=\"1:ble/widget/copy-forward-sword\" [135331883]=\"1:ble/widget/@nomarked forward-sword\" [135331884]=\"1:ble/widget/@nomarked backward-sword\" [167772258]=\"1:ble/widget/@marked backward-cword\" [167772262]=\"1:ble/widget/@marked forward-cword\" [167772269]=\"1:ble/widget/@marked non-space-beginning-of-line\" [168886315]=\"1:ble/widget/@marked forward-sword\" [168886316]=\"1:ble/widget/@marked backward-sword\" [201326655]=\"1:ble/widget/copy-backward-sword\" [201326695]=\"1:ble/widget/bell\" [201326696]=\"1:ble/widget/copy-backward-sword\" [201326701]=\"1:ble/widget/newline\")"
$ ble/is-array _ble_decode_emacs_kmap_; echo $?
1
$ echo "$_ble_base_cache"
/Users/dbarnard/Code/dev-tools/ble-0.3.0/./cache.d/501
$ ls -ld "${XDG_CACHE_HOME:-$HOME/.cache}"
ls: /Users/dbarnard/.cache: No such file or directory

Before I noted that after a fresh unzipping of the directory I’m able to source bleh.sh exactly once before subsequent sourcings return the emacs keymap error. Once thing I forgot to note is the first command post successful source always returns a ` prompt_command_array’ error.

$ echo 'hello'
-bash: read: ` prompt_command_array': not a valid identifier
hello
$ echo 'again'
again