aboutsummaryrefslogtreecommitdiffstats
path: root/incdec
diff options
context:
space:
mode:
authorTeddy Wing2021-08-08 05:05:33 +0200
committerTeddy Wing2021-08-08 05:05:33 +0200
commit44b8cbfb87afb35ad518186d7cce47fec8a5370b (patch)
tree43f5fc48f8b0734af404c29a9c116dce57fb5271 /incdec
parentdf2d935925498bba66a27bd51819ab0b9200863c (diff)
downloadreadline-incdec-44b8cbfb87afb35ad518186d7cce47fec8a5370b.tar.bz2
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.
Diffstat (limited to 'incdec')
-rw-r--r--incdec8
1 files changed, 5 insertions, 3 deletions
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