Merged .zshrc

Also implemented the concept of .zshrc.local and thus removed Worktop
specific exports and aliases.
This commit is contained in:
Patrick Engström 2020-04-22 23:17:29 +02:00
parent 315dd9e220
commit c9eb386dff

101
.zshrc
View File

@ -1,3 +1,4 @@
zstyle :compinstall filename '/home/patrick/.zshrc'
autoload -Uz promptinit && promptinit autoload -Uz promptinit && promptinit
autoload -Uz compinit && compinit autoload -Uz compinit && compinit
autoload -Uz colors && colors autoload -Uz colors && colors
@ -7,28 +8,55 @@ zstyle ':completion:*' accept-exact "*(N)"
zstyle ':completion:*' use-cache on zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/compcache zstyle ':completion:*' cache-path ~/.zsh/compcache
bindkey -v # Fix keyboard
bindkey '^?' backward-delete-char bindkey -v # Vi bindings
bindkey '^R' history-incremental-search-backward export KEYTIMEOUT=1 # Reduce esc timeout
if [[ "${terminfo[khome]}" != "" ]]; then
bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line
fi
if [[ "${terminfo[kend]}" != "" ]]; then
bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line
fi
# PROMPT bindkey ' ' magic-space # [Space] - do history expansion
if [[ "${terminfo[kcbt]}" != "" ]]; then
bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards
fi
bindkey '^?' backward-delete-char # [Backspace] - delete backward
if [[ "${terminfo[kdch1]}" != "" ]]; then
bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward
else
bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char
fi
bindkey '^R' history-incremental-search-backward # Reverse history search
# Enable colors
# GIT PROMPT
function parse_git_dirty() { function parse_git_dirty() {
STATUS=$(command git status --porcelain --untracked-files=no | tail -n1) STATUS=$(command git status --porcelain --untracked-files=no | tail -n1)
if [[ -n $STATUS ]]; then if [[ -n $STATUS ]]; then
echo "%{$fg[red]%}✗" echo "%{$fg[red]%}✘"
else else
echo "%{$fg[green]%}✔" echo "%{$fg[green]%}✔"
fi fi
} }
function git_prompt() { function git_prompt() {
isgit=$(command git rev-parse --is-inside-work-tree 2>/dev/null) isgit=$(command git rev-parse --is-inside-work-tree 2>/dev/null)
if [[ $isgit == "true" ]]; then if [[ $isgit == "true" ]]; then
ref=$(command git symbolic-ref HEAD -q --short) ref=$(command git symbolic-ref HEAD -q --short)
echo "%{$fg[cyan]%}$ref $(parse_git_dirty)%{$reset_color%}" echo "%{$fg[cyan]%}$ref$(parse_git_dirty)%{$reset_color%}"
fi fi
} }
# Theme
setopt promptsubst setopt promptsubst
GIT='$(git_prompt)' GIT='$(git_prompt)'
PROMPT="%(?, ,%{$fg[red]%}FAIL%{$reset_color%} PROMPT="%(?, ,%{$fg[red]%}FAIL%{$reset_color%}
@ -42,41 +70,42 @@ zstyle ':completion:*:*:*:*:*' menu select
# Case insensitive autocomplete # Case insensitive autocomplete
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*' zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' list-colors '' zstyle ':completion:*' list-colors ''
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
# disable named-directories autocompletion
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
# Loading dots for autocomplete
expand-or-complete-with-dots() { expand-or-complete-with-dots() {
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam
print -Pn "%{%F{red}......%f%}" print -Pn "%{%F{red}......%f%}"
[[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam
zle expand-or-complete zle expand-or-complete
zle redisplay zle redisplay
} }
zle -N expand-or-complete-with-dots zle -N expand-or-complete-with-dots
bindkey '^I' expand-or-complete-with-dots bindkey '^I' expand-or-complete-with-dots
HISTFILE=~/.zsh_history HISTFILE=~/.zsh_history
HISTSIZE=10000 HISTSIZE=1000
SAVEHIST=10000 SAVEHIST=1000
setopt extendedglob setopt extendedglob
setopt histignoredups
export EDITOR='vim' if [ -f ~/.zshrc.local ]; then
source ~/.zshrc.local
fi
alias pacman='sudo pacman --color always' # SSH Agent using Keychain
alias ls='ls --color=auto' eval $(keychain --eval --quiet id_ed25519 id_ecdsa id_dsa id_rockrobo old_id_ed25519)
alias iptables='sudo iptables'
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME'
# PAZI # PAZI
if command -v pazi &>/dev/null; then if command -v pazi &>/dev/null; then
eval "$(pazi init zsh)" eval "$(pazi init zsh)"
fi fi
# Ensure our build toolchain is in the path! export LANG=en_GB.UTF-8
export PATH="/opt/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH" export LC_CTYPE=en_GB.UTF-8
export EDITOR='vim'
# Add gems to path
export PATH="$HOME/.gem/ruby/2.7.0/bin:$PATH"
# Enable ccache
export PATH="/usr/lib/ccache/bin/:$PATH"