JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.12k stars 2.38k forks source link

Segment to display insert/normal mode for VIM editing mode #2088

Closed AniAggarwal closed 2 years ago

AniAggarwal commented 2 years ago

Code of Conduct

What would you like to see changed/added?

I use VIM-like keybinds in terminal, set via my .inputrc:

# Use Vim keybinds instead of default Emacs
set editing-mode vi
# Show current mode at the beginning of the prompt
set show-mode-in-prompt on
set vi-ins-mode-string "+ "
set vi-cmd-mode-string ": "

So that I can see which mode I am in, a + or a : is displayed at the beginning of my prompt and looks like below: Screenshot from 2022-04-14 10-25-04 Screenshot from 2022-04-14 10-25-53

I would love it if there was a way to integrate that into oh-my-posh.

JanDeDobbeleer commented 2 years ago

@AniAggarwal I had a look at this and it's not possible to get that value so oh-my-posh can use it. What you could do is change the implementation to use a cursor style, that will indicate the current mode by displaying a different cursor:

set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2

# optionally:
# switch to block cursor before executing a command
set keymap vi-insert
RETURN: "\e\n"
AniAggarwal commented 2 years ago

This worked, thanks! I use kitty so I need to figure out how to make it work with that now, but it works on Gnome terminal. Thanks for the pointer.

github-actions[bot] commented 8 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.