justjanne / powerline-go

A beautiful and useful low-latency prompt for your shell, written in go
GNU General Public License v3.0
2.75k stars 269 forks source link

vim mode indicator is not a powerline segment #323

Open xsteadfastx opened 3 years ago

xsteadfastx commented 3 years ago

Describe the bug i love to use the vi mode in fish. but the indicator is not shown as a powerline segment. its shown completly to the left side.

Environment (please complete the following information):

grafik

derphilipp commented 3 years ago

Same issue on

blackheaven commented 2 years ago

Actually that's more a missing feature, here's my workaround on zsh:

#!/usr/bin/env zsh

set opt prompt_subst
export VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
export MODE_INDICATOR="%F{yellow}+%f"

export BASE_PROMPT=$PROMPT

setopt promptsubst
zmodload zsh/datetime
autoload -U add-zsh-hook

function preexec() {
  __TIMER=$EPOCHREALTIME
}

function powerline_precmd() {
  local __ERRCODE=$?
  local __DURATION=0

  if [ -n $__TIMER ]; then
    local __ERT=$EPOCHREALTIME
    __DURATION="$(($__ERT - ${__TIMER:-__ERT}))"
  fi

  eval "$(powerline-go -cwd-max-depth 1 -jobs ${${(%):%j}:-0} -modules cwd,jobs -duration $__DURATION -error $__ERRCODE -shell zsh -eval -modules-right duration,node,docker,dotenv,kube,venv,git,exit)"
  export BASE_PROMPT=$PROMPT

  unset __TIMER
}

precmd_functions+=(powerline_precmd)

function vi-mode-prompt {
  case ${KEYMAP} in
    (vicmd)      echo -e "\\e[48;5;245m C \\e[0m" ;;
    (main|viins) echo -e "\\e[48;5;202m I \\e[0m" ;;
    (*)          echo -e "\\e[48;5;202m I \\e[0m" ;;
  esac
}

function zle-line-init zle-keymap-select {
  PS1="$(vi-mode-prompt)$BASE_PROMPT"
  zle reset-prompt
}
zle -N zle-line-init
zle -N zle-keymap-select

setopt transient_rprompt