Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prompt: support "bleopt prompt_ruler"
- Loading branch information
1 parent
a3047f5
commit 05cf638
Showing
6 changed files
with
425 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# -*- mode: sh-bash -*- | ||
|
||
type=fix3b | ||
|
||
if [[ $type == rep-c2w-auto-fail ]]; then | ||
source out/ble.sh --norc | ||
|
||
getCPos() { | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
} | ||
|
||
custom_prompt() { | ||
getCPos | ||
if [ $CPos -eq 1 ]; then | ||
PS1="" | ||
else | ||
PS1="\n" | ||
fi | ||
} | ||
PROMPT_COMMAND=custom_prompt | ||
|
||
ble-attach | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
|
||
if [[ $type == rep-c2w-auto-fail-min ]]; then | ||
source out/ble.sh --norc | ||
getCPos() { | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
} | ||
PROMPT_COMMAND=getCPos | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
|
||
if [[ $type == fix-exclude-blesh ]]; then | ||
custom_prompt() { | ||
cmd_cde=$? | ||
window_title | ||
if ! ble 2>/dev/null; then | ||
getCPos | ||
if [ $CPos -eq 1 ]; then | ||
PS1="" | ||
else | ||
PS1="\n" | ||
fi | ||
fi | ||
PS1+="\[$(tput setaf 1)\]┏━" | ||
} | ||
|
||
source out/ble.sh --norc | ||
getCPos() { | ||
if [[ ! ${_ble_attached-} ]]; then | ||
#if ! ble 2>/dev/null; then | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
fi | ||
} | ||
PROMPT_COMMAND=getCPos | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
# 修正案2 | ||
|
||
if [[ $type == fix2 ]]; then | ||
source out/ble.sh --norc | ||
custom_prompt() { | ||
printf -v PS1 $'\[ \b\e[%dC %s\r\]' $((COLUMNS-2)) "$(tput xenl && echo ' ')" | ||
PS1+='hello\$ ' | ||
} | ||
PROMPT_COMMAND=custom_prompt | ||
fi | ||
|
||
if [[ $type == fix3 ]]; then | ||
source out/ble.sh --norc | ||
|
||
getCPos() { | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
} | ||
|
||
if [[ ${BLE_VERSION-} ]]; then | ||
ble/function#advice after ble/widget/clear-screen '_ble_edit_lineno=0' | ||
_check_clear_command() { | ||
local rex_eval_prefix='((eval|command|env|sudo)[[:space:]]+)?' | ||
local rex_clear_command='(tput[[:space:]]+)?(clear|reset)' | ||
local rex=$'(^|[\n;&|(])[[:space:]]*'$rex_eval_prefix$rex_clear_command'([ \t\n;&|)]|$)' | ||
[[ $BASH_COMMAND =~ $rex ]] && _ble_edit_lineno=0 | ||
} | ||
blehook POSTEXEC+=_check_clear_command | ||
fi | ||
|
||
custom_prompt() { | ||
if | ||
if [[ $_ble_attached ]]; then | ||
((_ble_edit_lineno==0)) | ||
else | ||
getCPos; [ $CPos -eq 1 ] | ||
fi | ||
then | ||
PS1="" | ||
else | ||
PS1="\n" | ||
fi | ||
PS1+='hello\$ ' | ||
} | ||
PROMPT_COMMAND=custom_prompt | ||
fi | ||
|
||
if [[ $type == fix3b ]]; then | ||
source out/ble.sh --norc | ||
|
||
getCPos() { | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
} | ||
|
||
if [[ ${BLE_VERSION-} ]]; then | ||
CPos=(1 1) | ||
blehook POSTEXEC+=getCPos | ||
fi | ||
|
||
custom_prompt() { | ||
if [[ ! ${_ble_attached-} ]]; then | ||
getCPos | ||
fi | ||
if [ $CPos -eq 1 ]; then | ||
PS1="" | ||
else | ||
PS1="\n" | ||
fi | ||
PS1+='hello\$ ' | ||
} | ||
PROMPT_COMMAND=custom_prompt | ||
fi | ||
|
||
#------------------------------------------------------------------------------ | ||
# minimal reproducer for absorbed characters | ||
|
||
if [[ $type == rep-absorb-chars ]]; then | ||
getCPos() { | ||
local v=() t=$(stty -g) | ||
stty -echo | ||
printf "\033[6n" | ||
IFS='[;' read -ra v -d R | ||
stty $t | ||
CPos=(${v[@]:1}) | ||
} | ||
#PROMPT_COMMAND=getCPos | ||
|
||
something_slow() { sleep 2; } | ||
something_slow | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# -*- mode: sh; mode: sh-bash -*- | ||
|
||
# urxvt で C-l した直後に bash が 1-2 秒程 100% になって反応しなくなる | ||
# 問題。 | ||
|
||
source out/ble.sh --norc | ||
#PS1=$'\[\e[38;5;1m\]┏━[\e[38;5;7m\]\w\[\e[38;5;1m\]]\n\[\e[38;5;1m\]┗━━ \[\e[38;5;8m\]■ \[\e[38;5;7m\]' | ||
#PS1=$'\[\e[38;5;1m\]┏━[\[\e[38;5;7m\]\w\[\e[38;5;1m\]]\n\[\e[38;5;1m\]┗━━ \[\e[38;5;8m\]■ \[\e[38;5;7m\]' | ||
#PS1=$'┏━[\w]\n┗━━ ■ ' # ok | ||
#PS1=$'\e[38;5;1m@\e[38;5;7m@\e[38;5;1m]@\e[38;5;1m@\e[38;5;8m@\e[38;5;7m' | ||
#PS1=$'\e[38;5;1m@\e[38;5;1m@\e[38;5;1m@\e[38;5;1m@\e[38;5;1m@\e[38;5;1m' # NG | ||
#PS1=$'\e[31m@\e[31m@\e[31m@\e[31m@\e[31m@\e[31m' # NG | ||
#PS1=$'\e[31m\e[31m\e[31m\e[31m\e[31m\e[31mA ' # NG | ||
#PS1=$'\e[1m\e[1m\e[1m\e[1m\e[1m\e[1mA ' # OK | ||
|
||
# これで再現する??? と思ったら再現しなくなった。改めて urxvt を起動し | ||
# 直して試したら再現しなくなってしまった。何らかの urxvt の設定と関係 | ||
# があるのだろうか。例えば C-l をすると何か大量のデータを送ってくる等? | ||
# 然し、そうだとすると PS1 に関係なく発生しそうだし、着色の SGR を出力 | ||
# する時にだけ問題が発生するというのも変である。 | ||
|
||
PS1=$'\e[31mA ' # NG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.