system-helpers/etc/skel/.zshrc

132 lines
3.8 KiB
Bash
Raw Normal View History

# This configuration makes use of zsh-syntax-highlighting.
# Some alias will call pre-defined applications.
# Ensure to install them if a command is not working.
#
2018-08-27 16:37:14 +00:00
# SETTINGS
autoload -U compinit promptinit
autoload -U colors && colors
compinit
promptinit
prompt walters
zstyle ':completion:*' menu select
setopt completealiases
setopt HIST_IGNORE_DUPS
PROMPT="%{$fg[red]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg_no_bold[yellow]%}%1~%{$reset_color%} #"
RPROMPT="[%{$fg_no_bold[yellow]%}%?%{$reset_color%}]"
LS_COLORS='rs=0:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:';
# HISTORY
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
2018-08-27 16:37:14 +00:00
# EXPORTS
export LS_COLORS
# ALIAS & FUNCTIONS
2018-08-27 16:37:14 +00:00
alias ls="ls --color -F"
alias ll="ls --color -lh -a"
alias ll-octal-dir='stat -c "%a %n" *'
alias ip='ip -c'
alias n="nano"
alias ..='cd ..'
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
2019-01-11 16:10:16 +00:00
alias fd='fd -H'
2018-08-27 16:37:14 +00:00
alias e='$EDITOR'
alias edit='$EDITOR'
2019-09-04 20:31:16 +00:00
alias free-cached-memory='sync && sudo echo 3 > /proc/sys/vm/drop_caches'
2018-08-27 16:37:14 +00:00
function chpwd() {
ll
}
process-name() {
ps -p $1 -o comm=
}
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# SOURCE CUSTOM USER-SPECIFIC
2018-08-27 16:37:14 +00:00
if [ -f ~/.zsh_custom ]; then
source ~/.zsh_custom
fi
if [ -f ~/.zsh_systemd ]; then
source ~/.zsh_systemd
fi
if [ -f ~/.zsh_archlinux ]; then
source ~/.zsh_archlinux
fi
2018-08-27 16:37:14 +00:00
# KEYBINDINGS
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
[[ -n "${key[PageUp]}" ]] && bindkey "${key[PageUp]}" beginning-of-buffer-or-history
[[ -n "${key[PageDown]}" ]] && bindkey "${key[PageDown]}" end-of-buffer-or-history
if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
function zle-line-init () {
printf '%s' "${terminfo[smkx]}"
}
function zle-line-finish () {
printf '%s' "${terminfo[rmkx]}"
}
zle -N zle-line-init
zle -N zle-line-finish
fi
2019-09-06 14:40:48 +00:00
# DIRSTACK
DIRSTACKSIZE=${DIRSTACKSIZE:-20}
dirstack_file=${dirstack_file:-${HOME}/.zdirs}
if [[ -f ${dirstack_file} ]] && [[ ${#dirstack[*]} -eq 0 ]] ; then
dirstack=( ${(f)"$(< $dirstack_file)"} )
# "cd -" won't work after login by just setting $OLDPWD, so
[[ -d $dirstack[1] ]] && cd $dirstack[1] && cd $OLDPWD
fi
chpwd_functions+=(chpwd_dirpersist)
chpwd_dirpersist() {
if (( $DIRSTACKSIZE <= 0 )) || [[ -z $dirstack_file ]]; then return; fi
local -ax my_stack
my_stack=( ${PWD} ${dirstack} )
builtin print -l ${(u)my_stack} >! ${dirstack_file}
}
2018-08-27 16:37:14 +00:00
# HIGHLIGHTING
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh