Closed theshatterstone closed 3 months ago
You can use \q{user/currentmode}
only after you define the function ble/prompt/backslash:user/currentmode
. In the above setup, you define the function ble/prompt/backslash:user/currentmode
through the keymap_vi
load hook, which is called after precmd
and the first prompt. You use \q{user/currentmode}
in precmd
, but the function ble/prompt/backslash:user/currentmode
is not defined for the first call of precmd
. This causes the error.
To solve the problem, for example, one may consider defining the function ble/prompt/backslash:user/currentmode
outside the keymap_vi
load hook. However, there is a reason that the above ble/prompt/backslash:user/currentmode
was defined through the keymap_vi
load hook: the function ble/keymap:vi/script/get-mode
called by ble/prompt/backslash:user/currentmode
is only available after the vi module is loaded. Then, you can use ble/function#try ble/keymap:vi/script/get-mode
to call ble/keymap:vi/script/get-mode
only when it is available.
function ble/prompt/backslash:user/currentmode {
local mode=
ble/function#try ble/keymap:vi/script/get-mode
case $mode in
(*n) ble/prompt/print $'\e[1mNormal\e[m' ;;
(*i) ble/prompt/print $'\e[1mInsert\e[m' ;;
(*v) ble/prompt/print $'\e[1mVisual\e[m' ;;
(*V) ble/prompt/print $'\e[1mV-Line\e[m' ;;
(*^V) ble/prompt/print $'\e[1mV-Bloq\e[m' ;;
(*s) ble/prompt/print $'\e[1mSelect\e[m' ;;
(*S) ble/prompt/print $'\e[1mS-Line\e[m' ;;
(*^S) ble/prompt/print $'\e[1mS-Bloq\e[m' ;;
(R) ble/prompt/print $'\e[1mRPlace\e[m' ;;
(^R) ble/prompt/print $'\e[1mVPlace\e[m' ;;
(*) ble/prompt/print $'\e[1m??????\e[m' ;;
esac
}
Adding that function outside of the hook fixes it! Thanks. (Also, I removed the user/currentmode function from the keymap_vi load hook as it's not needed anymore and it still works). Closing this issue. Thank you!
ble/prompt: Undefined named sequence: \q{user/currentmode}
I get this as a message in the top right corner on every bash startup. I use the set-up-status-line function to get the current vi mode so I can have it displayed in my prompt (but NOT in a modeline or status line). It works but the error message is very annoying so any solution, including a dirty hack to supress or otherwise get rid of the message would be very appreciated. Thanks.
My Config: