чување f6a86d2edd4b36a4e12417b34d2882e8c4ea548e
родитељ 153d5161cd533cb18f6ad4780f7a07919b67577e
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sat, 16 Sep 2023 21:24:44 +0200
Add rlwrap support for command line editing (optional dep)
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 2, додавања: 18(+), брисања: 4(-)
diff --git a/INSTALL b/INSTALL
@@ -8,8 +8,14 @@ Prerequisites
* vipe from moreutils[2]
* Any text editor set via EDITOR environment variable
+Optional
+--------
+
+* rlwrap[3] (autodetected, fallback if absent) for command line editing
+
[1]: https://strahinja.srht.site/table/
[2]: https://joeyh.name/code/moreutils/
+[3]: https://github.com/hanslub42/rlwrap
Install
diff --git a/ste.in b/ste.in
@@ -10,6 +10,8 @@
clear=1
# Table output width in screen columns (0 = detect)
cols=0
+# History file location (if using rlwrap)
+historyfile="$HOME/.ste_history"
# Table output height in screen rows (0 = detect)
rows=0
# Pass -m to table
@@ -231,10 +233,16 @@ while [ "$continue" -eq 1 ]; do
fi
if [ -z "$nextcmd" ]; then
- printf "%s[%dx%d+%d@%d/%d]> " \
- "${file##*/}" "$_cols" "$_rows" "$firstrow" "$currow" \
- "$maxrows"
- IFS= read -r cmd
+ if command -v rlwrap >/dev/null; then
+ cmd=$(rlwrap -H "$historyfile" -s 1000 -D 2 -I -o \
+ -S "${file##*/}[${_cols}x${_rows}+${firstrow}"\
+"@${currow}/${maxrows}]> " cat)
+ else
+ printf "%s[%dx%d+%d@%d/%d]> " \
+ "${file##*/}" "$_cols" "$_rows" "$firstrow" \
+ "$currow" "$maxrows"
+ IFS= read -r cmd
+ fi
else
cmd="$nextcmd"
nextcmd=''