-
-
Save atdt/59c3cf13e0967fc3cefba3b7777f602c to your computer and use it in GitHub Desktop.
bash: any idea how to use the readline function 'history-and-alias-expand-line' in a recursive way?!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Method 1 | |
bind -x '"\C-x4": history_and_alias_expand_line'; | |
bind '"\C-x3": history-and-alias-expand-line'; | |
bind -x '"\C-x2": READLINE_LINE_OLD="$READLINE_LINE"'; | |
bind '"\C-x1": "\C-x2\C-x3\C-x4\C-x5"'; | |
function history_and_alias_expand_line { | |
if | |
[[ "$READLINE_LINE" == "$READLINE_LINE_OLD" ]]; | |
then | |
bind '"\C-x5": abort'; | |
unset -v READLINE_LINE_OLD; | |
else | |
bind '"\C-x5": "\C-x1"'; | |
fi; | |
}; | |
# Method 2 | |
bind '"\C-x2": history-and-alias-expand-line' | |
bind '"\C-x1": "\C-x(\C-x2\C-x)\M-100\C-xe"' | |
# vim: set ts=4 sw=4 tw=0 et : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment