From 298b4806809974fb9ed102f22241b20404cd99c4 Mon Sep 17 00:00:00 2001 From: teutat3s Date: Mon, 15 Apr 2024 13:23:10 +0200 Subject: [PATCH] ble.sh: fix newlines inserted at the top of the terminal --- modules/terminal-life/bash/default.nix | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/modules/terminal-life/bash/default.nix b/modules/terminal-life/bash/default.nix index a46d616d..5366c433 100644 --- a/modules/terminal-life/bash/default.nix +++ b/modules/terminal-life/bash/default.nix @@ -74,7 +74,28 @@ in { # Bash vim mode keybindings if [[ $- == *i* ]]; then # in interactive session set -o vi + fi + # Don't show a mode name in the normal mode + function ferdinandyb/set-up-mode-indicator { + # Define \q{ferdinandyb/mode-indicator} + function ble/prompt/backslash:ferdinandyb/mode-indicator { + if local mode; ble/keymap:vi/script/get-mode; [[ $mode != i ]]; then + # call the built-in mode indicator + ble/prompt/process-prompt-string '\q{keymap:vi/mode-indicator}' + fi + } + + # Specify \q{ferdinandyb/mode-indicator} in the mode-indicator prompt + bleopt prompt_vi_mode_indicator='\q{ferdinandyb/mode-indicator}' + + # In case you would like to show "-- NORMAL --" instead of "~" + bleopt keymap_vi_mode_string_nmap=$'\e[1m-- NORMAL --\e[m' + } + blehook/eval-after-load keymap_vi ferdinandyb/set-up-mode-indicator + + function blerc/vim-mode-hook { + # Write your settings for vi/vim mode here ble-bind -m vi_imap -f 'ENTER' 'vi_imap/complete' ble-bind -m vi_imap -f 'TAB' 'vi_imap/complete' @@ -88,7 +109,9 @@ in { ble-bind -m vi_nmap -f 'l' 'vi-command/forward-char' ble-bind -m vi_imap -f 'C-c' discard-line - fi + + } + blehook/eval-after-load keymap_vi blerc/vim-mode-hook # end of .bashrc # Somehow we need to ensure starship starts later than ble.sh