Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The keybindings themselves are part of readline, and can be changed in your <code>~/.inputrc</code> or use the <code>bind</code> command in your <code>.bashrc</code> (etc.), but they don't bind <em>directly</em> to user-defined functions, only indirectly as macros that might call those functions.</p> <pre><code>"\C-xhf": dump-functions # for ~/.inputrc bind '"\C-xhf":dump-functions' # in .bashrc (etc.) </code></pre> <p><code>bind -l</code> will show you builtin functions you <em>can</em> bind to. You can add macros this way, which let's you run any bash function you want, although not in completion context, so the results don't get stuffed back into the command line. Example:</p> <pre><code>"\C-xc": "echo hi\n" # note it's a just macro, not a direct binding. </code></pre> <p>I'm guessing you already know you can override completion with the <code>complete</code> builtin for commands at the left on the command line. Normally I'd just suggest creating your own completion routines that way and using them instead of working out a way to call an alternate set. Example:</p> <pre><code>_complete_ssh () { local ssharg="${COMP_WORDS[COMP_CWORD]}" local filter=cat case "$ssharg" in *@*) filter="sed s/^/${ssharg%@*}@/" ;; esac local host=${ssharg##*@} COMPREPLY=( $(compgen -W "` sed 's/[, ].*//' ~/.ssh*/known_hosts{,2} | sort | uniq `" $host | $filter )) return 0 } complete -F _complete_ssh ssh # for any command starting with "ssh "... </code></pre> <p>I experimented with binding <code>universal-argument</code> to see if it would affect a function run via a macro ("C-xu" to prefix UA, then "C-xf" to run a function), but I haven't noticed anything to indicate the function can detect UA. You'd think <code>bind</code> would have a option to regurgitate what UA was for the previous command, or a $-something, which might have allowed a user-defined completer sub-function to detect UA from inside of <code>complete</code>, and thus behave differently, but I don't see any sign of the idea in the readline source code. There's no obvious way to see what keybinding evoked a function or macro either (I didn't expect one), to allow mapping two keybindings to the same <code>complete</code> builtin, then backtracking to see which keybinding triggered it.</p> <p>Note that Shift-TAB would be hard to bind anyway, and impossible to type from an old-school terminal. bash doesn't use the X libraries and can't see Shift directly as a modifier, instead depending on terminals or terminal emulators for input in some character set, which don't have an applicable concept of modifiers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload