How to properly link the patched GNU readline library with all existing programs?

My initial problem was that I would like to distinguish if I am in vi command mode or vi insert mode when using bash in vi mode. I understand that as of GNU readline 7.0 there is a way to set the indicator on the command line; however I want to rather change the shape of the cursor (i.e. vertical line in insert mode and solid block in command mode).


NOTE: I already tried putting the following in my .inputrc, which did the trick, but it caused some problems when going to the beginning of the line in command line mode, so I concluded that this was not a good alternative.

set show-mode-in-prompt on
set vi-cmd-mode-string "\e[2 q"
set vi-ins-mode-string "\e[6 q"

      


I stumbled upon an article written by someone who was having the same problem and ended up fixing the GNU readline library linked here below:

http://blog.mkoskar.com/2010/10/gnu-readline-vi-mode-visualization.html http://blog.mkoskar.com/2010/11/gnu-readline-vi-mode-visualization-2 .html


So far I've managed to successfully apply the patch and compile / install the library (locally ... I'd rather keep the installed version intact if I ever want to switch), but bash still stays using the original.

Here are the important details:

1) The fixed library files (static and dynamic) are located on my computer at $ HOME / .local / lib /.
2) The library source files (dynamic only) that I have defined are located in / lib / x 86_64-linux-gnu /.
3) My environment variable LD_LIBRARY_PATH is set to $HOME/.local/lib:

inside my .bashrc.


Even though the patched version is installed and my LD_LIBRARY_PATH variable is set correctly, bash still doesn't use my patched GNU readline library. I am wondering if there is something I am doing wrong?

I hope the problem is not that bash comes with the readline library already copied, requiring, I suppose, reinstall bash (as well as any other programs that use this library, such as iPython) by manually linking in the patched version of readline.


DECISION

While this is not a solution to the question in the title, it is a solution to the original problem I had. After looking through the Readline man pages, I found the following descriptions for vi-cmd-mode-string

and vi-ins-mode-string

:

vi-cmd-mode-string ((cmd))
       This  string  is  displayed immediately before the last line of the primary prompt when vi editing mode is active and in command mode.  The value is expanded like a key binding, so the
       standard set of meta- and control prefixes and backslash escape sequences is available.  Use the \1 and \2 escapes to begin and end sequences of non-printing characters, which  can  be
       used to embed a terminal control sequence into the mode string.
vi-ins-mode-string ((ins))
       This  string is displayed immediately before the last line of the primary prompt when vi editing mode is active and in insertion mode.  The value is expanded like a key binding, so the
       standard set of meta- and control prefixes and backslash escape sequences is available.  Use the \1 and \2 escapes to begin and end sequences of non-printing characters, which  can  be
       used to embed a terminal control sequence into the mode string.

      

The part about shoots \ 1 and \ 2 is important stuff ...


So basically, placing the following in my .inputrc allowed me to set the cursor shape based on the current vi mode:

set show-mode-in-prompt on
set vi-cmd-mode-string "\1\e[2 q\2"
set vi-ins-mode-string "\1\e[6 q\2"

      

+2


source to share





All Articles