diff options
| author | Michal Hanus <mikehanus@protonmail.com> | 2025-12-29 20:48:24 +0100 |
|---|---|---|
| committer | Michal Hanus <mikehanus@protonmail.com> | 2025-12-29 20:50:40 +0100 |
| commit | cefb9c71a979df1aff40cfcf488d14e565a6668f (patch) | |
| tree | a9005f46fe32149a0ec731cb4d17b30f7a3c4d95 /.zshrc | |
| parent | 5eda7770be54f222e27e87190a95847e6d0e2c8c (diff) | |
git and zsh vi mode
Diffstat (limited to '.zshrc')
| -rw-r--r-- | .zshrc | 48 |
1 files changed, 30 insertions, 18 deletions
@@ -2,7 +2,21 @@ # Enable colors and change prompt: autoload -U colors && colors + +export GIT_PS1_SHOWUPSTREAM="verbose" + PS1="%B%{$fg[yellow]%}%n% %{$fg[blue]%}%~ %{$fg[green]%}$%{$reset_color%}%b " + +source /usr/lib/git-core/git-sh-prompt + +set_git_prompt() { + RPS1="%{$fg[yellow]%} $(__git_ps1 " %s") %{$reset_color%} " +} + +# Add the function to the precmd hook list +autoload -Uz add-zsh-hook +add-zsh-hook precmd set_git_prompt + #PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b " # Luke Conf zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' @@ -36,26 +50,24 @@ bindkey -M menuselect 'l' vi-forward-char bindkey -M menuselect 'j' vi-down-line-or-history bindkey -v '^?' backward-delete-char -# Change cursor shape for different vi modes. -function zle-keymap-select { - if [[ ${KEYMAP} == vicmd ]] || - [[ $1 = 'block' ]]; then - echo -ne '\e[1 q' - elif [[ ${KEYMAP} == main ]] || - [[ ${KEYMAP} == viins ]] || - [[ ${KEYMAP} = '' ]] || - [[ $1 = 'beam' ]]; then - echo -ne '\e[5 q' - fi -} -zle -N zle-keymap-select -zle-line-init() { - zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere) - echo -ne "\e[5 q" +# Change <> for vi mode +function zle-line-init zle-keymap-select { + if [[ ${KEYMAP} == vicmd ]] || + [[ $1 = 'block' ]]; then + PS1="%B%{$fg[yellow]%}%n% %{$fg[blue]%}%~ %{$fg[green]%}<%{$reset_color%}%b " + elif [[ ${KEYMAP} == main ]] || + [[ ${KEYMAP} == viins ]] || + [[ ${KEYMAP} = '' ]] || + [[ $1 = 'beam' ]]; then + PS1="%B%{$fg[yellow]%}%n% %{$fg[blue]%}%~ %{$fg[green]%}>%{$reset_color%}%b " + else + PS1="%B%{$fg[yellow]%}%n% %{$fg[blue]%}%~ %{$fg[green]%}v%{$reset_color%}%b " + fi + zle reset-prompt } + zle -N zle-line-init -echo -ne '\e[5 q' # Use beam shape cursor on startup. -preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt. +zle -N zle-keymap-select # Use lf to switch directories and bind it to ctrl-o lfcd () { |
