dots/.config/zsh/.zshrc

67 lines
1.6 KiB
Bash

git_prompt() {
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3-)"
local branch_truncated="${branch:0:30}"
if (( ${#branch} > ${#branch_truncated} )); then
branch="${branch_truncated}..."
fi
[ -n "${branch}" ] && echo " (${branch})"
}
setopt PROMPT_SUBST
autoload -U colors && colors # Load colors
PROMPT='%1~%f%b%F{blue}$(git_prompt)%f $ '
# gpg key for ssh authentication
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
export GPG_TTY=$(tty)
stty stop undef
setopt autocd
setopt interactive_comments
setopt extendedglob
# Load aliases
source $XDG_CONFIG_HOME/shell/aliases
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.cache/history
setopt INC_APPEND_HISTORY
setopt HIST_IGNORE_ALL_DUPS
# Basic auto/tab complete:
autoload -U compinit
zmodload zsh/complist
compinit
_comp_options+=(globdots) # Include hidden files.
# vi mode
bindkey -v
export KEYTIMEOUT=1
# Use vim keys in tab complete menu:
bindkey -v '^?' backward-delete-char
# Change cursor shape for different vi modes.
function zle-keymap-select () {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block
viins|main) echo -ne '\e[5 q';; # beam
esac
}
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"
}
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.
bindkey -s '^f' 'cd "$(dirname "$(fzf)")"\n'
bindkey -v '^r' 'history-incremental-search-backward'
bindkey '^[[P' delete-char