Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim mode indicator is not a powerline segment #323

Open
xsteadfastx opened this issue Aug 4, 2021 · 2 comments
Open

vim mode indicator is not a powerline segment #323

xsteadfastx opened this issue Aug 4, 2021 · 2 comments
Labels

Comments

@xsteadfastx
Copy link

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):

  • OS: linux
  • Architecture: x86_64
  • Shell: fish

grafik

@xsteadfastx xsteadfastx added the bug label Aug 4, 2021
@derphilipp
Copy link

Same issue on

  • macOS + fish (amd64)
  • Arch + fish (amd64, armv7)
  • Raspbian + fish (armv6)
  • Ubuntu + fish (armv7)

@blackheaven
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants