From 5b60455691922c0acf971557a138f3176cba0838 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 15 Mar 2012 16:05:46 +0100 Subject: [Keys] Binds ^K to redefine current prompt. :) --- 12_Prompts.zsh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to '12_Prompts.zsh') diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 61ca77a..afe2ede 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -77,6 +77,17 @@ __hbar() fi } +__get_prompt_lines() +{ + local lines + lines=$( (__expand_text "$PS1 $@" ) | sed "s/\\(.\{,$COLUMNS\}\\)/\\1\n/g" ) + lines=$( echo "$lines" | sed -n '/^$/n;p' | wc -l ) + # Got number of empty lines at end of command, because they are screwed up above... + lines=$(( $lines + $( echo -n "$@" | tr ';\n' '.;' | sed 's/^\(.*[^;]\)\(;*\)$/\2/' | wc -c ) )) + + echo $lines +} + preexec () { __term_title "$2" @@ -87,11 +98,7 @@ preexec () __hbar __redefine_prompt - local lines - lines=$( (__expand_text "$PS1 $1" ) | sed "s/\\(.\{,$COLUMNS\}\\)/\\1\n/g" ) - lines=$( echo "$lines" | sed -n '/^$/n;p' | wc -l ) - # Got number of empty lines at end of command, because they are screwed up above... - lines=$(( $lines + $( echo -n "$1" | tr ';\n' '.;' | sed 's/^\(.*[^;]\)\(;*\)$/\2/' | wc -c ) )) + local lines=$(__get_prompt_lines "$1") tput sc for i in {1..$lines} ; tput cuu1 -- cgit v1.2.3