Complex keybinding in bash

前端 未结 2 1497
臣服心动
臣服心动 2020-12-13 16:30

Is there a way to combine two operations into one keybinding (dont think would work with function).

This is what I\'d like to do:

I\'d like a keybinding (say

2条回答
  •  我在风中等你
    2020-12-13 16:50

    This might work for you:

    "\ex": menu-complete
    "\ez": "ls \ex"
    

    Include these lines in your ~/.inputrc file.

    These lines set Alt-x to menu-complete and Alt-z to ls space menu-complete. This will give you the first file in the directory and use Alt-x to cycle through the remainder one at a time.

    See here for more examples of macros.

    Checkout the readline commands by invoking bind -p or bind -P and bind -s will show the macros you already have. See here for the bind command also you can make one off macros too, see here. Lastly check that the .inputrc file is being read, I had trouble because the environmental variable was set to /etc/Inputrc and my personal version was never being invoked.

    BTW steer clear of Control-x as it is already in use for many readline commands.

提交回复
热议问题