This repository has been archived by the owner on Oct 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzlerc
109 lines (88 loc) · 2.77 KB
/
zlerc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env zsh
#: vi set ft=sh
# Add ZLE widgets
function _git-status () {
zle -U "git status"
zle accept-line
}
zle -N _git-status
bindkey '\eg' _git-status
[ -f "${DOTFILES}/colors" ] && source "${DOTFILES}/colors"
# zle -N zle-line-init
# zle -N zle-keymap-select
vim_prompt() {
if [ ! -z $VIMRUNTIME ]; then
echo ":%F{green}sh ";
fi
}
# Simple git prompt sets if there are changes in your
# branch (sets a green dot) or the number of modified
# files + if there are untracked files.
# I forgot where I got this originally but will try to credit!
git_prompt() {
BRANCH=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*\(.*\)/\1/')
# 140 is light magenta
if [ ! -z $BRANCH ]; then
echo -n "%F{$GIT_BRANCH_COLOR}$BRANCH"
if git status --short 1>/dev/null 2>&1; then
num_changes=$(git status --short | wc -l | tr -d ' ')
if [ "$num_changes" -gt "0" ]; then
# 146 is light grey/blueish
echo " %F{$GIT_CHANGED_COLOR}● %F{$GIT_STAGED_COLOR}($num_changes)"
else
echo " %F{$GIT_CLEAN_COLOR}●"
fi
fi
fi
}
# color output for man:
# https://wiki.archlinux.org/index.php/Color_output_in_console#man
man() {
LESS_TERMCAP_md=$'\e[01;31m' \
LESS_TERMCAP_me=$'\e[0m' \
LESS_TERMCAP_se=$'\e[0m' \
LESS_TERMCAP_so=$'\e[01;44;33m' \
LESS_TERMCAP_ue=$'\e[0m' \
LESS_TERMCAP_us=$'\e[01;32m' \
command man "$@"
}
#PS1='
#$(vim_prompt)%B%F{159}%~$(git_prompt)
#%B%F{141}$PRETTY_PROMPT_CHAR %F{reset}'
PS1='
$(vim_prompt)%B%F{$DIR_COLOR}%~$(git_prompt)
%B%F{$PROMPT_COLOR}$PRETTY_PROMPT_CHAR %F{reset}'
# inspired by https://github.com/katef
# ---------- zsh prompt
# $'\n' forces new line
PS2="%1~"$'\n'"; "
# Configure keybindings
bindkey -M viins '^B' vi-backward-char
bindkey -M viins '^P' vi-up-line-or-history
bindkey -M viins '^N' vi-down-line-or-history
bindkey -M viins '^E' vi-end-of-line
bindkey -M viins '^A' vi-beginning-of-line
bindkey -M viins '^R' history-incremental-search-backward
bindkey -M viins '^K' vi-kill-eol
bindkey -M viins '^U' backward-kill-line
bindkey -M viins '^Y' vi-put-after
bindkey -M viins '^T' transpose-chars
bindkey -M viins '^F' autosuggest-accept
bindkey -M viins '\et' transpose-words
bindkey -M viins '\eu' vi-up-case
bindkey -M viins '\el' vi-down-case
bindkey -M viins '\ec' capitalize-word
bindkey -M viins '\e.' vi-yank
bindkey -M viins '\ef' vi-forward-word
bindkey -M viins '\eb' vi-backward-word
function custom-vi-cmd-mode {
zle vi-cmd-mode
zle vi-forward-char
}
zle -N custom-vi-cmd-mode
bindkey -M viins '\\j' custom-vi-cmd-mode
# [ Enter the command line with `⌥ v` ]
autoload -Uz edit-command-line
bindkey -M viins '\ev' edit-command-line
bindkey -M vicmd '\ev' edit-command-line
zle -N edit-command-line