aboutsummaryrefslogtreecommitdiffstats
path: root/incdec
diff options
context:
space:
mode:
authorTeddy Wing2021-08-08 15:54:51 +0200
committerTeddy Wing2021-08-08 15:54:51 +0200
commitdb918a0716aaf559c3f64688c2c3ca9388172b7f (patch)
tree6d68194c1c483ab6b01a1e878de5aa2343d7aaf6 /incdec
parent9338c2cff6b4055f18c19b72a523a1e51d3359af (diff)
downloadreadline-incdec-db918a0716aaf559c3f64688c2c3ca9388172b7f.tar.bz2
incdec: Increment the number on the current line
Got it working! Thanks to the Fzf Bash code for showing me that you can assign to `READLINE_LINE` and `READLINE_POINT`: https://github.com/junegunn/fzf/blob/7191ebb615f5d6ebbf51d598d8ec853a65e2274d/shell/key-bindings.bash
Diffstat (limited to 'incdec')
-rw-r--r--incdec12
1 files changed, 8 insertions, 4 deletions
diff --git a/incdec b/incdec
index 854717d..3320bad 100644
--- a/incdec
+++ b/incdec
@@ -8,9 +8,9 @@ function incdec {
local number=
# If the line part doesn't contain a number, exit.
- if ! [[ "$line_part" =~ [^0-9]*([0-9]+)[^0-9]* ]]; then
- return $EX_DATAERR
- fi
+ # if ! [[ "$line_part" =~ [^0-9]*([0-9]+)[^0-9]* ]]; then
+ # return $EX_DATAERR
+ # fi
number=${BASH_REMATCH[1]}
@@ -20,7 +20,9 @@ function incdec {
incremented_line="$(echo "$line_part" | perl -pe 's/(\d+)/$1+1/e')"
- printf "${READLINE_LINE:0:$READLINE_POINT}$incremented_line"
+ # echo "${READLINE_LINE:0:$READLINE_POINT}$incremented_line"
+ READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$incremented_line"
+ # echo 'this is a test'
}
function __readline_incdec_incdec2 {
@@ -33,6 +35,8 @@ function __readline_incdec_incdec2 {
# }
bind -x '"\C-xa+":incdec'
+# bind '"\C-xa+": "\C-e$(incdec)\e\C-e"'
+# bind '"\C-xa+": "\C-e`incdec`"'
# bind '"\C-xaa":\C-xa+'
function __readline_incdec_save_readline_point {