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

Support for keymap highlighting #23

Open
wants to merge 3 commits 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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ function install_powerline_precmd() {
if [ "$TERM" != "linux" ]; then
install_powerline_precmd
fi

function zle-line-init zle-keymap-select {
export KEYMAP_POWERLINE=$KEYMAP
powerline_precmd
zle reset-prompt
}

zle -N zle-line-init
zle -N zle-keymap-select
```

### Fish
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ var modules = map[string](func(*powerline)){
"time": segmentTime,
"user": segmentUser,
"venv": segmentVirtualEnv,
"keymap": segmentKeymap,
}

func main() {
Expand Down
31 changes: 31 additions & 0 deletions segment-keymap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"os"
)

var editSegment = segment{
content: "\u270E",
foreground: 15,
background: 161,
}

var commandSegment = segment{
content: "\u26CF",
foreground: 15,
background: 31,
}

func segmentKeymap(p *powerline) {
var keymap string
if keymap == "" {
keymap, _ = os.LookupEnv("KEYMAP_POWERLINE")
}
if keymap == "main" {
p.appendSegment("keymap", editSegment)
}
if keymap == "vicmd" {
p.appendSegment("keymap", commandSegment)
}

}