.zshrc

make sure to install zsh-syntax-highlighting & zsh-autosuggestions
mail@pastecode.io avatar
unknown
sh
2 years ago
4.0 kB
1
Indexable
Never
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=500
SAVEHIST=500
setopt autocd notify
unsetopt beep
bindkey -e
# End of lines configured by zsh-newuser-install

# User defined options
autoload -U compinit colors vcs_info
colors
compinit
# Report command running time if it is more than 3 seconds
REPORTTIME=3
# Add commands to history as they are entered, don't wait for shell to exit
setopt INC_APPEND_HISTORY
# Also remember command start time & duration
setopt EXTENDED_HISTORY
# Do not keep duplicate commands in history
setopt HIST_IGNORE_ALL_DUPS
# Do not remember commands that start with a whitespace
setopt HIST_IGNORE_SPACE
# Correct spelling of all arguments in the command line
setopt CORRECT_ALL
# Enable autocompletion
zstyle ':completion:*' completer _complete _correct _approximate

zstyle ':vcs_info:*' stagedstr '%F{green}●%f '
zstyle ':vcs_info:*' unstagedstr '%F{yellow}●%f '
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%F{blue}%b%f %u%c"

_setup_ps1() {
  vcs_info
  GLYPH="▲"
  [ "x$KEYMAP" = "xvicmd" ] && GLYPH="▼"
  PS1="%F{yellow}~%f""%F{green}%n%f""%F{yellow}@%f""%F{red}%m%f"$'\n'"%(?.%F{blue}.%F{red})$GLYPH%f %(1j.%F{cyan}[%j]%f .)%F{blue}%~%f%(!.%F{red}#%f .)"$'\n'"%F{white}$ %f"
  RPROMPT="$vcs_info_msg_0_"
}
_setup_ps1

# user-friendly command output
export CLICOLOR=1
ls --color=auto &> /dev/null && alias ls='ls --color=auto'

# Set umask for non-login shell
umask 077

# My env variables
export EDITOR=vim
export HISTCONTROL=ignoredups:ignorespace
export C_INCLUDE_PATH=/usr/local/include
export LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH=/usr/local/lib
bin=/usr/local/bin ; export bin
# Wayland support
MOZ_ENABLE_WAYLAND=1

# set aliases
alias ls='ls --color=auto'
alias lx='ls -X --color=auto'
alias l='ls -CF --color=auto'
alias lh='ls -lh --color=auto'
alias la='ls -A --color=auto'
alias lah='ls -lah --color=auto'
alias ld='ls -ld --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir -h --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias ip='ip -color=auto'
alias df='df -h'
alias rm='rm -I'
alias cp='cp -i'
alias mv='mv -i'
alias dr='dir -h --group-directories-first --color'
alias du='du -h'
alias mkdir='mkdir -p'
alias python='python3'
alias free='free -h'
alias dd='dd status="progress"'
alias p='pwd ; ls -CF'
alias d='date "+%d %b %Y"'
alias mypass='cat /etc/passwd'
alias query='xbps-query'
alias remove='doas xbps-remove'
alias ins='doas xbps-install'

# Color manpages
man() {
    LESS_TERMCAP_md=$'\e[01;31m' \
    LESS_TERMCAP_me=$'\e[0m' \
    LESS_TERMCAP_se=$'\e[0m' \
    LESS_TERMCAP_so=$'\e[01;44;33m' \
    LESS_TERMCAP_ue=$'\e[0m' \
    LESS_TERMCAP_us=$'\e[01;32m' \
    command man "$@"
}

# add login message
clear
printf "Welcome $USER to $HOST\n"
date
printf "Logged on users:"
w | cut -d " " -f 1 - | grep -v USER | sort -u
uptime

# Activate zsh-syntax-highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Activate zsh-autosuggestions
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

# bindkeys from /etc/inputrc "sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc"
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
#bindkey # "\e[5~" beginning-of-history
#bindkey # "\e[6~" end-of-history
#bindkey # "\e[5~" history-search-backward
#bindkey # "\e[6~" history-search-forward
bindkey "\e[1;5C" forward-word
bindkey "\e[1;5D" backward-word
bindkey "\e[5C" forward-word
bindkey "\e[5D" backward-word
bindkey "\e\e[C" forward-word
bindkey "\e\e[D" backward-word
bindkey "\e[8~" end-of-line
bindkey "\eOc" forward-word
bindkey "\eOd" backward-word
#bindkey # "\eOH" beginning-of-line
#bindkey # "\eOF" end-of-line
#bindkey # "\e[H" beginning-of-line
#bindkey # "\e[F" end-of-line