From 04c51b3dc96a304be01e5ddc0a5f975da54854c6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 4 Aug 2020 00:17:56 +0300 Subject: [PATCH] prompts --- README | 1 + shfm | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README b/README index 31ae733..2265ebf 100644 --- a/README +++ b/README @@ -39,6 +39,7 @@ h - go up level g - go to top G - go to bottom q - quit +: - cd to opener diff --git a/shfm b/shfm index a5de42f..4fe8e48 100755 --- a/shfm +++ b/shfm @@ -74,6 +74,21 @@ status_line() { "$LINES" "$COLUMNS" "$1" } +prompt() { + printf '\0337\033[%sH%s' "$LINES" "$1" + + case $2 in + r) + stty icanon echo + read -r ans ||: + stty -icanon -echo + ;; + esac + + printf '\0338' + status_line "$PWD ($y/$#)" +} + print_line() { offset=$1 @@ -172,13 +187,22 @@ main() { redraw "$@" ;; - # broken G?) y=$# y2=$(($# < bottom ? $# : bottom)) redraw "$@" ;; + :?) + prompt "cd: " r + + cd "${ans:="$0"}" >/dev/null 2>&1|| continue + + set -- * + y=1 y2=1 + redraw "$@" + ;; + q?) exit 0 ;;