Macros for ble.sh #294
mozirilla213
started this conversation in
Ideas
Replies: 2 comments 3 replies
-
function ble/widget/my/ex1 {
ble/widget/vi_nmap/linewise-visual-mode
sleep .4
ble/keymap:vi/operator:filter
ble/widget/insert-string "m4 ~/bash.m4 -"
#ble/widget/accept-single-line-or-newline
} Doesn't quite work |
Beta Was this translation helpful? Give feedback.
0 replies
-
It seems just achievable with the plain Bash feature to me. Is it different from just doing something like the below? bind -x '"\C-t": READLINE_LINE=$(m4 ~/bash.m4 - <<< "$READLINE_LINE")' Edit (2023-03-09): I have added the missing |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So zsh supports aliases with positional parameters like
making them a simple form of a macro, but since ble.sh in vi-mode can use the operator filter
!
like in vim, we could process the text in our command line with whatever command and have it expand to a more complex code.So I'll use the
m4
macro processor for example, it should be available for Unix. Create a filebash.m4
with the following content and put in let's say in your home directory:Now open bash with ble.sh in vi-mode, write the following, then enter normal mode, type double bang
!!
and enter the m4 command, then press enter:And that's how to get macro expansions in ble.sh, you could make far more complex examples if you learn some
m4
, or some other macro processor, or make your own tools with whatever language. (Note that writing bad macros in m4 leads to infinite loops)Now I wish I knew a way to better integrate this so that I could press a keybinding and execute this macro expansion (or whatever command in operator filter mode), like how I can do with abbreviations. It could be yet another killer feature of ble.sh
Beta Was this translation helpful? Give feedback.
All reactions