Search code examples
vimintellij-ideaterminalzsh

IntelliJ terminal cursor shape


So, I am obsessed with Vim. I use vi mode everywhere - in all the editors and IDEs that support it. I use it it my browser (vimium, wasavi). I use 'hjkl' navigation everywhere thanks to awesome Karabiner. I use vi mode in my terminal via iTerm under zsh. Long time ago I found this little trick that changes cursor shape in the terminal depending of what mode you're currently in.

Now, although it perfectly works for iTerm, sadly it doesn't work in OS X's builtin terminal. I couldn't care less about that, except it also doesn't work in my favorite WebStorm. I thought I could trick it and instead of changing cursor's shape I could try tweaking its color. Still didn't work.

Please guys, help me to find a way to tweak cursor in IDEA's Terminal. Thanks!

p.s.: Some may suggest to change the prompt depending the mode, but honestly I don't like that. I still believe there's a way to change cursor shape or color. Prob. just need to find the right escape sequence.


Solution

  • Unfortunately it looks like Intellij terminal draws it's own cursor without respect to bash or zsh settings.

    Note I'm assuming community and pro editions of Intellij use the same terminal plugin

    You can see the Terminal plugin source here

    The terminal plugin uses Jediterm, a Java based terminal emulator written by JetBrains

    Most of the drawing of the terminal window is handled in TerminalPanel.java and has a nested class called TerminalCursor

    From the TerminalCursor class you can see that Java Graphics is used to draw boxes for regular cursors and blinking cursors.

    Code that draws a rectangle for the cursor

    I'm still not sure how the unfocused cursor is drawn since it's just an outline, and I can't find a handler for lost focus on the frame.