mirror of https://github.com/tiyn/dotfiles
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.1 KiB
98 lines
3.1 KiB
4 years ago
|
# Disable ctrl-s and ctrl-q.
|
||
|
stty -ixon
|
||
|
|
||
|
setopt autocd autopushd \
|
||
|
|
||
|
# Enable colors and change prompt
|
||
|
autoload -U colors && colors
|
||
|
autoload -Uz vcs_info
|
||
|
precmd_vcs_info() { vcs_info }
|
||
|
precmd_functions+=( precmd_vcs_info )
|
||
|
zstyle ':vcs_info:*' enable git
|
||
|
zstyle ':vcs_info:git*:*' get-revision true
|
||
|
zstyle ':vcs_info:git*:*' check-for-changes true
|
||
|
zstyle ':vcs_info:git*' formats "(%s) %c%u %b%m"
|
||
|
zstyle ':vcs_info:git*' actionformats "(%s|%a) %12.12i %c%u %b%m"
|
||
|
setopt prompt_subst
|
||
|
# Show remote ref name and number of commits ahead-of or behind
|
||
|
function +vi-git-st() {
|
||
|
local ahead behind remote
|
||
|
local -a gitstatus
|
||
|
# Are we on a remote-tracking branch?
|
||
|
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
|
||
|
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
|
||
|
if [[ -n ${remote} ]] ; then
|
||
|
# for git prior to 1.7
|
||
|
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
|
||
|
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
|
||
|
(( $ahead )) && gitstatus+=( " ${c3}+${ahead}${c2}" )
|
||
|
# for git prior to 1.7
|
||
|
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
|
||
|
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
|
||
|
(( $behind )) && gitstatus+=( "${c4}-${behind}${c2}" )
|
||
|
hook_com[branch]="${hook_com[branch]} [${remote}${(j:/:)gitstatus}]"
|
||
|
fi
|
||
|
}
|
||
|
# Show count of stashed changes
|
||
|
function +vi-git-stash() {
|
||
|
local -a stashes
|
||
|
if [[ -s ${hook_com[base]}/.git/refs/stash ]] ; then
|
||
|
stashes=$(git stash list 2>/dev/null | wc -l)
|
||
|
hook_com[misc]+=" (${stashes} stashed)"
|
||
|
fi
|
||
|
}
|
||
|
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-stash
|
||
|
PS1='%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}#%b '
|
||
|
RPROMPT='%B%{$fg[magenta]%}$vcs_info_msg_0_%{$reset_color%}%b'
|
||
|
|
||
|
# History in cache directory
|
||
|
HISTSIZE=10000
|
||
|
SAVEHIST=10000
|
||
|
HISTFILE=~/.cache/shhistory
|
||
|
|
||
|
# Basic auto/tab complete
|
||
|
autoload -U compinit
|
||
|
zstyle ':completion:*' menu select
|
||
|
zmodload zsh/complist
|
||
|
compinit
|
||
|
_comp_options+=(globdots) # Include hidden files
|
||
|
|
||
|
# Enable vi mode
|
||
|
bindkey -v
|
||
|
export KEYTIMEOUT=1
|
||
|
# Vim bindings in tab mode
|
||
|
bindkey -M menuselect 'h' vi-backward-char
|
||
|
bindkey -M menuselect 'k' vi-up-line-or-history
|
||
|
bindkey -M menuselect 'l' vi-forward-char
|
||
|
bindkey -M menuselect 'j' vi-down-line-or-history
|
||
|
bindkey -v '^?' backward-delete-char
|
||
|
# Vim Cursor shape
|
||
|
function zle-keymap-select {
|
||
|
if [[ ${KEYMAP} == vicmd ]] ||
|
||
|
[[ $1 = 'block' ]]; then
|
||
|
echo -ne '\e[1 q'
|
||
|
elif [[ ${KEYMAP} == main ]] ||
|
||
|
[[ ${KEYMAP} == viins ]] ||
|
||
|
[[ ${KEYMAP} == '' ]]; then
|
||
|
echo -ne '\e[5 q'
|
||
|
fi
|
||
|
}
|
||
|
zle -N zle-keymap-select
|
||
|
zle-line-init() {
|
||
|
zle -K viins
|
||
|
echo -ne "\e[5 q"
|
||
|
}
|
||
|
zle -N zle-line-init
|
||
|
echo -ne '\e[5 q'
|
||
|
preexec() { echo -ne '\e[5 q' ;}
|
||
|
|
||
|
[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc" # Load aliases
|
||
|
|
||
|
source $HOME/.profile 2>/dev/null # Load .profile
|
||
|
|
||
|
if [[ -n "$PS1" ]] && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
|
||
|
tmux attach-session -t $USER || tmux new-session -s $USER
|
||
|
fi
|
||
|
|
||
|
pfetch
|