-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
D1665.bashrc2
176 lines (153 loc) · 3.44 KB
/
D1665.bashrc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
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