Skip to content

feat: Support specific color for mode #6

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,16 @@ spaceship add --before char vi_mode

## Options

| Variable | Default | Meaning |
| :------------------------- | :--------------------------------: | ------------------------------------ |
| `SPACESHIP_VI_MODE_SHOW` | `true` | Show section |
| `SPACESHIP_VI_MODE_PREFIX` | - | Section's prefix |
| `SPACESHIP_VI_MODE_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Section's suffix |
| `SPACESHIP_VI_MODE_INSERT` | `[I]` | Text to be shown when in insert mode |
| `SPACESHIP_VI_MODE_NORMAL` | `[N]` | Text to be shown when in normal mode |
| `SPACESHIP_VI_MODE_COLOR` | `white` | Sectin's color |
| Variable | Default | Meaning |
| :------------------------------: | :--------------------------------: | ------------------------------------ |
| `SPACESHIP_VI_MODE_SHOW` | `true` | Show section |
| `SPACESHIP_VI_MODE_PREFIX` | - | Section's prefix |
| `SPACESHIP_VI_MODE_SUFFIX` | `$SPACESHIP_PROMPT_DEFAULT_SUFFIX` | Section's suffix |
| `SPACESHIP_VI_MODE_INSERT` | `[I]` | Text to be shown when in insert mode |
| `SPACESHIP_VI_MODE_NORMAL` | `[N]` | Text to be shown when in normal mode |
| `SPACESHIP_VI_MODE_COLOR` | `white` | Sectin's color |
| `SPACESHIP_VI_MODE_INSERT_COLOR` | `$SPACESHIP_VI_MODE_COLOR` | Sectin's color |
| `SPACESHIP_VI_MODE_NORMAL_COLOR` | `$SPACESHIP_VI_MODE_COLOR` | Sectin's color |

## Helpers

Expand Down
7 changes: 6 additions & 1 deletion spaceship-vi-mode.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SPACESHIP_VI_MODE_SUFFIX="${SPACESHIP_VI_MODE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_
SPACESHIP_VI_MODE_INSERT="${SPACESHIP_VI_MODE_INSERT="[I]"}"
SPACESHIP_VI_MODE_NORMAL="${SPACESHIP_VI_MODE_NORMAL="[N]"}"
SPACESHIP_VI_MODE_COLOR="${SPACESHIP_VI_MODE_COLOR="white"}"
SPACESHIP_VI_MODE_INSERT_COLOR="${SPACESHIP_VI_MODE_INSERT_COLOR=${SPACESHIP_VI_MODE_COLOR}}"
SPACESHIP_VI_MODE_NORMAL_COLOR="${SPACESHIP_VI_MODE_NORMAL_COLOR=${SPACESHIP_VI_MODE_COLOR}}"

# ------------------------------------------------------------------------------
# Section
Expand All @@ -23,18 +25,21 @@ spaceship_vi_mode() {

if bindkey | grep "vi-quoted-insert" > /dev/null 2>&1; then # check if vi-mode enabled
local mode_indicator="${SPACESHIP_VI_MODE_INSERT}"
local mode_indicator_color="${SPACESHIP_VI_MODE_INSERT_COLOR}"

case "${KEYMAP}" in
main|viins)
mode_indicator="${SPACESHIP_VI_MODE_INSERT}"
mode_indicator_color="${SPACESHIP_VI_MODE_INSERT_COLOR}"
;;
vicmd)
mode_indicator="${SPACESHIP_VI_MODE_NORMAL}"
mode_indicator_color="${SPACESHIP_VI_MODE_NORMAL_COLOR}"
;;
esac

spaceship::section::v3 \
"$SPACESHIP_VI_MODE_COLOR" \
"$mode_indicator_color" \
"$SPACESHIP_VI_MODE_PREFIX" \
"$mode_indicator" \
"$SPACESHIP_VI_MODE_SUFFIX"
Expand Down