|
@@ -114,14 +114,14 @@ validate "$@"
|
|
|
|
|
|
fzf_rw0_inplace_preview () {
|
|
fzf_rw0_inplace_preview () {
|
|
# NOTE: to preview and select captured command directories
|
|
# NOTE: to preview and select captured command directories
|
|
|
|
+ header_len="$1"
|
|
# shellcheck disable=SC2016
|
|
# shellcheck disable=SC2016
|
|
fzf \
|
|
fzf \
|
|
--read0 --print0 \
|
|
--read0 --print0 \
|
|
-m \
|
|
-m \
|
|
--no-sort \
|
|
--no-sort \
|
|
-d / \
|
|
-d / \
|
|
- --nth 1,2,3 \
|
|
|
|
- --preview-window="~2" \
|
|
|
|
|
|
+ --preview-window="~$header_len" \
|
|
--preview='cat {}/info; head -n "$LINES" {}/dat' \
|
|
--preview='cat {}/info; head -n "$LINES" {}/dat' \
|
|
&& :
|
|
&& :
|
|
}
|
|
}
|
|
@@ -160,8 +160,31 @@ awk_r0_add_prefix () {
|
|
&& :
|
|
&& :
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+sort_rw0 () {
|
|
|
|
+ # NOTE: sort by program, or timestamp
|
|
|
|
+ if [ "$1" = "prog" ]
|
|
|
|
+ then
|
|
|
|
+ sort -zrV
|
|
|
|
+ elif [ "$1" = "ts" ]
|
|
|
|
+ then
|
|
|
|
+ awk \
|
|
|
|
+ -v FS='/' -v RS='\0' \
|
|
|
|
+ -v OFS='/' -v ORS='\0' \
|
|
|
|
+ '{print $NF,$0}' \
|
|
|
|
+ | sort -zrV \
|
|
|
|
+ | awk_rw0_strip_first_path_part \
|
|
|
|
+ :
|
|
|
|
+ else
|
|
|
|
+ echo "unsupported sort option: $1" >&2
|
|
|
|
+ false
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
if "$LIST_MODE"
|
|
if "$LIST_MODE"
|
|
then
|
|
then
|
|
|
|
+ # TODO: make sort option configurable
|
|
|
|
+ sort_opt="ts"
|
|
find_name=()
|
|
find_name=()
|
|
if [ "${1:-}" ]
|
|
if [ "${1:-}" ]
|
|
then
|
|
then
|
|
@@ -183,7 +206,7 @@ then
|
|
\) \
|
|
\) \
|
|
\) \
|
|
\) \
|
|
-print0 \
|
|
-print0 \
|
|
- | sort -zrV \
|
|
|
|
|
|
+ | sort_rw0 "$sort_opt" \
|
|
| head -zn "${NUM:--0}" \
|
|
| head -zn "${NUM:--0}" \
|
|
| fzf_rw0_inplace_preview "2" \
|
|
| fzf_rw0_inplace_preview "2" \
|
|
| awk_rw0_strip_first_path_part \
|
|
| awk_rw0_strip_first_path_part \
|