Bash: call script with customized keyboard shortcuts?

后端 未结 3 1001
梦谈多话
梦谈多话 2021-02-03 15:45

Lets say I have a script, \"myscript.sh\", with contents being simply echo $PWD. I\'d like to bind somehow this script to a key combo in bash

3条回答
  •  忘了有多久
    2021-02-03 16:33

    One way to do what you want with a single key press is to take advantage of programmable completion in bash. You possibly have some programmable completion set up with the bash_completion tool/package. If not, look into that to see the specifics of how it is done.

    The idea is to have the programmable completion recognise when you have hit at the start of a svn commit message and then have it return a single completion which is the text you want to insert (the basename of the current directory).

    I've only dabbled with programmable completion so I can't give you the details, but the above-mentioned bash_completion package or the subversion completion script may be a good start.

提交回复
热议问题