-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bash 3.2 in macOS] keymap 'emacs' is not defined. #33
Comments
Thank you very much for the report!
This error typically occurs when only Question 1: Can you provide me the file tree of the directory where Homebrew installed the script file
I don't have macOS so I don't have experience on Homebrew, but I suspect that the Homebrew formula that you used is broken. Question 2: Where did you get Homebrew formula for
Question 3: Where is that |
Thanks for the quick reply!
I do not seem to be missing the
|
Oh, I see. You have clearly written that you installed bash via Homebrew. I'm sorry it's just my mistake.
OK. It appears that the directory contents are correct. Because I don't have macOS, I am trying to reproduce it in Linux with bash-3.2.57 and bash-5.0.7, but have not yet reproduced the problem. I would like to ask for your help. After the message "
The input command $ type ble-decode/DEFAULT_KEYMAP
$ declare -p _ble_decode_emacs_kmap_
$ ble/is-array _ble_decode_emacs_kmap_; echo $? Edit: I'm also interested in the result of the following command. Can you check? $ echo "$_ble_base_cache"
$ ls -ld "${XDG_CACHE_HOME:-$HOME/.cache}" |
I followed your instructions and entered From that state I ran the commands that you requested. Here's the output:
Before I noted that after a fresh unzipping of the directory I'm able to source
|
Thank you very much for details! It seems there are several separate problems. I'm still trying to reproduce the problem, yet I haven't managed to reproduce the main problem. About results
That's a puzzle... I don't have any idea what happens there. Maybe I need to take more time to investigate it.
Thank you for the result! It seems that the definition of the function
Yes! Here's a problem. Somehow the expected array attribute prompt_command_array error
Thank you for the report! I guess you are using Next checkBefore going to next step, I would like to ask you to update $ ble-update The update includes
Then, after the " $ ... $ ble.sh: Failed to load the default keymap. keymap 'emacs' is not defined.
$ grep _emacs_ "$_ble_base_cache/keymap.emacs"
$ arr=(1 2 3)
$ declare -p arr | cat -A
$ ble/util/declare-print-definitions arr | cat -A
$ cat -A <<< $IFS |
Huh, that's interesting. My impression was that it would use my updated bash version. I'm unsure if I'm using
I had to install gawk via Homebrew first, but once I did so I began to run into another error when running
|
I'm sorry for many troubles one after another. As I haven't tested ble.sh with macOS, there seem to be many troubles related to the differences between softwares, such as GNU awk vs new-awk, GNU sed vs BSD sed, etc. I fixed the problem of the update. Also I newly installed FreeBSD (which I think is closer to macOS environment than Linux) in my virtual machine, tested ble.sh, and fixed another problem. I'm sorry, but I think $ cd /Users/dbarnard/Code/dev-tools/ble-0.3.0/ble.sh/src/ble.sh
$ git pull
$ make clean
$ make install INSDIR=../.. Then, if there is no problem, could you try the following commands (which were modified from the previous comment) in the new session? $ ... $ ble.sh: Failed to load the default keymap. keymap 'emacs' is not defined.
$ grep _emacs_ "$_ble_base_cache/keymap.emacs"
$ arr=(1 2 3)
$ declare -p arr | cat -v
$ ble/util/declare-print-definitions arr | cat -v
$ cat -v <<< $IFS |
Maybe you haven't yet noticed, but actually you are still using Bash 3.2.57 for login shells as your first post implies:
So actually you can now switch to newly installed Bash to see if the problem persists, but to avoid the complication of the problem I would like to solve the problem in older Bash before going to the newer version.
I found that in fact iTerm2 shell-integration script contains embedded |
No worries at all - thanks for being so responsive on the issue. Well I couldn't follow your instructions exactly, but the good news is that's because I no longer receive the $ grep _emacs_ "$_ble_base_cache/keymap.emacs"
_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__" [1114126]="1:ble/widget/overwrite-mode" [1114127]="1:ble/widget/@nomarked beginning-of-line" [1114129]="1:ble/widget/delete-region-or forward-char" [1114130]="1:ble/widget/@nomarked end-of-line" [1114132]="1:ble/widget/command-help" [1114152]="1:ble/widget/emacs/bracketed-paste" [1114154]="1:ble/widget/@nomarked backward-line history" [1114155]="1:ble/widget/@nomarked forward-line history" [1114156]="1:ble/widget/@nomarked forward-char" [1114157]="1:ble/widget/@nomarked backward-char" [1114159]="1:ble/widget/auto-complete-enter" [34668559]="1:ble/widget/@marked beginning-of-line" [34668562]="1:ble/widget/@marked end-of-line" [34668586]="1:ble/widget/@marked backward-line" [34668587]="1:ble/widget/@marked forward-line" [34668588]="1:ble/widget/@marked forward-char" [34668589]="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" [68222991]="1:ble/widget/@nomarked beginning-of-text" [68222992]="1:ble/widget/history-beginning" [68222993]="1:ble/widget/delete-forward-cword" [68222994]="1:ble/widget/@nomarked end-of-text" [68222995]="1:ble/widget/history-end" [68223020]="1:ble/widget/@nomarked forward-cword" [68223021]="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" [101777423]="1:ble/widget/@marked beginning-of-text" [101777426]="1:ble/widget/@marked end-of-text" [101777452]="1:ble/widget/@marked forward-cword" [101777453]="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" [135331857]="1:ble/widget/copy-forward-sword" [135331884]="1:ble/widget/@nomarked forward-sword" [135331885]="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" [168886316]="1:ble/widget/@marked forward-sword" [168886317]="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_decode_emacs_kmap__67108984=([33]="1:ble/widget/complete show_menu:context=command" [36]="1:ble/widget/complete show_menu:context=variable" [39]="1:ble/widget/sabbrev-expand" [42]="1:ble/widget/complete insert_all:context=glob" [47]="1:ble/widget/complete show_menu:context=filename" [60]="1:ble/widget/history-nsearch-backward" [62]="1:ble/widget/history-nsearch-forward" [64]="1:ble/widget/complete show_menu:context=hostname" [85]="1:ble/widget/emacs/redo" [103]="1:ble/widget/complete show_menu:context=glob" [110]="1:ble/widget/history-substring-search-forward" [112]="1:ble/widget/history-substring-search-backward" [117]="1:ble/widget/emacs/undo" [126]="1:ble/widget/complete show_menu:context=username" [1114154]="1:ble/widget/history-search-backward" [1114155]="1:ble/widget/history-search-forward" [67108967]="1:ble/widget/bell" [67108974]="1:ble/widget/history-search-forward" [67108976]="1:ble/widget/history-search-backward" [67108978]="1:ble/widget/dabbrev-expand" [67108981]="1:ble/widget/emacs/undo" [67108982]="1:ble/widget/display-shell-version" [67108984]="1:ble/widget/exchange-point-and-mark" [100663413]="1:ble/widget/emacs/redo") $ arr=(1 2 3)
$ declare -p arr | cat -v
declare -a arr='([0]="1" [1]="2" [2]="3")'
$ ble/util/declare-print-definitions arr | cat -v
arr=([0]="1" [1]="2" [2]="3")
$ cat -v <<< $IFS
# blank new line |
Hm, yes I thought the default shell in OSX was the login shell so I'm actually not sure why there's two versions for different shells, but I don't know much about this type of stuff. https://unix.stackexchange.com/questions/119627/why-are-interactive-shells-on-osx-login-shells-by-default
The main feature that drew me to this project was the mention of Is the reason I'm not seeing these types of autosuggestions for all terminal commands because bleh.sh is running on an older version of bash for the login shell? If so I'm guessing I should change my login shell bash version by adding bleh.sh to |
For "Failed to load the default keymap" errorThank you for the results!
OK. So now, would you have some syntax highlighting? (If not, that means there are still problems.)
Now it looks like everything is working correctly. I'm not sure what was the actual problem, but I am thinking of leaving it for another occasion.
Yes. ble.sh's autosuggestions are only available with Bash 4.0 and later because it internally uses a Bash 4.0's feature. Currently your login shell is Bash 3.2, so autosuggestions are inactive. Change login shellLet's go to the newer version of Bash! I don't know your exact situation, but I guess you have installed the new Bash by Homebrew but haven't added the path in
FYI: Right prompt in ble.shIf you want to show the right prompt (like # In ~/.bashrc (after source ble.sh) or in ~/.blerc
bleopt rps1='\D{%c}' Here is an example at my side (in Arch Linux in a virtual machine). I'm running Bash 5.0:
|
FYI: .bash_profile vs .bashrcRelated to the login shell, you have mentioned that you are using
If you do not have specific reasons or special preferences, I actually recommend you to put the setting of Login shell and non-login shellActually $ echo hello # <-- We are in a login shell (bash_login is loaded for this session).
hello
$
$ bash # <-- You can launch a child shell inside the login shell.
$ echo hello # <-- Now we are NOT in a login shell but a child shell (bashrc is loaded for this session)
hello
$ exit # <-- Exit the child shell.
$ # <-- We come back to the login shell Normal configurationUsually # bash_profile
# (Setting environment variables such as LANG, PATH, etc.)
# call bashrc inside
[[ -f ~/.bashrc ]] && source ~/.bashrc # bashrc
# (Common settings)
[[ $- == *i* ]] || return 0 # If this is not interactive session, then exit here
# (Commonn settings for interactive session such as aliases, functions, key bindings, etc) ble.sh in bashrcActually ble.sh belongs to the latter type of configuration, i.e., it only affects the current Bash instance. So we want to call ble.sh in For this reason, I recommend to configure ble.sh in |
Should have mentioned that I did run the update command successfully first before the errors loading ble.sh stopped.
Ah, sorry I wasn't clear! I showed the screenshot from fish as an example of autocomplete since I wasn't sure if the ble.sh autcomplete feature was similar to the fish version or not. Thanks for the detailed information on login shells! I followed the instructions and now have fish-like autocomplete working which I'm very happy about. There are two small issues I'm running into though.
|
Thank you for the report! I'm glad to hear that! 1. S-RET
Right. It represents "Shift + Return".
Yes. S-RET is intended to behave like right or C-f. To be precise, when the cursor is not at the end of the line, right and C-f retain the original meaning, "move one character right", so they cannot be used for auto-complete. S-RET is an alternative binding which can be used for auto-complete any time.
This should be the limitation of iTerm2. ble.sh uses a terminal feature for extended key sequences called "
I think that's the right approach for the current iTerm2. I don't have macOS, so I cannot try iTerm2, but it seems there is a setting "Action: Send Escape Sequence" looking at an image in this answer. You can enter If you also want to set up other key combinations for iTerm2, the following table shows examples for the key combinations used in ble.sh.
2. M-rightI think the right settings depend on what behavior you actually expect for different key combinations with Meta keys. There are historically two different roles for Meta key in terminals:
The following is a part of possible settings based on my guess on iTerm2 (as I don't have iTerm2/macOS). I'm not sure if they work, but I wish so.
|
Thanks for looking into those details and providing the escape codes! I have now have
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 However it's interesting that |
Thank you very much for your feedback!
This is actually my preference and was an intended one. I added an option to configure the delimiters c294e31 (in # Example 1: spaces (default)
bleopt complete_auto_wordbreaks=$' \t\n'
# Example 2: spaces + /
bleopt complete_auto_wordbreaks=$' \t\n/' |
Thanks for all the help! |
OK. Thank you for your reports and replies on the problems! |
Just letting you know that including
|
Thank you for the information! Which version of ble.sh do you use? As I have already written, this new feature is implemented in the master branch and not reflected in ble-0.3. In my environment, it works for the master branch. If you now use ble-0.3 and want to use the feature, you need to switch to the master branch (the devel branch for ble-0.4). To use the master branch version, you can follow the intruction in README (with git clone & make install). Note: |
Ah, you clearly explained this before and I overlooked that point. Thanks! |
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.
|
Thank you for the report! This was a bug. Fixed (db8b0c2). Could you check after |
Yep, that fixed it! |
Thank you! |
Started seeing same thing updated macos (14.4.1 (23E224)) today: → ble.sh: The keymap 'emacs' is empty. → ble --version blesh is installed via bash-it plugins |
MACHTYPE: aarch64-apple-darwin23.2.0 98.3% [section] bash: 60/61 (1 fail, 0 crash, 4 skip) |
I added [[ $- == i ]] && source $HOME/.local/share/blesh/ble.sh --noattach to top of .bashrc and error disappeared |
@jw-miaem If possible could you provide the result of the following command in a ble.sh session? $ ble/widget/display-shell-version Could you try clearing ble.sh's cache and restart Bash to see if anything changes? $ bash /path/to/ble.sh --clear-cache # <-- please replace /path/to/ble.sh with the actual path to the script file ble.sh Also, does your system have $ type gawk |
|
and run and basically it seems to fix it - there was some text output but its obscured something like...put cache for TERM=xterm-256color... done |
yep all seems good again so thanks for swift response |
Oh, OK. Thanks. |
ble version:
3.0.0
Bash version:
I'm on MacOS and have installed bash via Homebrew
When I add follow the instructions for configuring bleh.sh with .bashrc (except that I'm using .bash_profile) I get an error.
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!
The text was updated successfully, but these errors were encountered: