mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
bash: reverse % + clear incomplete line a la zsh
This commit is contained in:
parent
d7189d263e
commit
37ce373989
2 changed files with 20 additions and 1 deletions
17
bash/prompt
17
bash/prompt
|
|
@ -41,6 +41,23 @@ __tpwd() {
|
|||
__truncate_path "$PWD"
|
||||
}
|
||||
|
||||
clear_incomplete_line() {
|
||||
# prevent the terminal response to be displayed
|
||||
stty raw -echo
|
||||
# ask for cursor position
|
||||
echo -en "\033[6n"
|
||||
# read answer
|
||||
IFS=';' read -r -d R -a pos
|
||||
# set back terminal to human mode
|
||||
stty -raw echo
|
||||
# extract tput-compatible answer
|
||||
local row=$((${pos[0]:2} - 1))
|
||||
local col=$((${pos[1]} - 1))
|
||||
|
||||
# not on first column? clean up!
|
||||
[[ $col != 0 ]] && printf "\e[7m%%\e[m%$((COLUMNS-1))s\r"
|
||||
}
|
||||
|
||||
# git prompt info
|
||||
source $DOTFILES_BASH_DIR/git_prompt_info
|
||||
GIT_PS1_SHOWDIRTYSTATE=1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue