From 44b8cbfb87afb35ad518186d7cce47fec8a5370b Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 8 Aug 2021 05:05:33 +0200 Subject: incdec: Ideas for operating on the full command line If we have access to the full command line and modify the number in it, we can print the whole thing with the number incremented onto the working command line. Probably going to need some Perl to do the regex and incrementing. --- incdec | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'incdec') diff --git a/incdec b/incdec index 5981e43..cad4101 100644 --- a/incdec +++ b/incdec @@ -8,12 +8,14 @@ function incdec { local number= # If the line part doesn't contain a number, exit. - if ! [[ "$line_part" =~ ([0-9]+) ]]; then + if ! [[ "$line_part" =~ [^0-9]*([0-9]+)[^0-9]* ]]; then return $EX_DATAERR fi number=${BASH_REMATCH[1]} + echo "${READLINE_LINE}" + echo "${BASH_REMATCH[0]}" echo "$(($number + 1))" } @@ -22,7 +24,7 @@ function __readline_incdec_incdec2 { echo !# } -# bind -x '"\C-xa+":incdec' +bind -x '"\C-xa+":incdec' # bind '"\C-xaa":\C-xa+' function __readline_incdec_save_readline_point { @@ -33,7 +35,7 @@ bind -x '"\C-xasrp": __readline_incdec_save_readline_point' # bind '"\C-xaa": \C-xasrp\C-c$(__readline_incdec_incdec2)\e\C-e' # bind '"\C-xaa": \C-xasrp' -bind '"\C-xaa": __readline_incdec_incdec2' +# bind '"\C-xaa": __readline_incdec_incdec2' # 2021.01.15: Idea: Maybe try using $EDITOR -- cgit v1.2.3