As far as I seen in the wiki, There is only an option to change normal mode name (keymap_vi_nmap_name). I think it would be nice to be able to change insert mode name and others. Also it is great to be able to set the position of mode indicator for example at the right end of the prompt.
Thank you for the suggestion!
I think it would be nice to be able to change insert mode name and others.
I think I can support it, but I need to consider how to provide a way to configure it because these mode names are not fixed strings but dynamically generated depending on the current detailed status (just like in vim). Possible values include
-- INSERT --
-- REPLACE --
-- VREPLACE --
-- VISUAL --
-- VISUAL BLOCK --
-- VISUAL LINE --
-- SELECT --
-- SELECT BLOCK --
-- SELECT LINE --
-- (insert) --
-- (insert) VISUAL --
-- (insert) VISUAL BLOCK --
-- (insert) VISUAL LINE --
-- (insert) SELECT --
-- (insert) SELECT BLOCK --
-- (insert) SELECT LINE --
-- (replace) --
-- (replace) VISUAL --
-- (replace) VISUAL BLOCK --
-- (replace) VISUAL LINE --
-- (replace) SELECT --
-- (replace) SELECT BLOCK --
-- (replace) SELECT LINE --
-- (vreplace) --
-- (vreplace) VISUAL --
-- (vreplace) VISUAL BLOCK --
-- (vreplace) VISUAL LINE --
-- (vreplace) SELECT --
-- (vreplace) SELECT BLOCK --
-- (vreplace) SELECT LINE --
I don't think it is useful to prepare 30 options to configure each. I would like to somehow organize the settings. Can I ask you about what kind of configuration you would like to make for the mode names. For example:
INSERT, REPLACE, VREPLACE, VISUAL, SELECT, BLOCK, LINE?-- ... --?Also it is great to be able to set the position of mode indicator for example at the right end of the prompt.
Maybe I could add a special escape sequence for prompts PS1 or bleopt rps1. Something like bleopt rps1='\p{vi_mode}'. But it induces the re-rendering of entire command line at every change of modes because prompt change could cause the layout change of the command line. What do you think of this?
Yes it would seem ugly to set options for every case. Personally I would like to change words (including enclosing string) to some sensible icon not to clutter my prompt. I think enclosing strings should be included in the names themselves not to have too many options.
As for names in prompt, changing modes doesn't happen too often (at-least it is not like at every char input) so I wouldn't mind a redraw now and then.
Thank you for your reply! OK, it seems like you would like to have a mode indicator in the prompt. I think "the mode line" and "the mode string in prompt" can be configured separately. In the commit 76be6f1 , I added options for the mode line and the prompt. I also added a support for Readline settings of show-mode-in-prompt and {emacs,vi-ins,vi-cmd}-mode-string. The added settings and features are listed below:
bleopt keymap_vi_mode_showbleopt keymap_vi_mode_name_insertbleopt keymap_vi_mode_name_replacebleopt keymap_vi_mode_name_vreplacebleopt keymap_vi_mode_name_visualbleopt keymap_vi_mode_name_selectbleopt keymap_vi_mode_name_linewisebleopt keymap_vi_mode_name_blockwise\q{NAME ARGS...}bleopt keymap_vi_mode_update_promptset show-mode-in-promptset emacs-mode-stringset vi-ins-mode-stringset vi-cmd-mode-stringFor example, you can write the following setting in blerc to show the mode name in the prompt. You can change the strings '(cmd)', etc. in the following setting.
# blerc
# Define prompt sequence \q{my/vim-mode}
function ble/prompt/backslash:my/vim-mode {
bleopt keymap_vi_mode_update_prompt:=1
case $_ble_decode_keymap in
(vi_[on]map) ble/prompt/print '(cmd)' ;;
(vi_imap) ble/prompt/print '(ins)' ;;
(vi_smap) ble/prompt/print '(sel)' ;;
(vi_xmap) ble/prompt/print '(vis)' ;;
esac
}
# Specify \q{my/vim-mode} in PS1
PS1='blahblah\q{my/vim-mode}\$ '
# Do not show mode line
bleopt keymap_vi_mode_show:=
I also added a sample configuration at contrib/prompt-vim-mode.bash. If you would like to use the sample setting without modification, you can simply write as follows:
# blerc
ble-import contrib/prompt-vim-mode
PS1='....\q{contrib/vim-mode}\$ '
bleopt keymap_vi_mode_show:=
Can you test the behavior? Any additional suggestions are welcome.
I have tested it out thoroughly. It works perfect. Except that on startup there is an error related to sed. It prints out the help menu.
ps: I am atomized by and thankful for your very fast response.
Thank you for your testing!
Except that on startup there is an error related to sed. It prints out the help menu.
It seems I cannot reproduce the error.
sed implementation causes the error)?sed?Did the problem start to happen after the last commit?
Yes. But, I was using the packaged version (ble-0.3.2.tar.xz) from github before. And now I cloned the repository an installed from source. I haven't tested commits before the last commit.
Which operating system do you use (because maybe the sed implementation causes the error)?
I am using arch-linux with sed 4.8-1
Do you have some prompt settings that use sed?
I do have prompt setting using sed but I have also tested it with no settings at all. It is still the same. Note that the sed help menu is displayed only once. just after the first command is run. Also, I haven't encountered any malfunctions on the prompt.
Sorry for the confusion. I got bad configs in .bashrc.
Thanks!
It might be off-topic but Is there a way to make PS1 transient and replace it with other prompt? Like in zsh's p10k plugin? I would look it up myself but I don't know where to start. Maybe some directions?
It might be off-topic but Is there a way to make PS1 transient and replace it with other prompt? Like in zsh's p10k plugin? I would look it up myself but I don't know where to start. Maybe some directions?
Maybe you could have exploited PS0 (Bash 4.4+) to rewrite the prompt contents before leaving the command line as described in the article "When did I run that command?". You can trim the terminal lines by the escape sequence \e[xxxM where xxx is the number of lines to be removed. But I'm not sure if that kind of hack is robust and stable.
06381c9 Instead of hacking PS0, I have newly supported the proper way in ble.sh through the options bleopt prompt_ps1_* for the transient prompts.
Also some option names have been changed:
rps1 => prompt_rps1,rps1_transient => prompt_rps1_transient,keymap_vi_nmap_name => keymap_vi_mode_string_nmapFor the detailed description, please follow the above links. Here I explain a simple usage: When you want to have a similar effect with p10k POWERLEVEL9K_TRANSIENT_PROMPT=always, please write in the following way:
# blerc
# Similar to POWERLEVEL9K_TRANSIENT_PROMPT=always
bleopt prompt_ps1_transient=always:trim
For POWERLEVEL9K_TRANSIENT_PROMPT=same-dir, you can write as follows:
# blerc
# Similar to POWERLEVEL9K_TRANSIENT_PROMPT=same-dir
bleopt prompt_ps1_transient=same-dir:trim
For more flexible configuration, you can use prompt_ps1_final. When the option is set, the prompt PS1 is replaced by prompt_ps1_final on leaving the command line. For example, the effect in "When did I run that command?" can be achieved by the following simple setting:
# blerc
PS1='\e[33m\n--:--:-- \w\n\$ '
bleopt prompt_ps1_final='\e[33m\n\t \w\n\$ '
Note: as I'm not familiar with p10k, I have referenced the following links. I have just taken a look at the articles and haven't tried p10k in my machine, so it is possible that the behavior would be different from the intended one. If you notice some differences, please feel free to let me know that.
Perfect! Clear and Works as intended. Thanks.
Thank you!